@@ -2386,31 +2386,32 @@ pub fn rendered_const<'tcx>(tcx: TyCtxt<'tcx>, body: hir::BodyId) -> String {
23862386        } 
23872387    } 
23882388
2389-     let  classification = classify ( value) ; 
2390- 
2391-     if  classification == Literal 
2392-         && !value. span . from_expansion ( ) 
2393-         && let  Ok ( snippet)  = tcx. sess . source_map ( ) . span_to_snippet ( value. span ) 
2394-     { 
2395-         // For literals, we avoid invoking the pretty-printer and use the source snippet instead to 
2396-         // preserve certain stylistic choices the user likely made for the sake legibility like 
2389+     match  classify ( value)  { 
2390+         // For non-macro literals, we avoid invoking the pretty-printer and use the source snippet 
2391+         // instead to preserve certain stylistic choices the user likely made for the sake of 
2392+         // legibility, like: 
23972393        // 
23982394        // * hexadecimal notation 
23992395        // * underscores 
24002396        // * character escapes 
24012397        // 
24022398        // FIXME: This passes through `-/*spacer*/0` verbatim. 
2403-         snippet
2404-     }  else  if  classification == Simple  { 
2399+         Literal  if  !value. span . from_expansion ( ) 
2400+             && let  Ok ( snippet)  = tcx. sess . source_map ( ) . span_to_snippet ( value. span )  => { 
2401+             snippet
2402+         } 
2403+ 
24052404        // Otherwise we prefer pretty-printing to get rid of extraneous whitespace, comments and 
24062405        // other formatting artifacts. 
2407-         id_to_string ( & hir,  body. hir_id ) 
2408-      }   else   if  tcx . def_kind ( hir . body_owner_def_id ( body ) . to_def_id ( ) )  ==  DefKind :: AnonConst   { 
2406+         Literal  |  Simple  =>  id_to_string ( & hir,  body. hir_id ) , 
2407+ 
24092408        // FIXME: Omit the curly braces if the enclosing expression is an array literal 
24102409        //        with a repeated element (an `ExprKind::Repeat`) as in such case it 
24112410        //        would not actually need any disambiguation. 
2412-         "{ _ }" . to_owned ( ) 
2413-     }  else  { 
2414-         "_" . to_owned ( ) 
2411+         Complex  => if  tcx. def_kind ( hir. body_owner_def_id ( body) . to_def_id ( ) )  == DefKind :: AnonConst  { 
2412+             "{ _ }" . to_owned ( ) 
2413+         }  else  { 
2414+             "_" . to_owned ( ) 
2415+         } 
24152416    } 
24162417} 
0 commit comments