mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Merge #9461
9461: fix: Fix incorrect guard for NameRefClass attribute resolution r=Veykril a=Veykril This is what happens when you forget to write a test bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
cd7277efac
2 changed files with 22 additions and 1 deletions
|
@ -4134,4 +4134,24 @@ pub fn foo() {}
|
||||||
"#]],
|
"#]],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn hover_attr_path_qualifier() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
//- /foo.rs crate:foo
|
||||||
|
|
||||||
|
//- /lib.rs crate:main.rs deps:foo
|
||||||
|
#[fo$0o::bar()]
|
||||||
|
struct Foo;
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
*foo*
|
||||||
|
|
||||||
|
```rust
|
||||||
|
extern crate foo
|
||||||
|
```
|
||||||
|
"#]],
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,7 +393,8 @@ impl NameRefClass {
|
||||||
Some(true) => sema.resolve_path(&path).and_then(|resolved| {
|
Some(true) => sema.resolve_path(&path).and_then(|resolved| {
|
||||||
match resolved {
|
match resolved {
|
||||||
// Don't wanna collide with builtin attributes here like `test` hence guard
|
// Don't wanna collide with builtin attributes here like `test` hence guard
|
||||||
PathResolution::Def(module @ ModuleDef::Module(_)) if path == top_path => {
|
// so only resolve to modules that aren't the last segment
|
||||||
|
PathResolution::Def(module @ ModuleDef::Module(_)) if path != top_path => {
|
||||||
Some(NameRefClass::Definition(Definition::ModuleDef(module)))
|
Some(NameRefClass::Definition(Definition::ModuleDef(module)))
|
||||||
}
|
}
|
||||||
PathResolution::Macro(mac) if mac.kind() == hir::MacroKind::Attr => {
|
PathResolution::Macro(mac) if mac.kind() == hir::MacroKind::Attr => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue