Skip to content

Commit 70b4ace

Browse files
committed
rustdoc: synthetic auto trait impls: accept unresolved region vars for now
1 parent 5dbaafd commit 70b4ace

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

Diff for: src/librustdoc/clean/auto_trait.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,14 @@ fn clean_param_env<'tcx>(
181181
})
182182
.map(|pred| {
183183
tcx.fold_regions(pred, |r, _| match *r {
184-
ty::ReVar(vid) => vid_to_region[&vid],
184+
// FIXME: Don't `unwrap_or`, I think we should panic if we encounter an infer var that
185+
// we can't map to a concrete region. However, `AutoTraitFinder` *does* leak those kinds
186+
// of `ReVar`s for some reason at the time of writing. See `rustdoc-ui/` tests.
187+
// This is in dire need of an investigation into `AutoTraitFinder`.
188+
ty::ReVar(vid) => vid_to_region.get(&vid).copied().unwrap_or(r),
185189
ty::ReEarlyParam(_) | ty::ReStatic | ty::ReBound(..) | ty::ReError(_) => r,
190+
// FIXME(#120606): `AutoTraitFinder` can actually leak placeholder regions which feels
191+
// incorrect. Needs investigation.
186192
ty::ReLateParam(_) | ty::RePlaceholder(_) | ty::ReErased => {
187193
bug!("unexpected region kind: {r:?}")
188194
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// We used to ICE here while trying to synthesize auto trait impls.
2+
// issue: 112242
3+
//@ check-pass
4+
//@ compile-flags: -Znormalize-docs
5+
6+
pub trait MyTrait<'a> {
7+
type MyItem;
8+
}
9+
pub struct Inner<Q>(Q);
10+
pub struct Outer<Q>(Inner<Q>);
11+
12+
impl<'a, Q> std::marker::Unpin for Inner<Q>
13+
where
14+
Q: MyTrait<'a>,
15+
<Q as MyTrait<'a>>::MyItem: Copy,
16+
{
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// We used to ICE here while trying to synthesize auto trait impls.
2+
// issue: 123370
3+
//@ check-pass
4+
5+
pub struct Inner<'a, Q>(&'a (), Q);
6+
7+
pub struct Outer<'a, Q>(Inner<'a, Q>);
8+
9+
impl<'a, Q: Trait<'a>> std::marker::Unpin for Inner<'static, Q> {}
10+
11+
pub trait Trait<'a> {}

0 commit comments

Comments
 (0)