mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Auto merge of #16727 - Veykril:assoc-related, r=Veykril
fix: Don't highlight related assoc items of super traits
This commit is contained in:
commit
79e0fee6a3
1 changed files with 53 additions and 5 deletions
|
@ -166,7 +166,7 @@ fn highlight_references(
|
|||
match parent {
|
||||
ast::UseTree(it) => it.syntax().ancestors().find(|it| {
|
||||
ast::SourceFile::can_cast(it.kind()) || ast::Module::can_cast(it.kind())
|
||||
}),
|
||||
}).zip(Some(true)),
|
||||
ast::PathType(it) => it
|
||||
.syntax()
|
||||
.ancestors()
|
||||
|
@ -178,14 +178,14 @@ fn highlight_references(
|
|||
.ancestors()
|
||||
.find(|it| {
|
||||
ast::Item::can_cast(it.kind())
|
||||
}),
|
||||
}).zip(Some(false)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
})();
|
||||
if let Some(trait_item_use_scope) = trait_item_use_scope {
|
||||
if let Some((trait_item_use_scope, use_tree)) = trait_item_use_scope {
|
||||
res.extend(
|
||||
t.items_with_supertraits(sema.db)
|
||||
if use_tree { t.items(sema.db) } else { t.items_with_supertraits(sema.db) }
|
||||
.into_iter()
|
||||
.filter_map(|item| {
|
||||
Definition::from(item)
|
||||
|
@ -1598,7 +1598,10 @@ fn f() {
|
|||
fn test_trait_highlights_assoc_item_uses() {
|
||||
check(
|
||||
r#"
|
||||
trait Foo {
|
||||
trait Super {
|
||||
type SuperT;
|
||||
}
|
||||
trait Foo: Super {
|
||||
//^^^
|
||||
type T;
|
||||
const C: usize;
|
||||
|
@ -1614,6 +1617,8 @@ impl Foo for i32 {
|
|||
}
|
||||
fn f<T: Foo$0>(t: T) {
|
||||
//^^^
|
||||
let _: T::SuperT;
|
||||
//^^^^^^
|
||||
let _: T::T;
|
||||
//^
|
||||
t.m();
|
||||
|
@ -1635,6 +1640,49 @@ fn f2<T: Foo>(t: T) {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_trait_highlights_assoc_item_uses_use_tree() {
|
||||
check(
|
||||
r#"
|
||||
use Foo$0;
|
||||
// ^^^ import
|
||||
trait Super {
|
||||
type SuperT;
|
||||
}
|
||||
trait Foo: Super {
|
||||
//^^^
|
||||
type T;
|
||||
const C: usize;
|
||||
fn f() {}
|
||||
fn m(&self) {}
|
||||
}
|
||||
impl Foo for i32 {
|
||||
//^^^
|
||||
type T = i32;
|
||||
// ^
|
||||
const C: usize = 0;
|
||||
// ^
|
||||
fn f() {}
|
||||
// ^
|
||||
fn m(&self) {}
|
||||
// ^
|
||||
}
|
||||
fn f<T: Foo>(t: T) {
|
||||
//^^^
|
||||
let _: T::SuperT;
|
||||
let _: T::T;
|
||||
//^
|
||||
t.m();
|
||||
//^
|
||||
T::C;
|
||||
//^
|
||||
T::f();
|
||||
//^
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn implicit_format_args() {
|
||||
check(
|
||||
|
|
Loading…
Reference in a new issue