Skip to content

Commit f88a33c

Browse files
authored
Rollup merge of rust-lang#123375 - fmease:rustdoc-sati-re-hotfix, r=GuillaumeGomez
rustdoc: synthetic auto trait impls: accept unresolved region vars for now rust-lang#123348 (comment): > Right, [in rust-lang#123340] I've intentionally changed a `vid_map.get(vid).unwrap_or(r)` to a `vid_map[vid]` making rustdoc panic if `rustc::AutoTraitFinder` returns a region inference variable that cannot be resolved because that is really fishy. I can change it back with a `FIXME: investigate` […]. [O]nce I [fully] understand [the arcane] `rustc::AutoTraitFinder` [I] can fix the underlying issue if there's one. > > `rustc::AutoTraitFinder` can also return placeholder regions `RePlaceholder` which doesn't seem right either and which makes rustdoc ICE, too (we have a GitHub issue for that already[, namely rust-lang#120606]). Fixes rust-lang#123370. Fixes rust-lang#112242. r? `@GuillaumeGomez`
2 parents d563729 + 70b4ace commit f88a33c

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

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)