From: Owen Avery Date: Wed, 27 Mar 2024 01:57:17 +0000 (-0400) Subject: gccrs: Recognize rustc_deprecated as a builtin attribute X-Git-Tag: basepoints/gcc-16~6969 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cde7407ec09fce2041f8e55f2408c2a55c0b05fa;p=thirdparty%2Fgcc.git gccrs: Recognize rustc_deprecated as a builtin attribute gcc/rust/ChangeLog: * util/rust-attribute-values.h (Attributes::RUSTC_DEPRECATED): New. * util/rust-attributes.cc (__definitions): Add Attributes::RUSTC_DEPRECATED. gcc/testsuite/ChangeLog: * rust/compile/deprecated-fn.rs: New test. Signed-off-by: Owen Avery --- diff --git a/gcc/rust/util/rust-attribute-values.h b/gcc/rust/util/rust-attribute-values.h index e284cec1a16..04aef99be68 100644 --- a/gcc/rust/util/rust-attribute-values.h +++ b/gcc/rust/util/rust-attribute-values.h @@ -48,6 +48,7 @@ public: static constexpr auto &TARGET_FEATURE = "target_feature"; // From now on, these are reserved by the compiler and gated through // #![feature(rustc_attrs)] + static constexpr auto &RUSTC_DEPRECATED = "rustc_deprecated"; static constexpr auto &RUSTC_INHERIT_OVERFLOW_CHECKS = "rustc_inherit_overflow_checks"; static constexpr auto &STABLE = "stable"; diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc index eac29808299..e10918b2f8d 100644 --- a/gcc/rust/util/rust-attributes.cc +++ b/gcc/rust/util/rust-attributes.cc @@ -58,6 +58,7 @@ static const BuiltinAttrDefinition __definitions[] {Attrs::TARGET_FEATURE, CODE_GENERATION}, // From now on, these are reserved by the compiler and gated through // #![feature(rustc_attrs)] + {Attrs::RUSTC_DEPRECATED, STATIC_ANALYSIS}, {Attrs::RUSTC_INHERIT_OVERFLOW_CHECKS, CODE_GENERATION}, {Attrs::STABLE, STATIC_ANALYSIS}}; diff --git a/gcc/testsuite/rust/compile/deprecated-fn.rs b/gcc/testsuite/rust/compile/deprecated-fn.rs new file mode 100644 index 00000000000..4083593b30b --- /dev/null +++ b/gcc/testsuite/rust/compile/deprecated-fn.rs @@ -0,0 +1,4 @@ +#![feature(rustc_attrs)] + +#[rustc_deprecated(since = "right now", reason = "a whim")] +pub fn foo() {}