@@ -34,17 +34,8 @@ symbols! {
3434 // unnamed method parameters, crate root module, error recovery etc.
3535 // Matching predicates: `is_special`/`is_reserved`
3636 //
37- // Notes about `kw::Empty`:
38- // - Its use can blur the lines between "empty symbol" and "no symbol".
39- // Using `Option<Symbol>` is preferable, where possible, because that
40- // is unambiguous.
41- // - For dummy symbols that are never used and absolutely must be
42- // present, it's better to use `sym::dummy` than `kw::Empty`, because
43- // it's clearer that it's intended as a dummy value, and more likely
44- // to be detected if it accidentally does get used.
4537 // tidy-alphabetical-start
4638 DollarCrate : "$crate" ,
47- Empty : "" ,
4839 PathRoot : "{{root}}" ,
4940 Underscore : "_" ,
5041 // tidy-alphabetical-end
@@ -863,7 +854,7 @@ symbols! {
863854 drop_types_in_const,
864855 dropck_eyepatch,
865856 dropck_parametricity,
866- dummy: "<!dummy!>" , // use this instead of `kw::Empty ` for symbols that won't be used
857+ dummy: "<!dummy!>" , // use this instead of `sym::empty ` for symbols that won't be used
867858 dummy_cgu_name,
868859 dylib,
869860 dyn_compatible_for_dispatch,
@@ -882,6 +873,14 @@ symbols! {
882873 emit_enum_variant_arg,
883874 emit_struct,
884875 emit_struct_field,
876+ // Notes about `sym::empty`:
877+ // - It should only be used when it genuinely means "empty symbol". Use
878+ // `Option<Symbol>` when "no symbol" is a possibility.
879+ // - For dummy symbols that are never used and absolutely must be
880+ // present, it's better to use `sym::dummy` than `sym::empty`, because
881+ // it's clearer that it's intended as a dummy value, and more likely
882+ // to be detected if it accidentally does get used.
883+ empty: "" ,
885884 emscripten_wasm_eh,
886885 enable,
887886 encode,
@@ -2361,7 +2360,7 @@ impl Ident {
23612360 #[ inline]
23622361 /// Constructs a new identifier from a symbol and a span.
23632362 pub fn new ( name : Symbol , span : Span ) -> Ident {
2364- debug_assert_ne ! ( name, kw :: Empty ) ;
2363+ debug_assert_ne ! ( name, sym :: empty ) ;
23652364 Ident { name, span }
23662365 }
23672366
@@ -2583,7 +2582,7 @@ impl Symbol {
25832582 }
25842583
25852584 pub fn is_empty ( self ) -> bool {
2586- self == kw :: Empty
2585+ self == sym :: empty
25872586 }
25882587
25892588 /// This method is supposed to be used in error messages, so it's expected to be
@@ -2592,7 +2591,7 @@ impl Symbol {
25922591 /// or edition, so we have to guess the rawness using the global edition.
25932592 pub fn to_ident_string ( self ) -> String {
25942593 // Avoid creating an empty identifier, because that asserts in debug builds.
2595- if self == kw :: Empty { String :: new ( ) } else { Ident :: with_dummy_span ( self ) . to_string ( ) }
2594+ if self == sym :: empty { String :: new ( ) } else { Ident :: with_dummy_span ( self ) . to_string ( ) }
25962595 }
25972596}
25982597
@@ -2772,7 +2771,7 @@ impl Symbol {
27722771
27732772 /// Returns `true` if this symbol can be a raw identifier.
27742773 pub fn can_be_raw ( self ) -> bool {
2775- self != kw :: Empty && self != kw:: Underscore && !self . is_path_segment_keyword ( )
2774+ self != sym :: empty && self != kw:: Underscore && !self . is_path_segment_keyword ( )
27762775 }
27772776
27782777 /// Was this symbol predefined in the compiler's `symbols!` macro
0 commit comments