From 42119ff45c75e5e3ced06f1f45a9e4853fb5bca9 Mon Sep 17 00:00:00 2001 From: jdonszelmann Date: Tue, 14 May 2024 16:10:05 +0200 Subject: [PATCH 1/3] create a feature gate --- compiler/rustc_ast_passes/src/feature_gate.rs | 1 + compiler/rustc_feature/src/unstable.rs | 2 ++ compiler/rustc_span/src/symbol.rs | 1 + tests/ui/feature-gates/feature-gate-global-registration.rs | 1 + 4 files changed, 5 insertions(+) create mode 100644 tests/ui/feature-gates/feature-gate-global-registration.rs diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 6622caaaab4..a522f04b21d 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -560,6 +560,7 @@ macro_rules! gate_all { gate_all!(postfix_match, "postfix match is experimental"); gate_all!(mut_ref, "mutable by-reference bindings are experimental"); gate_all!(precise_capturing, "precise captures on `impl Trait` are experimental"); + gate_all!(global_registration, "global registration is experimental"); if !visitor.features.never_patterns { if let Some(spans) = spans.get(&sym::never_patterns) { diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 60b386acf91..a25b7ef10a4 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -487,6 +487,8 @@ pub fn internal(&self, feature: Symbol) -> bool { (incomplete, generic_const_exprs, "1.56.0", Some(76560)), /// Allows generic parameters and where-clauses on free & associated const items. (incomplete, generic_const_items, "1.73.0", Some(113521)), + /// Allows registring static items globally, possibly across crates, to iterate over at runtime. + (unstable, global_registration, "CURRENT_RUSTC_VERSION", Some(125119)), /// Allows using `..=X` as a patterns in slices. (unstable, half_open_range_patterns_in_slices, "1.66.0", Some(67264)), /// Allows `if let` guard in match arms. diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index d41059e8c24..192c7a27bd6 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -928,6 +928,7 @@ global_alloc_ty, global_allocator, global_asm, + global_registration, globs, gt, half_open_range_patterns, diff --git a/tests/ui/feature-gates/feature-gate-global-registration.rs b/tests/ui/feature-gates/feature-gate-global-registration.rs new file mode 100644 index 00000000000..77072727ec5 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-global-registration.rs @@ -0,0 +1 @@ +//! WIP From 1d9757cd849989691becceb15e0e7c2ec37a3452 Mon Sep 17 00:00:00 2001 From: jdonszelmann Date: Mon, 20 May 2024 09:18:49 +0200 Subject: [PATCH 2/3] add todo test for feature gate --- .../feature-gate-global-registration.rs | 4 +++- .../feature-gate-global-registration.stderr | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/ui/feature-gates/feature-gate-global-registration.stderr diff --git a/tests/ui/feature-gates/feature-gate-global-registration.rs b/tests/ui/feature-gates/feature-gate-global-registration.rs index 77072727ec5..6ac36712090 100644 --- a/tests/ui/feature-gates/feature-gate-global-registration.rs +++ b/tests/ui/feature-gates/feature-gate-global-registration.rs @@ -1 +1,3 @@ -//! WIP +todo!(); //~ ERROR + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-global-registration.stderr b/tests/ui/feature-gates/feature-gate-global-registration.stderr new file mode 100644 index 00000000000..70538ae6f31 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-global-registration.stderr @@ -0,0 +1,13 @@ +error: expected one of `!` or `::`, found `(` + --> $DIR/feature-gate-global-registration.rs:1:1 + | +LL | todo!(); + | ^^^^^^^ + | | + | expected one of `!` or `::` + | in this macro invocation + | + = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + From a2e0f10639bd2c8828267ade0a06ce7a477ce685 Mon Sep 17 00:00:00 2001 From: Felix S Klock II Date: Mon, 20 May 2024 11:55:20 -0400 Subject: [PATCH 3/3] address nit --- compiler/rustc_feature/src/unstable.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index a25b7ef10a4..b374c0df42a 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -487,7 +487,7 @@ pub fn internal(&self, feature: Symbol) -> bool { (incomplete, generic_const_exprs, "1.56.0", Some(76560)), /// Allows generic parameters and where-clauses on free & associated const items. (incomplete, generic_const_items, "1.73.0", Some(113521)), - /// Allows registring static items globally, possibly across crates, to iterate over at runtime. + /// Allows registering static items globally, possibly across crates, to iterate over at runtime. (unstable, global_registration, "CURRENT_RUSTC_VERSION", Some(125119)), /// Allows using `..=X` as a patterns in slices. (unstable, half_open_range_patterns_in_slices, "1.66.0", Some(67264)),