Auto merge of #17190 - dfireBird:dyn_trait_with_lifetimes_in_rpit, r=Veykril
Fix: Lifetime's Bound Var Debrujin Index in Dyn Traits Surely fixes #17182 I have tried running the analysis-stats in some of the repos mentioned in #17080. No panic in almost all of them.
This commit is contained in:
commit
c50b357efe
@ -1311,11 +1311,10 @@ impl<'a> TyLoweringContext<'a> {
|
|||||||
bounds,
|
bounds,
|
||||||
lifetime: match lifetime {
|
lifetime: match lifetime {
|
||||||
Some(it) => match it.bound_var(Interner) {
|
Some(it) => match it.bound_var(Interner) {
|
||||||
Some(bound_var) => LifetimeData::BoundVar(BoundVar::new(
|
Some(bound_var) => bound_var
|
||||||
DebruijnIndex::INNERMOST,
|
.shifted_out_to(DebruijnIndex::new(2))
|
||||||
bound_var.index,
|
.map(|bound_var| LifetimeData::BoundVar(bound_var).intern(Interner))
|
||||||
))
|
.unwrap_or(it),
|
||||||
.intern(Interner),
|
|
||||||
None => it,
|
None => it,
|
||||||
},
|
},
|
||||||
None => static_lifetime(),
|
None => static_lifetime(),
|
||||||
|
@ -4803,3 +4803,24 @@ fn foo() {
|
|||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn dyn_trait_with_lifetime_in_rpit() {
|
||||||
|
check_types(
|
||||||
|
r#"
|
||||||
|
//- minicore: future
|
||||||
|
pub struct Box<T> {}
|
||||||
|
|
||||||
|
trait Trait {}
|
||||||
|
|
||||||
|
pub async fn foo_async<'a>() -> Box<dyn Trait + 'a> {
|
||||||
|
Box {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo() {
|
||||||
|
foo_async();
|
||||||
|
//^^^^^^^^^^^impl Future<Output = Box<dyn Trait>> + ?Sized
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user