Bypass ppaux for Outlives predicates

This commit is contained in:
scalexm 2018-11-01 14:32:32 +01:00
parent 3510805f7e
commit 239df7be37
8 changed files with 48 additions and 18 deletions

View File

@ -442,11 +442,41 @@ impl<'tcx> fmt::Display for traits::WhereClause<'tcx> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
use traits::WhereClause::*;
// Bypass ppaux because it does not print out anonymous regions.
fn write_region_name<'tcx>(
r: ty::Region<'tcx>,
fmt: &mut fmt::Formatter<'_>
) -> fmt::Result {
match r {
ty::ReLateBound(index, br) => match br {
ty::BoundRegion::BrNamed(_, name) => write!(fmt, "{}", name),
ty::BoundRegion::BrAnon(var) => {
if *index == ty::INNERMOST {
write!(fmt, "'^{}", var)
} else {
write!(fmt, "'^{}_{}", index.index(), var)
}
}
_ => write!(fmt, "'_"),
}
_ => write!(fmt, "{}", r),
}
}
match self {
Implemented(trait_ref) => write!(fmt, "Implemented({})", trait_ref),
ProjectionEq(projection) => write!(fmt, "ProjectionEq({})", projection),
RegionOutlives(predicate) => write!(fmt, "RegionOutlives({})", predicate),
TypeOutlives(predicate) => write!(fmt, "TypeOutlives({})", predicate),
RegionOutlives(predicate) => {
write!(fmt, "RegionOutlives({}: ", predicate.0)?;
write_region_name(predicate.1, fmt)?;
write!(fmt, ")")
}
TypeOutlives(predicate) => {
write!(fmt, "TypeOutlives({}: ", predicate.0)?;
write_region_name(predicate.1, fmt)?;
write!(fmt, ")")
}
}
}
}
@ -567,7 +597,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundNamesCollector {
match bound_ty.kind {
ty::BoundTyKind::Param(name) => name,
ty::BoundTyKind::Anon => Symbol::intern(
&format!("?{}", bound_ty.var.as_u32())
&format!("^{}", bound_ty.var.as_u32())
).as_interned_str(),
}
);
@ -591,7 +621,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundNamesCollector {
ty::BoundRegion::BrAnon(var) => {
self.regions.insert(Symbol::intern(
&format!("?'{}", var)
&format!("'^{}", var)
).as_interned_str());
}

View File

@ -1114,9 +1114,9 @@ define_print! {
match bound_ty.kind {
ty::BoundTyKind::Anon => {
if bound_ty.index == ty::INNERMOST {
write!(f, "?{}", bound_ty.var.index())
write!(f, "^{}", bound_ty.var.index())
} else {
write!(f, "?{}_{}", bound_ty.index.index(), bound_ty.var.index())
write!(f, "^{}_{}", bound_ty.index.index(), bound_ty.var.index())
}
}

View File

@ -191,7 +191,7 @@ fn program_clauses_for_tuple<'tcx>(
.map(|i| ty::BoundTy::new(ty::INNERMOST, ty::BoundVar::from(i)))
.map(|t| tcx.mk_ty(ty::Bound(t)))
);
let tuple_ty = tcx.mk_ty(ty::Tuple(type_list));
let sized_trait = match tcx.lang_items().sized_trait() {

View File

@ -5,8 +5,8 @@ LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: forall<'a, T> { FromEnv(T: Foo) :- FromEnv(S<'a, T>). }
= note: forall<'a, T> { TypeOutlives(T : 'a) :- FromEnv(S<'a, T>). }
= note: forall<'a, T> { WellFormed(S<'a, T>) :- Implemented(T: Foo), TypeOutlives(T : 'a). }
= note: forall<'a, T> { TypeOutlives(T: 'a) :- FromEnv(S<'a, T>). }
= note: forall<'a, T> { WellFormed(S<'a, T>) :- Implemented(T: Foo), TypeOutlives(T: 'a). }
error: program clause dump
--> $DIR/lower_env2.rs:21:1
@ -15,7 +15,7 @@ LL | #[rustc_dump_env_program_clauses] //~ ERROR program clause dump
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: forall<'a, T> { FromEnv(T: Foo) :- FromEnv(S<'a, T>). }
= note: forall<'a, T> { TypeOutlives(T : 'a) :- FromEnv(S<'a, T>). }
= note: forall<'a, T> { TypeOutlives(T: 'a) :- FromEnv(S<'a, T>). }
= note: forall<Self> { Implemented(Self: Foo) :- FromEnv(Self: Foo). }
= note: forall<Self> { Implemented(Self: std::marker::Sized) :- FromEnv(Self: std::marker::Sized). }

View File

@ -4,7 +4,7 @@ error: program clause dump
LL | #[rustc_dump_env_program_clauses] //~ ERROR program clause dump
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: forall<?'0, ?1> { TypeOutlives(?1 : ) :- FromEnv(&?1). }
= note: forall<'^0, ^1> { TypeOutlives(^1: '^0) :- FromEnv(&^1). }
= note: forall<Self> { Implemented(Self: Foo) :- FromEnv(Self: Foo). }
error: program clause dump
@ -13,7 +13,7 @@ error: program clause dump
LL | #[rustc_dump_env_program_clauses] //~ ERROR program clause dump
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: forall<?'0, ?1> { TypeOutlives(?1 : ) :- FromEnv(&?1). }
= note: forall<'^0, ^1> { TypeOutlives(^1: '^0) :- FromEnv(&^1). }
= note: forall<Self> { FromEnv(Self: std::marker::Sized) :- FromEnv(Self: std::clone::Clone). }
= note: forall<Self> { Implemented(Self: std::clone::Clone) :- FromEnv(Self: std::clone::Clone). }
= note: forall<Self> { Implemented(Self: std::marker::Sized) :- FromEnv(Self: std::marker::Sized). }

