@@ -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
@@ -864,7 +855,7 @@ symbols! {
864
855
drop_types_in_const,
865
856
dropck_eyepatch,
866
857
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
868
859
dummy_cgu_name,
869
860
dylib,
870
861
dyn_compatible_for_dispatch,
@@ -883,6 +874,14 @@ symbols! {
883
874
emit_enum_variant_arg,
884
875
emit_struct,
885
876
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: "" ,
886
885
emscripten_wasm_eh,
887
886
enable,
888
887
encode,
@@ -2362,7 +2361,7 @@ impl Ident {
2362
2361
#[ inline]
2363
2362
/// Constructs a new identifier from a symbol and a span.
2364
2363
pub fn new ( name : Symbol , span : Span ) -> Ident {
2365
- debug_assert_ne ! ( name, kw :: Empty ) ;
2364
+ debug_assert_ne ! ( name, sym :: empty ) ;
2366
2365
Ident { name, span }
2367
2366
}
2368
2367
@@ -2584,7 +2583,7 @@ impl Symbol {
2584
2583
}
2585
2584
2586
2585
pub fn is_empty ( self ) -> bool {
2587
- self == kw :: Empty
2586
+ self == sym :: empty
2588
2587
}
2589
2588
2590
2589
/// This method is supposed to be used in error messages, so it's expected to be
@@ -2593,7 +2592,7 @@ impl Symbol {
2593
2592
/// or edition, so we have to guess the rawness using the global edition.
2594
2593
pub fn to_ident_string ( self ) -> String {
2595
2594
// 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 ( ) }
2597
2596
}
2598
2597
}
2599
2598
@@ -2773,7 +2772,7 @@ impl Symbol {
2773
2772
2774
2773
/// Returns `true` if this symbol can be a raw identifier.
2775
2774
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 ( )
2777
2776
}
2778
2777
2779
2778
/// Was this symbol predefined in the compiler's `symbols!` macro
0 commit comments