diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc index bc5bc944e772..a6816cf1603a 100644 --- a/gcc/rust/expand/rust-macro-builtins.cc +++ b/gcc/rust/expand/rust-macro-builtins.cc @@ -123,6 +123,8 @@ std::unordered_map {"test_case", MacroBuiltin::sorry}, {"global_allocator", MacroBuiltin::sorry}, {"cfg_accessible", MacroBuiltin::sorry}, + {"rustc_const_stable", MacroBuiltin::sorry}, + {"rustc_const_unstable", MacroBuiltin::sorry}, /* Derive builtins do not need a real transcriber, but still need one. It should however never be called since builtin derive macros get expanded differently, and benefit from knowing on what kind of items they are diff --git a/gcc/rust/util/rust-attribute-values.h b/gcc/rust/util/rust-attribute-values.h index a8551c07dba6..a7eaf9ffa70c 100644 --- a/gcc/rust/util/rust-attribute-values.h +++ b/gcc/rust/util/rust-attribute-values.h @@ -53,6 +53,8 @@ class Attributes = "rustc_inherit_overflow_checks"; static constexpr auto &STABLE = "stable"; static constexpr auto &UNSTABLE = "unstable"; + static constexpr auto &RUSTC_CONST_STABLE = "rustc_const_stable"; + static constexpr auto &RUSTC_CONST_UNSTABLE = "rustc_const_unstable"; }; } // namespace Values } // namespace Rust diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc index 84d1781d0b36..33166673c28a 100644 --- a/gcc/rust/util/rust-attributes.cc +++ b/gcc/rust/util/rust-attributes.cc @@ -61,7 +61,10 @@ static const BuiltinAttrDefinition __definitions[] {Attrs::RUSTC_DEPRECATED, STATIC_ANALYSIS}, {Attrs::RUSTC_INHERIT_OVERFLOW_CHECKS, CODE_GENERATION}, {Attrs::STABLE, STATIC_ANALYSIS}, - {Attrs::UNSTABLE, STATIC_ANALYSIS}}; + {Attrs::UNSTABLE, STATIC_ANALYSIS}, + // assuming we keep these for static analysis + {Attrs::RUSTC_CONST_STABLE, STATIC_ANALYSIS}, + {Attrs::RUSTC_CONST_UNSTABLE, STATIC_ANALYSIS}}; BuiltinAttributeMappings * BuiltinAttributeMappings::get () diff --git a/gcc/testsuite/rust/compile/rustc_const_stable.rs b/gcc/testsuite/rust/compile/rustc_const_stable.rs index 9208b1ab3b62..a45355de6b37 100644 --- a/gcc/testsuite/rust/compile/rustc_const_stable.rs +++ b/gcc/testsuite/rust/compile/rustc_const_stable.rs @@ -1,2 +1,4 @@ +#![feature(rustc_attrs)] + #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] -pub fn foo() {} // { dg-error "macro not found" "" { target *-*-* } .-1 } +pub fn foo() {} diff --git a/gcc/testsuite/rust/compile/rustc_const_unstable.rs b/gcc/testsuite/rust/compile/rustc_const_unstable.rs new file mode 100644 index 000000000000..6cedefade720 --- /dev/null +++ b/gcc/testsuite/rust/compile/rustc_const_unstable.rs @@ -0,0 +1,4 @@ +#![feature(rustc_attrs)] + +#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "1234")] +pub fn foo() {}