1
Fork 0

Auto merge of #52990 - Aaron1011:fix/rustdoc-auto-trait-static, r=eddyb

Fix ICE when rustdoc encounters certain usages of HRTBs

Fixes #51236

Under certain circumstances, `AutoTraitFinder` could end up computing a `ParamEnv` involving two trait predicates that differed only in the region parameters involved. One of these parameters would be a HRTB, while the other would be a normal region parameter.

When this `ParamEnv` was later passed to `SelectionContext`, an `Ambiguity` error would occur, since the erased versions of these predicates would be identical. To solve the issue, we de-duplicate our list of predicates as we build it up. Whenever we encounter two predicates that differ only in their assignment of region parameters (a HRTB vs a normal lifetime parameter), we pick the HRTB. This corresponds to selecting a 'stricter' bound to display in the generated documentation: we're requiring that a particular type works for all possible lifetime parameters if it's going to implement a particular auto trait.
This commit is contained in:
bors 2018-08-06 14:07:22 +00:00
commit 4b8089daf8
4 changed files with 136 additions and 5 deletions

View file

@ -418,8 +418,8 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
name: name.to_string(),
kind: GenericParamDefKind::Lifetime,
})
}
&ty::ReVar(_) | &ty::ReEarlyBound(_) => None,
},
&ty::ReVar(_) | &ty::ReEarlyBound(_) | &ty::ReStatic => None,
_ => panic!("Unexpected region type {:?}", r),
}
})