mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
Merge #9710
9710: fix: Don't qualify self as crate in add_missing_impl_members assist r=Veykril a=Veykril Fixes #7499 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
6a2a0b7abb
@ -812,4 +812,39 @@ impl Foo for () {
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_requalify_self_as_crate() {
|
||||
check_assist(
|
||||
add_missing_default_members,
|
||||
r"
|
||||
struct Wrapper<T>(T);
|
||||
|
||||
trait T {
|
||||
fn f(self) -> Wrapper<Self> {
|
||||
Wrapper(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl T for () {
|
||||
$0
|
||||
}
|
||||
",
|
||||
r"
|
||||
struct Wrapper<T>(T);
|
||||
|
||||
trait T {
|
||||
fn f(self) -> Wrapper<Self> {
|
||||
Wrapper(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl T for () {
|
||||
$0fn f(self) -> Wrapper<Self> {
|
||||
Wrapper(self)
|
||||
}
|
||||
}
|
||||
",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -101,8 +101,11 @@ impl<'a> Ctx<'a> {
|
||||
if path.qualifier().is_some() {
|
||||
return None;
|
||||
}
|
||||
if path.segment().and_then(|s| s.param_list()).is_some() {
|
||||
if path.segment().map_or(false, |s| {
|
||||
s.param_list().is_some() || (s.self_token().is_some() && path.parent_path().is_none())
|
||||
}) {
|
||||
// don't try to qualify `Fn(Foo) -> Bar` paths, they are in prelude anyway
|
||||
// don't try to qualify sole `self` either, they are usually locals, but are returned as modules due to namespace classing
|
||||
return None;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user