Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't try to clean predicates involving ReErased #57851

Merged
merged 1 commit into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/librustdoc/clean/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,10 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
let mut ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)> = Default::default();

for (orig_p, p) in clean_where_predicates {
if p.is_none() {
continue;
}
let p = p.unwrap();
match p {
WherePredicate::BoundPredicate { ty, mut bounds } => {
// Writing a projection trait bound of the form
Expand Down
48 changes: 33 additions & 15 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,10 @@ impl Clean<Option<Lifetime>> for ty::RegionKind {
ty::RePlaceholder(..) |
ty::ReEmpty |
ty::ReClosureBound(_) |
ty::ReErased => None
ty::ReErased => {
debug!("Cannot clean region {:?}", self);
None
}
}
}
}
Expand Down Expand Up @@ -1310,16 +1313,16 @@ impl Clean<WherePredicate> for hir::WherePredicate {
}
}

impl<'a> Clean<WherePredicate> for ty::Predicate<'a> {
fn clean(&self, cx: &DocContext) -> WherePredicate {
impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
fn clean(&self, cx: &DocContext) -> Option<WherePredicate> {
use rustc::ty::Predicate;

match *self {
Predicate::Trait(ref pred) => pred.clean(cx),
Predicate::Subtype(ref pred) => pred.clean(cx),
Predicate::Trait(ref pred) => Some(pred.clean(cx)),
Predicate::Subtype(ref pred) => Some(pred.clean(cx)),
Predicate::RegionOutlives(ref pred) => pred.clean(cx),
Predicate::TypeOutlives(ref pred) => pred.clean(cx),
Predicate::Projection(ref pred) => pred.clean(cx),
Predicate::Projection(ref pred) => Some(pred.clean(cx)),

Predicate::WellFormed(..) |
Predicate::ObjectSafe(..) |
Expand All @@ -1345,24 +1348,39 @@ impl<'tcx> Clean<WherePredicate> for ty::SubtypePredicate<'tcx> {
}
}

impl<'tcx> Clean<WherePredicate> for ty::OutlivesPredicate<ty::Region<'tcx>, ty::Region<'tcx>> {
fn clean(&self, cx: &DocContext) -> WherePredicate {
impl<'tcx> Clean<Option<WherePredicate>> for
ty::OutlivesPredicate<ty::Region<'tcx>,ty::Region<'tcx>> {

fn clean(&self, cx: &DocContext) -> Option<WherePredicate> {
let ty::OutlivesPredicate(ref a, ref b) = *self;
WherePredicate::RegionPredicate {

match (a, b) {
(ty::ReEmpty, ty::ReEmpty) => {
return None;
},
_ => {}
}

Some(WherePredicate::RegionPredicate {
lifetime: a.clean(cx).expect("failed to clean lifetime"),
bounds: vec![GenericBound::Outlives(b.clean(cx).expect("failed to clean bounds"))]
}
})
}
}

impl<'tcx> Clean<WherePredicate> for ty::OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>> {
fn clean(&self, cx: &DocContext) -> WherePredicate {
impl<'tcx> Clean<Option<WherePredicate>> for ty::OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>> {
fn clean(&self, cx: &DocContext) -> Option<WherePredicate> {
let ty::OutlivesPredicate(ref ty, ref lt) = *self;

WherePredicate::BoundPredicate {
match lt {
ty::ReEmpty => return None,
_ => {}
}

Some(WherePredicate::BoundPredicate {
ty: ty.clean(cx),
bounds: vec![GenericBound::Outlives(lt.clean(cx).expect("failed to clean lifetimes"))]
}
})
}
}

Expand Down Expand Up @@ -1579,7 +1597,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
}).collect::<Vec<GenericParamDef>>();

let mut where_predicates = preds.predicates.iter()
.map(|(p, _)| p.clean(cx))
.flat_map(|(p, _)| p.clean(cx))
.collect::<Vec<_>>();

// Type parameters and have a Sized bound by default unless removed with
Expand Down