Skip to content

Commit 4cdc441

Browse files
committed
rustc: don't support tcx.lift returning None in ppaux.
1 parent 3c58216 commit 4cdc441

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

src/librustc/util/ppaux.rs

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -402,17 +402,16 @@ impl PrintContext {
402402
*has_default.unwrap_or(&false)
403403
};
404404
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;
415410
}
411+
if tcx.type_of(def_id).subst(tcx, substs) != actual {
412+
break;
413+
}
414+
num_supplied_defaults += 1;
416415
}
417416
}
418417
}
@@ -517,15 +516,13 @@ impl PrintContext {
517516
Ok(())
518517
}
519518

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>(
522520
&mut self,
523521
f: &mut F,
524522
tcx: TyCtxt<'a, 'gcx, 'tcx>,
525-
original: &ty::Binder<T>,
526-
lifted: Option<ty::Binder<U>>,
523+
value: ty::Binder<T>,
527524
) -> 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
529526
{
530527
fn name_by_region_index(index: usize) -> InternedString {
531528
match index {
@@ -540,12 +537,6 @@ impl PrintContext {
540537
// clearly differentiate between named and unnamed regions in
541538
// the output. We'll probably want to tweak this over time to
542539
// 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-
549540
if self.binder_depth == 0 {
550541
self.prepare_late_bound_region_info(&value);
551542
}
@@ -1084,7 +1075,8 @@ impl fmt::Debug for ty::FloatVarValue {
10841075
for<'a> <T as ty::Lift<'a>>::Lifted: fmt::Display + TypeFoldable<'a>
10851076
{
10861077
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")))
10881080
}
10891081
}*/
10901082

@@ -1101,7 +1093,8 @@ define_print_multi! {
11011093
]
11021094
(self, f, cx) {
11031095
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")))
11051098
}
11061099
}
11071100
}
@@ -1169,10 +1162,9 @@ define_print! {
11691162
}
11701163
FnDef(def_id, substs) => {
11711164
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);
11761168
print!(f, cx, print(sig), write(" {{"))
11771169
})?;
11781170
cx.parameterized(f, substs, def_id, &[])?;
@@ -1243,11 +1235,9 @@ define_print! {
12431235
}
12441236
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
12451237
// 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);
12511241

12521242
let mut first = true;
12531243
let mut is_sized = false;
@@ -1314,7 +1304,8 @@ define_print! {
13141304
print!(f, cx, write(" "), print(witness), write("]"))
13151305
}),
13161306
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")))
13181309
}
13191310
Closure(did, substs) => ty::tls::with(|tcx| {
13201311
let upvar_tys = substs.upvar_tys(did, tcx);

0 commit comments

Comments
 (0)