@@ -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
@@ -864,7 +855,7 @@ symbols! {
864855 drop_types_in_const,
865856 dropck_eyepatch,
866857 dropck_parametricity,
867- dummy: "<!dummy!>" , // use this instead of `kw::Empty ` for symbols that won't be used
858+ dummy: "<!dummy!>" , // use this instead of `sym::empty ` for symbols that won't be used
868859 dummy_cgu_name,
869860 dylib,
870861 dyn_compatible_for_dispatch,
@@ -883,6 +874,14 @@ symbols! {
883874 emit_enum_variant_arg,
884875 emit_struct,
885876 emit_struct_field,
877+ // Notes about `sym::empty`:
878+ // - It should only be used when it genuinely means "empty symbol". Use
879+ // `Option<Symbol>` when "no symbol" is a possibility.
880+ // - For dummy symbols that are never used and absolutely must be
881+ // present, it's better to use `sym::dummy` than `sym::empty`, because
882+ // it's clearer that it's intended as a dummy value, and more likely
883+ // to be detected if it accidentally does get used.
884+ empty: "" ,
886885 emscripten_wasm_eh,
887886 enable,
888887 encode,
@@ -2362,7 +2361,7 @@ impl Ident {
23622361 #[ inline]
23632362 /// Constructs a new identifier from a symbol and a span.
23642363 pub fn new ( name : Symbol , span : Span ) -> Ident {
2365- debug_assert_ne ! ( name, kw :: Empty ) ;
2364+ debug_assert_ne ! ( name, sym :: empty ) ;
23662365 Ident { name, span }
23672366 }
23682367
@@ -2584,7 +2583,7 @@ impl Symbol {
25842583 }
25852584
25862585 pub fn is_empty ( self ) -> bool {
2587- self == kw :: Empty
2586+ self == sym :: empty
25882587 }
25892588
25902589 /// This method is supposed to be used in error messages, so it's expected to be
@@ -2593,7 +2592,7 @@ impl Symbol {
25932592 /// or edition, so we have to guess the rawness using the global edition.
25942593 pub fn to_ident_string ( self ) -> String {
25952594 // Avoid creating an empty identifier, because that asserts in debug builds.
2596- if self == kw :: Empty { String :: new ( ) } else { Ident :: with_dummy_span ( self ) . to_string ( ) }
2595+ if self == sym :: empty { String :: new ( ) } else { Ident :: with_dummy_span ( self ) . to_string ( ) }
25972596 }
25982597}
25992598
@@ -2773,7 +2772,7 @@ impl Symbol {
27732772
27742773 /// Returns `true` if this symbol can be a raw identifier.
27752774 pub fn can_be_raw ( self ) -> bool {
2776- self != kw :: Empty && self != kw:: Underscore && !self . is_path_segment_keyword ( )
2775+ self != sym :: empty && self != kw:: Underscore && !self . is_path_segment_keyword ( )
27772776 }
27782777
27792778 /// Was this symbol predefined in the compiler's `symbols!` macro
0 commit comments