mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-14 09:46:00 +00:00
fix: resolve item in match bind
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
This commit is contained in:
parent
13ffda70eb
commit
07a1b4e69f
2 changed files with 74 additions and 1 deletions
|
|
@ -765,7 +765,8 @@ impl<'db> SourceAnalyzer<'db> {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let res = resolve_hir_path(db, &self.resolver, path, HygieneId::ROOT, Some(store))?;
|
let body_owner = self.resolver.body_owner();
|
||||||
|
let res = resolve_hir_value_path(db, &self.resolver, body_owner, path, HygieneId::ROOT)?;
|
||||||
match res {
|
match res {
|
||||||
PathResolution::Def(def) => Some(def),
|
PathResolution::Def(def) => Some(def),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
||||||
|
|
@ -3848,6 +3848,78 @@ fn main() {
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn goto_const_from_match_pat_with_tuple_struct() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
struct Tag(u8);
|
||||||
|
struct Path {}
|
||||||
|
|
||||||
|
const Path: u8 = 0;
|
||||||
|
// ^^^^
|
||||||
|
fn main() {
|
||||||
|
match Tag(Path) {
|
||||||
|
Tag(Path$0) => {}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn goto_const_from_match_pat() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
type T1 = u8;
|
||||||
|
const T1: u8 = 0;
|
||||||
|
// ^^
|
||||||
|
fn main() {
|
||||||
|
let x = 0;
|
||||||
|
match x {
|
||||||
|
T1$0 => {}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn goto_struct_from_match_pat() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
struct T1;
|
||||||
|
// ^^
|
||||||
|
fn main() {
|
||||||
|
let x = 0;
|
||||||
|
match x {
|
||||||
|
T1$0 => {}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn no_goto_trait_from_match_pat() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
trait T1 {}
|
||||||
|
fn main() {
|
||||||
|
let x = 0;
|
||||||
|
match x {
|
||||||
|
T1$0 => {}
|
||||||
|
// ^^
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue