-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Change rename self to parameter use Self
type
#20285
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
Conversation
And add `&self` lifetime support Example === Rename to `this` ```rust struct Foo<T>(T); impl Foo<i32> { fn foo(&'static self$0) {} } ``` Old: ```rust struct Foo<T>(T); impl Foo<i32> { fn foo(this: &Foo) {} } ``` Fixes: ```rust struct Foo<T>(T); impl Foo<i32> { fn foo(this: &'static Self) {} } ```
75dd853
to
4b32a49
Compare
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.
Seems reasonable to me, just one request.
crates/ide/src/rename.rs
Outdated
replacement_text.push_str(": _"); | ||
Some(TextEdit::replace(self_param.syntax().text_range(), replacement_text)) | ||
} | ||
if self_param.syntax().ancestors().find_map(ast::Impl::cast).is_some() { |
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.
This should also include ast::Trait
(although this wasn't in the original code). Also this check will be incorrect in case of a nested function inside impl, but I guess it's fine.
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.
What does "include ast::Trait
" mean?
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.
I meant methods in traits should also use Self
, but I see you changed it to always use Self
, that's also good.
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.
Thanks!
And add
&self
lifetime supportFixes #17366
Example
Old:
Fixes: