@@ -34,17 +34,8 @@ symbols! {
34
34
// unnamed method parameters, crate root module, error recovery etc.
35
35
// Matching predicates: `is_special`/`is_reserved`
36
36
//
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.
45
37
// tidy-alphabetical-start
46
38
DollarCrate : "$crate" ,
47
- Empty : "" ,
48
39
PathRoot : "{{root}}" ,
49
40
Underscore : "_" ,
50
41
// tidy-alphabetical-end
@@ -863,7 +854,7 @@ symbols! {
863
854
drop_types_in_const,
864
855
dropck_eyepatch,
865
856
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
867
858
dummy_cgu_name,
868
859
dylib,
869
860
dyn_compatible_for_dispatch,
@@ -882,6 +873,14 @@ symbols! {
882
873
emit_enum_variant_arg,
883
874
emit_struct,
884
875
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: "" ,
885
884
emscripten_wasm_eh,
886
885
enable,
887
886
encode,
@@ -2361,7 +2360,7 @@ impl Ident {
2361
2360
#[ inline]
2362
2361
/// Constructs a new identifier from a symbol and a span.
2363
2362
pub fn new ( name : Symbol , span : Span ) -> Ident {
2364
- debug_assert_ne ! ( name, kw :: Empty ) ;
2363
+ debug_assert_ne ! ( name, sym :: empty ) ;
2365
2364
Ident { name, span }
2366
2365
}
2367
2366
@@ -2583,7 +2582,7 @@ impl Symbol {
2583
2582
}
2584
2583
2585
2584
pub fn is_empty ( self ) -> bool {
2586
- self == kw :: Empty
2585
+ self == sym :: empty
2587
2586
}
2588
2587
2589
2588
/// This method is supposed to be used in error messages, so it's expected to be
@@ -2592,7 +2591,7 @@ impl Symbol {
2592
2591
/// or edition, so we have to guess the rawness using the global edition.
2593
2592
pub fn to_ident_string ( self ) -> String {
2594
2593
// 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 ( ) }
2596
2595
}
2597
2596
}
2598
2597
@@ -2772,7 +2771,7 @@ impl Symbol {
2772
2771
2773
2772
/// Returns `true` if this symbol can be a raw identifier.
2774
2773
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 ( )
2776
2775
}
2777
2776
2778
2777
/// Was this symbol predefined in the compiler's `symbols!` macro
0 commit comments