Skip to content

Commit 6dc5fbc

Browse files
committed
rustc: tie the 'tcx between Print and PrintCx in ty::print.
1 parent d695d7d commit 6dc5fbc

File tree

9 files changed

+97
-90
lines changed

9 files changed

+97
-90
lines changed

src/librustc/infer/outlives/free_region_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl_stable_hash_for!(struct FreeRegionMap<'tcx> {
9191
impl<'a, 'tcx> Lift<'tcx> for FreeRegionMap<'a> {
9292
type Lifted = FreeRegionMap<'tcx>;
9393
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<FreeRegionMap<'tcx>> {
94-
self.relation.maybe_map(|&fr| fr.lift_to_tcx(tcx))
94+
self.relation.maybe_map(|&fr| tcx.lift(&fr))
9595
.map(|relation| FreeRegionMap { relation })
9696
}
9797
}

src/librustc/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
23772377
AggregateKind::Adt(adt_def, variant, substs, _user_ty, _) => {
23782378
let variant_def = &adt_def.variants[variant];
23792379

2380-
ppaux::parameterized(fmt, substs, variant_def.did, &[])?;
2380+
ppaux::parameterized(fmt, variant_def.did, substs)?;
23812381

23822382
match variant_def.ctor_kind {
23832383
CtorKind::Const => Ok(()),

src/librustc/ty/instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl<'tcx> InstanceDef<'tcx> {
174174

175175
impl<'tcx> fmt::Display for Instance<'tcx> {
176176
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
177-
ppaux::parameterized(f, self.substs, self.def_id(), &[])?;
177+
ppaux::parameterized(f, self.def_id(), self.substs)?;
178178
match self.def {
179179
InstanceDef::Item(_) => Ok(()),
180180
InstanceDef::VtableShim(_) => {

src/librustc/ty/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ impl<'a, 'gcx, 'tcx> Generics {
973973
}
974974

975975
/// Bounds on generics.
976-
#[derive(Clone, Default)]
976+
#[derive(Clone, Default, Debug)]
977977
pub struct GenericPredicates<'tcx> {
978978
pub parent: Option<DefId>,
979979
pub predicates: Vec<(Predicate<'tcx>, Span)>,
@@ -1475,7 +1475,7 @@ impl<'tcx> Predicate<'tcx> {
14751475
/// `[[], [U:Bar<T>]]`. Now if there were some particular reference
14761476
/// like `Foo<isize,usize>`, then the `InstantiatedPredicates` would be `[[],
14771477
/// [usize:Bar<isize>]]`.
1478-
#[derive(Clone)]
1478+
#[derive(Clone, Debug)]
14791479
pub struct InstantiatedPredicates<'tcx> {
14801480
pub predicates: Vec<Predicate<'tcx>>,
14811481
}

src/librustc/ty/print.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,32 +56,36 @@ impl PrintCx<'a, 'gcx, 'tcx> {
5656
}
5757

5858
pub trait Print<'tcx> {
59-
fn print<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintCx<'_, '_, '_>) -> fmt::Result;
60-
fn print_to_string(&self, cx: &mut PrintCx<'_, '_, '_>) -> String {
59+
fn print<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintCx<'_, '_, 'tcx>) -> fmt::Result;
60+
fn print_to_string(&self, cx: &mut PrintCx<'_, '_, 'tcx>) -> String {
6161
let mut result = String::new();
6262
let _ = self.print(&mut result, cx);
6363
result
6464
}
65-
fn print_display<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintCx<'_, '_, '_>) -> fmt::Result {
65+
fn print_display<F: fmt::Write>(
66+
&self,
67+
f: &mut F,
68+
cx: &mut PrintCx<'_, '_, 'tcx>,
69+
) -> fmt::Result {
6670
let old_debug = cx.is_debug;
6771
cx.is_debug = false;
6872
let result = self.print(f, cx);
6973
cx.is_debug = old_debug;
7074
result
7175
}
72-
fn print_display_to_string(&self, cx: &mut PrintCx<'_, '_, '_>) -> String {
76+
fn print_display_to_string(&self, cx: &mut PrintCx<'_, '_, 'tcx>) -> String {
7377
let mut result = String::new();
7478
let _ = self.print_display(&mut result, cx);
7579
result
7680
}
77-
fn print_debug<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintCx<'_, '_, '_>) -> fmt::Result {
81+
fn print_debug<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintCx<'_, '_, 'tcx>) -> fmt::Result {
7882
let old_debug = cx.is_debug;
7983
cx.is_debug = true;
8084
let result = self.print(f, cx);
8185
cx.is_debug = old_debug;
8286
result
8387
}
84-
fn print_debug_to_string(&self, cx: &mut PrintCx<'_, '_, '_>) -> String {
88+
fn print_debug_to_string(&self, cx: &mut PrintCx<'_, '_, 'tcx>) -> String {
8589
let mut result = String::new();
8690
let _ = self.print_debug(&mut result, cx);
8791
result

src/librustc/ty/structural_impls.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ CloneTypeFoldableAndLiftImpls! {
4747
// really meant to be folded. In general, we can only fold a fully
4848
// general `Region`.
4949
::ty::BoundRegion,
50+
::ty::Placeholder<::ty::BoundRegion>,
5051
::ty::ClosureKind,
52+
::ty::FreeRegion,
53+
::ty::InferTy,
5154
::ty::IntVarValue,
5255
::ty::ParamTy,
5356
::ty::UniverseIndex,
@@ -472,6 +475,13 @@ impl<'a, 'tcx> Lift<'tcx> for ty::InstanceDef<'a> {
472475
}
473476
}
474477

478+
BraceStructLiftImpl! {
479+
impl<'a, 'tcx> Lift<'tcx> for ty::TypeAndMut<'a> {
480+
type Lifted = ty::TypeAndMut<'tcx>;
481+
ty, mutbl
482+
}
483+
}
484+
475485
BraceStructLiftImpl! {
476486
impl<'a, 'tcx> Lift<'tcx> for ty::Instance<'a> {
477487
type Lifted = ty::Instance<'tcx>;
@@ -486,6 +496,16 @@ BraceStructLiftImpl! {
486496
}
487497
}
488498

499+
// FIXME(eddyb) this is like what `CloneTypeFoldableAndLiftImpls!`
500+
// generates, except that macro *also* generates a foldable impl,
501+
// which we don't want (with it we'd risk bypassing `fold_region`).
502+
impl<'tcx> Lift<'tcx> for ty::RegionKind {
503+
type Lifted = ty::RegionKind;
504+
fn lift_to_tcx<'b, 'gcx>(&self, _: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
505+
Some(self.clone())
506+
}
507+
}
508+
489509
BraceStructLiftImpl! {
490510
impl<'a, 'tcx> Lift<'tcx> for ty::Const<'a> {
491511
type Lifted = ty::Const<'tcx>;

src/librustc/ty/sty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ impl<'tcx> List<ExistentialPredicate<'tcx>> {
608608

609609
#[inline]
610610
pub fn projection_bounds<'a>(&'a self) ->
611-
impl Iterator<Item=ExistentialProjection<'tcx>> + 'a {
611+
impl Iterator<Item=ExistentialProjection<'tcx>> + Clone + 'a {
612612
self.iter().filter_map(|predicate| {
613613
match *predicate {
614614
ExistentialPredicate::Projection(p) => Some(p),

src/librustc/ty/subst.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ impl<'a, 'tcx> Lift<'tcx> for Kind<'a> {
122122

123123
fn lift_to_tcx<'cx, 'gcx>(&self, tcx: TyCtxt<'cx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
124124
match self.unpack() {
125-
UnpackedKind::Lifetime(a) => a.lift_to_tcx(tcx).map(|a| a.into()),
126-
UnpackedKind::Type(a) => a.lift_to_tcx(tcx).map(|a| a.into()),
125+
UnpackedKind::Lifetime(a) => tcx.lift(&a).map(|a| a.into()),
126+
UnpackedKind::Type(a) => tcx.lift(&a).map(|a| a.into()),
127127
}
128128
}
129129
}

0 commit comments

Comments
 (0)