mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
fix lifetime bound var index in dyn trait
This commit is contained in:
parent
1a5bb27c01
commit
8cbeb04ba2
2 changed files with 25 additions and 5 deletions
|
@ -1311,11 +1311,10 @@ impl<'a> TyLoweringContext<'a> {
|
|||
bounds,
|
||||
lifetime: match lifetime {
|
||||
Some(it) => match it.bound_var(Interner) {
|
||||
Some(bound_var) => LifetimeData::BoundVar(BoundVar::new(
|
||||
DebruijnIndex::INNERMOST,
|
||||
bound_var.index,
|
||||
))
|
||||
.intern(Interner),
|
||||
Some(bound_var) => bound_var
|
||||
.shifted_out_to(DebruijnIndex::new(2))
|
||||
.map(|bound_var| LifetimeData::BoundVar(bound_var).intern(Interner))
|
||||
.unwrap_or(it),
|
||||
None => it,
|
||||
},
|
||||
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…
Add table
Add a link
Reference in a new issue