@@ -402,17 +402,16 @@ impl PrintContext {
402
402
* has_default. unwrap_or ( & false )
403
403
} ;
404
404
if has_default {
405
- if let Some ( substs) = tcx. lift ( & substs) {
406
- let types = substs. types ( ) . rev ( ) . skip ( child_types) ;
407
- for ( ( def_id, has_default) , actual) in type_params. zip ( types) {
408
- if !has_default {
409
- break ;
410
- }
411
- if tcx. type_of ( def_id) . subst ( tcx, substs) != actual {
412
- break ;
413
- }
414
- num_supplied_defaults += 1 ;
405
+ let substs = tcx. lift ( & substs) . expect ( "could not lift for printing" ) ;
406
+ let types = substs. types ( ) . rev ( ) . skip ( child_types) ;
407
+ for ( ( def_id, has_default) , actual) in type_params. zip ( types) {
408
+ if !has_default {
409
+ break ;
415
410
}
411
+ if tcx. type_of ( def_id) . subst ( tcx, substs) != actual {
412
+ break ;
413
+ }
414
+ num_supplied_defaults += 1 ;
416
415
}
417
416
}
418
417
}
@@ -517,15 +516,13 @@ impl PrintContext {
517
516
Ok ( ( ) )
518
517
}
519
518
520
- // FIXME(eddyb) replace `'almost_tcx` with `'tcx` when possible/needed.
521
- fn in_binder < ' a , ' gcx , ' tcx , ' almost_tcx , T , U , F > (
519
+ fn in_binder < ' a , ' gcx , ' tcx , T , F > (
522
520
& mut self ,
523
521
f : & mut F ,
524
522
tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
525
- original : & ty:: Binder < T > ,
526
- lifted : Option < ty:: Binder < U > > ,
523
+ value : ty:: Binder < T > ,
527
524
) -> fmt:: Result
528
- where T : Print < ' almost_tcx > , U : Print < ' tcx > + TypeFoldable < ' tcx > , F : fmt:: Write
525
+ where T : Print < ' tcx > + TypeFoldable < ' tcx > , F : fmt:: Write
529
526
{
530
527
fn name_by_region_index ( index : usize ) -> InternedString {
531
528
match index {
@@ -540,12 +537,6 @@ impl PrintContext {
540
537
// clearly differentiate between named and unnamed regions in
541
538
// the output. We'll probably want to tweak this over time to
542
539
// decide just how much information to give.
543
- let value = if let Some ( v) = lifted {
544
- v
545
- } else {
546
- return original. skip_binder ( ) . print_display ( f, self ) ;
547
- } ;
548
-
549
540
if self . binder_depth == 0 {
550
541
self . prepare_late_bound_region_info ( & value) ;
551
542
}
@@ -1084,7 +1075,8 @@ impl fmt::Debug for ty::FloatVarValue {
1084
1075
for<'a> <T as ty::Lift<'a>>::Lifted: fmt::Display + TypeFoldable<'a>
1085
1076
{
1086
1077
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1087
- ty::tls::with(|tcx| in_binder(f, tcx, self, tcx.lift(self)))
1078
+ ty::tls::with(|tcx| in_binder(f, tcx, tcx.lift(self)
1079
+ .expect("could not lift for printing")))
1088
1080
}
1089
1081
}*/
1090
1082
@@ -1101,7 +1093,8 @@ define_print_multi! {
1101
1093
]
1102
1094
( self , f, cx) {
1103
1095
display {
1104
- ty:: tls:: with( |tcx| cx. in_binder( f, tcx, self , tcx. lift( self ) ) )
1096
+ ty:: tls:: with( |tcx| cx. in_binder( f, tcx, tcx. lift( self )
1097
+ . expect( "could not lift for printing" ) ) )
1105
1098
}
1106
1099
}
1107
1100
}
@@ -1169,10 +1162,9 @@ define_print! {
1169
1162
}
1170
1163
FnDef ( def_id, substs) => {
1171
1164
ty:: tls:: with( |tcx| {
1172
- let mut sig = tcx. fn_sig( def_id) ;
1173
- if let Some ( substs) = tcx. lift( & substs) {
1174
- sig = sig. subst( tcx, substs) ;
1175
- }
1165
+ let substs = tcx. lift( & substs)
1166
+ . expect( "could not lift for printing" ) ;
1167
+ let sig = tcx. fn_sig( def_id) . subst( tcx, substs) ;
1176
1168
print!( f, cx, print( sig) , write( " {{" ) )
1177
1169
} ) ?;
1178
1170
cx. parameterized( f, substs, def_id, & [ ] ) ?;
@@ -1243,11 +1235,9 @@ define_print! {
1243
1235
}
1244
1236
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
1245
1237
// by looking up the projections associated with the def_id.
1246
- let predicates_of = tcx. predicates_of( def_id) ;
1247
- let substs = tcx. lift( & substs) . unwrap_or_else( || {
1248
- tcx. intern_substs( & [ ] )
1249
- } ) ;
1250
- let bounds = predicates_of. instantiate( tcx, substs) ;
1238
+ let substs = tcx. lift( & substs)
1239
+ . expect( "could not lift for printing" ) ;
1240
+ let bounds = tcx. predicates_of( def_id) . instantiate( tcx, substs) ;
1251
1241
1252
1242
let mut first = true ;
1253
1243
let mut is_sized = false ;
@@ -1314,7 +1304,8 @@ define_print! {
1314
1304
print!( f, cx, write( " " ) , print( witness) , write( "]" ) )
1315
1305
} ) ,
1316
1306
GeneratorWitness ( types) => {
1317
- ty:: tls:: with( |tcx| cx. in_binder( f, tcx, & types, tcx. lift( & types) ) )
1307
+ ty:: tls:: with( |tcx| cx. in_binder( f, tcx, tcx. lift( & types)
1308
+ . expect( "could not lift for printing" ) ) )
1318
1309
}
1319
1310
Closure ( did, substs) => ty:: tls:: with( |tcx| {
1320
1311
let upvar_tys = substs. upvar_tys( did, tcx) ;
0 commit comments