mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-01 07:48:45 +00:00
Auto merge of #12901 - Veykril:completion-trait-expr, r=Veykril
fix: Don't complete marker traits in expression position cc https://github.com/rust-lang/rust-analyzer/issues/12196
This commit is contained in:
commit
32e640e2ba
4 changed files with 14 additions and 9 deletions
|
@ -202,10 +202,21 @@ pub(crate) fn complete_expr_path(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.process_all_names(&mut |name, def| {
|
ctx.process_all_names(&mut |name, def| match def {
|
||||||
if scope_def_applicable(def) {
|
ScopeDef::ModuleDef(hir::ModuleDef::Trait(t)) => {
|
||||||
acc.add_path_resolution(ctx, path_ctx, name, def);
|
let assocs = t.items_with_supertraits(ctx.db);
|
||||||
|
match &*assocs {
|
||||||
|
// traits with no assoc items are unusable as expressions since
|
||||||
|
// there is no associated item path that can be constructed with them
|
||||||
|
[] => (),
|
||||||
|
// FIXME: Render the assoc item with the trait qualified
|
||||||
|
&[_item] => acc.add_path_resolution(ctx, path_ctx, name, def),
|
||||||
|
// FIXME: Append `::` to the thing here, since a trait on its own won't work
|
||||||
|
[..] => acc.add_path_resolution(ctx, path_ctx, name, def),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_ if scope_def_applicable(def) => acc.add_path_resolution(ctx, path_ctx, name, def),
|
||||||
|
_ => (),
|
||||||
});
|
});
|
||||||
|
|
||||||
if is_func_update.is_none() {
|
if is_func_update.is_none() {
|
||||||
|
|
|
@ -1347,7 +1347,6 @@ fn main() {
|
||||||
fn main() []
|
fn main() []
|
||||||
fn foo(…) []
|
fn foo(…) []
|
||||||
md core []
|
md core []
|
||||||
tt Sized []
|
|
||||||
"#]],
|
"#]],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1394,7 +1393,6 @@ fn main() {
|
||||||
fn main() []
|
fn main() []
|
||||||
fn foo(…) []
|
fn foo(…) []
|
||||||
md core []
|
md core []
|
||||||
tt Sized []
|
|
||||||
"#]],
|
"#]],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1492,7 +1490,6 @@ fn main() {
|
||||||
fn &bar() [type]
|
fn &bar() [type]
|
||||||
fn foo(…) []
|
fn foo(…) []
|
||||||
md core []
|
md core []
|
||||||
tt Sized []
|
|
||||||
"#]],
|
"#]],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@ fn baz() {
|
||||||
st Record
|
st Record
|
||||||
st Tuple
|
st Tuple
|
||||||
st Unit
|
st Unit
|
||||||
tt Trait
|
|
||||||
un Union
|
un Union
|
||||||
ev TupleV(…) TupleV(u32)
|
ev TupleV(…) TupleV(u32)
|
||||||
bt u32
|
bt u32
|
||||||
|
@ -137,7 +136,6 @@ impl Unit {
|
||||||
st Record
|
st Record
|
||||||
st Tuple
|
st Tuple
|
||||||
st Unit
|
st Unit
|
||||||
tt Trait
|
|
||||||
tp TypeParam
|
tp TypeParam
|
||||||
un Union
|
un Union
|
||||||
ev TupleV(…) TupleV(u32)
|
ev TupleV(…) TupleV(u32)
|
||||||
|
|
|
@ -167,7 +167,6 @@ fn main() {
|
||||||
st Foo
|
st Foo
|
||||||
st Foo {…} Foo { foo1: u32, foo2: u32 }
|
st Foo {…} Foo { foo1: u32, foo2: u32 }
|
||||||
tt Default
|
tt Default
|
||||||
tt Sized
|
|
||||||
bt u32
|
bt u32
|
||||||
kw crate::
|
kw crate::
|
||||||
kw self::
|
kw self::
|
||||||
|
|
Loading…
Reference in a new issue