View File

@ -4,7 +4,7 @@ error: program clause dump
LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: forall<T> { Implemented(T: Foo) :- ProjectionEq(<T as std::iter::Iterator>::Item == i32), TypeOutlives(T : 'static), Implemented(T: std::iter::Iterator), Implemented(T: std::marker::Sized). }
= note: forall<T> { Implemented(T: Foo) :- ProjectionEq(<T as std::iter::Iterator>::Item == i32), TypeOutlives(T: 'static), Implemented(T: std::iter::Iterator), Implemented(T: std::marker::Sized). }
error: program clause dump
--> $DIR/lower_impl.rs:23:5

View File

@ -6,8 +6,8 @@ LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump
|
= note: forall<'a, T> { FromEnv(T: std::marker::Sized) :- FromEnv(Foo<'a, T>). }
= note: forall<'a, T> { FromEnv(std::boxed::Box<T>: std::clone::Clone) :- FromEnv(Foo<'a, T>). }
= note: forall<'a, T> { TypeOutlives(T : 'a) :- FromEnv(Foo<'a, T>). }
= note: forall<'a, T> { WellFormed(Foo<'a, T>) :- Implemented(T: std::marker::Sized), Implemented(std::boxed::Box<T>: std::clone::Clone), TypeOutlives(T : 'a). }
= note: forall<'a, T> { TypeOutlives(T: 'a) :- FromEnv(Foo<'a, T>). }
= note: forall<'a, T> { WellFormed(Foo<'a, T>) :- Implemented(T: std::marker::Sized), Implemented(std::boxed::Box<T>: std::clone::Clone), TypeOutlives(T: 'a). }
error: aborting due to previous error

View File

@ -6,9 +6,9 @@ LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump
|
= note: forall<'a, 'b, Self, T, U> { FromEnv(T: std::borrow::Borrow<U>) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
= note: forall<'a, 'b, Self, T, U> { Implemented(Self: Foo<'a, 'b, T, U>) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
= note: forall<'a, 'b, Self, T, U> { RegionOutlives('a : 'b) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
= note: forall<'a, 'b, Self, T, U> { TypeOutlives(U : 'b) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
= note: forall<'a, 'b, Self, T, U> { WellFormed(Self: Foo<'a, 'b, T, U>) :- Implemented(Self: Foo<'a, 'b, T, U>), WellFormed(T: std::borrow::Borrow<U>), TypeOutlives(U : 'b), RegionOutlives('a : 'b), WellFormed(std::boxed::Box<T>). }
= note: forall<'a, 'b, Self, T, U> { RegionOutlives('a: 'b) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
= note: forall<'a, 'b, Self, T, U> { TypeOutlives(U: 'b) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
= note: forall<'a, 'b, Self, T, U> { WellFormed(Self: Foo<'a, 'b, T, U>) :- Implemented(Self: Foo<'a, 'b, T, U>), WellFormed(T: std::borrow::Borrow<U>), TypeOutlives(U: 'b), RegionOutlives('a: 'b), WellFormed(std::boxed::Box<T>). }
= note: forall<'a, 'b, Self, T, U> { WellFormed(std::boxed::Box<T>) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
error: aborting due to previous error