-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Improve automatic name selection for "Extract into variable" on from()
calls
#17631
Comments
@rustbot claim |
@kpreid How do you think it would be better to handle this situation? use std::slice::Iter;
struct Foo;
impl From<Foo> for fn(&Iter<'_, i32>) -> *mut i32 {
fn from(_: Foo) -> Self {
todo!()
}
} |
@Lampese I guess what he wants is that if Self is a path type, the variable name is the type name, otherwise fall back to |
Yes. Things like this can never be perfect; they can only handle common cases better. Speaking of common cases, here's another one not using the struct Foo {}
struct Bar {}
impl Bar {
pub fn from_foo(_: Foo) -> Self {
Self {}
}
}
fn do_something(_: Bar) {}
fn main() {
let foo = Foo {};
do_something(Bar::from_foo(foo));
// ^^^^^^^^^^^^^^^^^^ select this and extract into variable
} This generates the variable name |
|
The result of extraction is:
A better result would be:
.into()
calls also currently produce variables namedinto
, but that might be more trouble to fix; I don't know.rust-analyzer version: 0.3.2037-standalone (e9afba5 2024-07-14)
The text was updated successfully, but these errors were encountered: