Skip to content

Commit c2de483

Browse files
committed
feature gate
1 parent 52f3cd5 commit c2de483

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
516516
}
517517
};
518518
}
519+
gate_all!(forced_keywords, "`k#ident` syntax is experimental",);
519520
gate_all!(
520521
if_let_guard,
521522
"`if let` guards are experimental",

compiler/rustc_feature/src/unstable.rs

+2
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,8 @@ declare_features! (
473473
(unstable, fn_align, "1.53.0", Some(82232)),
474474
/// Support delegating implementation of functions to other already implemented functions.
475475
(incomplete, fn_delegation, "1.76.0", Some(118212)),
476+
/// Support forcing an ident to be recognized as a keyword through `k#ident`.
477+
(unstable, forced_keywords, "CURRENT_RUSTC_VERSION", None),
476478
/// Allows defining gen blocks and `gen fn`.
477479
(unstable, gen_blocks, "1.75.0", Some(117078)),
478480
/// Infer generic args for both consts and types.

compiler/rustc_parse/src/lexer/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ impl<'a> StringReader<'a> {
194194
rustc_lexer::TokenKind::KeywordIdent => {
195195
let sym = nfc_normalize(self.str_from(start));
196196
let span = self.mk_sp(start, self.pos);
197+
self.sess.gated_spans.gate(sym::forced_keywords, span);
197198
self.sess.symbol_gallery.insert(sym, span);
198199
token::Ident(sym, IdentKind::Keyword)
199200
}

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ symbols! {
787787
fn_ptr_addr,
788788
fn_ptr_trait,
789789
forbid,
790+
forced_keywords,
790791
forget,
791792
format,
792793
format_alignment,

0 commit comments

Comments
 (0)