mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
add test for item same name
This commit is contained in:
parent
0dbc091fee
commit
408fa148b9
1 changed files with 20 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
use std::convert::TryInto;
|
use std::{convert::TryInto, mem::discriminant};
|
||||||
|
|
||||||
use crate::{doc_links::token_as_doc_comment, FilePosition, NavigationTarget, RangeInfo, TryToNav};
|
use crate::{doc_links::token_as_doc_comment, FilePosition, NavigationTarget, RangeInfo, TryToNav};
|
||||||
use hir::{AsAssocItem, AssocItem, Semantics};
|
use hir::{AsAssocItem, AssocItem, Semantics};
|
||||||
|
@ -126,9 +126,11 @@ fn try_filter_trait_item_definition(
|
||||||
};
|
};
|
||||||
let trait_ = imp.trait_(db)?;
|
let trait_ = imp.trait_(db)?;
|
||||||
let name = def.name(db)?;
|
let name = def.name(db)?;
|
||||||
|
let discri_value = discriminant(&assoc);
|
||||||
trait_
|
trait_
|
||||||
.items(db)
|
.items(db)
|
||||||
.iter()
|
.iter()
|
||||||
|
.filter(|itm| discriminant(*itm) == discri_value)
|
||||||
.find_map(|itm| (itm.name(db)? == name).then(|| itm.try_to_nav(db)).flatten())
|
.find_map(|itm| (itm.name(db)? == name).then(|| itm.try_to_nav(db)).flatten())
|
||||||
.map(|it| vec![it])
|
.map(|it| vec![it])
|
||||||
}
|
}
|
||||||
|
@ -175,6 +177,23 @@ mod tests {
|
||||||
assert!(navs.is_empty(), "didn't expect this to resolve anywhere: {:?}", navs)
|
assert!(navs.is_empty(), "didn't expect this to resolve anywhere: {:?}", navs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn goto_def_if_items_same_name() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
trait Trait {
|
||||||
|
type A;
|
||||||
|
const A: i32;
|
||||||
|
//^
|
||||||
|
}
|
||||||
|
|
||||||
|
struct T;
|
||||||
|
impl Trait for T {
|
||||||
|
type A = i32;
|
||||||
|
const A$0: i32 = -9;
|
||||||
|
}"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn goto_def_in_mac_call_in_attr_invoc() {
|
fn goto_def_in_mac_call_in_attr_invoc() {
|
||||||
check(
|
check(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue