@@ -2375,31 +2375,32 @@ pub fn rendered_const<'tcx>(tcx: TyCtxt<'tcx>, body: hir::BodyId) -> String {
23752375        } 
23762376    } 
23772377
2378-     let  classification = classify ( value) ; 
2379- 
2380-     if  classification == Literal 
2381-         && !value. span . from_expansion ( ) 
2382-         && let  Ok ( snippet)  = tcx. sess . source_map ( ) . span_to_snippet ( value. span ) 
2383-     { 
2384-         // For literals, we avoid invoking the pretty-printer and use the source snippet instead to 
2385-         // preserve certain stylistic choices the user likely made for the sake legibility like 
2378+     match  classify ( value)  { 
2379+         // For non-macro literals, we avoid invoking the pretty-printer and use the source snippet 
2380+         // instead to preserve certain stylistic choices the user likely made for the sake of 
2381+         // legibility, like: 
23862382        // 
23872383        // * hexadecimal notation 
23882384        // * underscores 
23892385        // * character escapes 
23902386        // 
23912387        // FIXME: This passes through `-/*spacer*/0` verbatim. 
2392-         snippet
2393-     }  else  if  classification == Simple  { 
2388+         Literal  if  !value. span . from_expansion ( ) 
2389+             && let  Ok ( snippet)  = tcx. sess . source_map ( ) . span_to_snippet ( value. span )  => { 
2390+             snippet
2391+         } 
2392+ 
23942393        // Otherwise we prefer pretty-printing to get rid of extraneous whitespace, comments and 
23952394        // other formatting artifacts. 
2396-         id_to_string ( & hir,  body. hir_id ) 
2397-      }   else   if  tcx . def_kind ( hir . body_owner_def_id ( body ) . to_def_id ( ) )  ==  DefKind :: AnonConst   { 
2395+         Literal  |  Simple  =>  id_to_string ( & hir,  body. hir_id ) , 
2396+ 
23982397        // FIXME: Omit the curly braces if the enclosing expression is an array literal 
23992398        //        with a repeated element (an `ExprKind::Repeat`) as in such case it 
24002399        //        would not actually need any disambiguation. 
2401-         "{ _ }" . to_owned ( ) 
2402-     }  else  { 
2403-         "_" . to_owned ( ) 
2400+         Complex  => if  tcx. def_kind ( hir. body_owner_def_id ( body) . to_def_id ( ) )  == DefKind :: AnonConst  { 
2401+             "{ _ }" . to_owned ( ) 
2402+         }  else  { 
2403+             "_" . to_owned ( ) 
2404+         } 
24042405    } 
24052406} 
0 commit comments