@@ -323,8 +323,8 @@ impl NameAndSpan {
323
323
pub fn name ( & self ) -> Symbol {
324
324
match self . format {
325
325
ExpnFormat :: MacroAttribute ( s) |
326
- ExpnFormat :: MacroBang ( s) |
327
- ExpnFormat :: CompilerDesugaring ( s ) => s ,
326
+ ExpnFormat :: MacroBang ( s) => s ,
327
+ ExpnFormat :: CompilerDesugaring ( ref kind ) => kind . as_symbol ( ) ,
328
328
}
329
329
}
330
330
}
@@ -337,7 +337,39 @@ pub enum ExpnFormat {
337
337
/// e.g. `format!()`
338
338
MacroBang ( Symbol ) ,
339
339
/// Desugaring done by the compiler during HIR lowering.
340
- CompilerDesugaring ( Symbol )
340
+ CompilerDesugaring ( CompilerDesugaringKind )
341
+ }
342
+
343
+ /// The kind of compiler desugaring.
344
+ #[ derive( Clone , Hash , Debug , PartialEq , Eq ) ]
345
+ pub enum CompilerDesugaringKind {
346
+ BackArrow ,
347
+ DotFill ,
348
+ QuestionMark ,
349
+ }
350
+
351
+ impl CompilerDesugaringKind {
352
+ pub fn as_symbol ( & self ) -> Symbol {
353
+ use CompilerDesugaringKind :: * ;
354
+ let s = match * self {
355
+ BackArrow => "<-" ,
356
+ DotFill => "..." ,
357
+ QuestionMark => "?" ,
358
+ } ;
359
+ Symbol :: intern ( s)
360
+ }
361
+ }
362
+
363
+ impl < ' a > From < & ' a str > for CompilerDesugaringKind {
364
+ fn from ( s : & ' a str ) -> Self {
365
+ use CompilerDesugaringKind :: * ;
366
+ match s {
367
+ "<-" => BackArrow ,
368
+ "..." => DotFill ,
369
+ "?" => QuestionMark ,
370
+ _ => panic ! ( "Invalid compiler desugaring" ) ,
371
+ }
372
+ }
341
373
}
342
374
343
375
impl Encodable for SyntaxContext {
0 commit comments