New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: implemeted lifetime transformation fot assits #14875
fix: implemeted lifetime transformation fot assits #14875
Conversation
crates/ide-db/src/path_transform.rs
Outdated
.into_iter() | ||
.flat_map(|it| it.lifetime_params(db)) | ||
.zip(self.substs.lifetimes.clone()) | ||
.filter_map(|(k, v)| Some((k.name(db).to_string(), v.lifetime()?))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: lifetime resolver is already written, could I reuse it somehow?
upd: I believe I shouldn't.
basically this resolver traverses through a ast::Lifetime
's ancestors looking for one with the same name, then converts the found ast::LifetimeParam
to hir::LifetimeParam
. in our case, there's no need neither in conversion nor in the search, as all the lifetimes to be changed are generic params of a known ancestor, the source trait.
(but I don't really understand why SemanticsScope
can't resolve a lifetime)
crates/hir/src/lib.rs
Outdated
self.lifetime_params(db).into_iter().chain(ty_params).collect() | ||
} | ||
|
||
pub fn lifetime_params(self, db: &dyn HirDatabase) -> Vec<GenericParam> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn lifetime_params(self, db: &dyn HirDatabase) -> Vec<GenericParam> { | |
pub fn lifetime_params(self, db: &dyn HirDatabase) -> Vec<LifetimeParam> { |
crates/ide-db/src/path_transform.rs
Outdated
@@ -9,6 +9,14 @@ use syntax::{ | |||
ted, SyntaxNode, | |||
}; | |||
|
|||
#[derive(Default)] | |||
struct Substs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, let's rename this to AstSubsts
as we might have Substs
in the hir layer in the future
… assists transform lifetimes
ba6e7ce
to
7f45ccc
Compare
Thanks! |
☀️ Test successful - checks-actions |
A part of #13363
I expect to implement transformation of const params in a separate PR
Other assists and a completion affected:
generate_function
currently just ignores lifetimes and, consequently, is not affectedinline_call
andreplace_derive_with...
don't seem to need lifetime transformationtrait_impl
(a completion) is fixed and tested