@@ -323,8 +323,8 @@ impl NameAndSpan {
323323 pub fn name ( & self ) -> Symbol {
324324 match self . format {
325325 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 ( ) ,
328328 }
329329 }
330330}
@@ -337,7 +337,39 @@ pub enum ExpnFormat {
337337 /// e.g. `format!()`
338338 MacroBang ( Symbol ) ,
339339 /// 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+ }
341373}
342374
343375impl Encodable for SyntaxContext {
0 commit comments