@@ -2098,10 +2098,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
20982098 AggregateKind :: Closure ( def_id, substs) => ty:: tls:: with ( |tcx| {
20992099 let name = if tcx. sess . opts . unstable_opts . span_free_formats {
21002100 let substs = tcx. lift ( substs) . unwrap ( ) ;
2101- format ! (
2102- "[closure@{}]" ,
2103- tcx. def_path_str_with_substs( def_id. to_def_id( ) , substs) ,
2104- )
2101+ format ! ( "[closure@{}]" , tcx. def_path_str_with_substs( def_id, substs) , )
21052102 } else {
21062103 let span = tcx. def_span ( def_id) ;
21072104 format ! (
@@ -2112,11 +2109,17 @@ impl<'tcx> Debug for Rvalue<'tcx> {
21122109 let mut struct_fmt = fmt. debug_struct ( & name) ;
21132110
21142111 // FIXME(project-rfc-2229#48): This should be a list of capture names/places
2115- if let Some ( upvars) = tcx. upvars_mentioned ( def_id) {
2112+ if let Some ( def_id) = def_id. as_local ( )
2113+ && let Some ( upvars) = tcx. upvars_mentioned ( def_id)
2114+ {
21162115 for ( & var_id, place) in iter:: zip ( upvars. keys ( ) , places) {
21172116 let var_name = tcx. hir ( ) . name ( var_id) ;
21182117 struct_fmt. field ( var_name. as_str ( ) , place) ;
21192118 }
2119+ } else {
2120+ for ( index, place) in places. iter ( ) . enumerate ( ) {
2121+ struct_fmt. field ( & format ! ( "{index}" ) , place) ;
2122+ }
21202123 }
21212124
21222125 struct_fmt. finish ( )
@@ -2127,11 +2130,17 @@ impl<'tcx> Debug for Rvalue<'tcx> {
21272130 let mut struct_fmt = fmt. debug_struct ( & name) ;
21282131
21292132 // FIXME(project-rfc-2229#48): This should be a list of capture names/places
2130- if let Some ( upvars) = tcx. upvars_mentioned ( def_id) {
2133+ if let Some ( def_id) = def_id. as_local ( )
2134+ && let Some ( upvars) = tcx. upvars_mentioned ( def_id)
2135+ {
21312136 for ( & var_id, place) in iter:: zip ( upvars. keys ( ) , places) {
21322137 let var_name = tcx. hir ( ) . name ( var_id) ;
21332138 struct_fmt. field ( var_name. as_str ( ) , place) ;
21342139 }
2140+ } else {
2141+ for ( index, place) in places. iter ( ) . enumerate ( ) {
2142+ struct_fmt. field ( & format ! ( "{index}" ) , place) ;
2143+ }
21352144 }
21362145
21372146 struct_fmt. finish ( )
0 commit comments