Skip to content

Commit 07a1b4e

Browse files
committed
fix: resolve item in match bind
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
1 parent 13ffda7 commit 07a1b4e

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

crates/hir/src/source_analyzer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,8 @@ impl<'db> SourceAnalyzer<'db> {
765765
},
766766
};
767767

768-
let res = resolve_hir_path(db, &self.resolver, path, HygieneId::ROOT, Some(store))?;
768+
let body_owner = self.resolver.body_owner();
769+
let res = resolve_hir_value_path(db, &self.resolver, body_owner, path, HygieneId::ROOT)?;
769770
match res {
770771
PathResolution::Def(def) => Some(def),
771772
_ => None,

crates/ide/src/goto_definition.rs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3848,6 +3848,78 @@ fn main() {
38483848
_ => {},
38493849
}
38503850
}
3851+
"#,
3852+
);
3853+
}
3854+
3855+
#[test]
3856+
fn goto_const_from_match_pat_with_tuple_struct() {
3857+
check(
3858+
r#"
3859+
struct Tag(u8);
3860+
struct Path {}
3861+
3862+
const Path: u8 = 0;
3863+
// ^^^^
3864+
fn main() {
3865+
match Tag(Path) {
3866+
Tag(Path$0) => {}
3867+
_ => {}
3868+
}
3869+
}
3870+
3871+
"#,
3872+
);
3873+
}
3874+
3875+
#[test]
3876+
fn goto_const_from_match_pat() {
3877+
check(
3878+
r#"
3879+
type T1 = u8;
3880+
const T1: u8 = 0;
3881+
// ^^
3882+
fn main() {
3883+
let x = 0;
3884+
match x {
3885+
T1$0 => {}
3886+
_ => {}
3887+
}
3888+
}
3889+
"#,
3890+
);
3891+
}
3892+
3893+
#[test]
3894+
fn goto_struct_from_match_pat() {
3895+
check(
3896+
r#"
3897+
struct T1;
3898+
// ^^
3899+
fn main() {
3900+
let x = 0;
3901+
match x {
3902+
T1$0 => {}
3903+
_ => {}
3904+
}
3905+
}
3906+
"#,
3907+
);
3908+
}
3909+
3910+
#[test]
3911+
fn no_goto_trait_from_match_pat() {
3912+
check(
3913+
r#"
3914+
trait T1 {}
3915+
fn main() {
3916+
let x = 0;
3917+
match x {
3918+
T1$0 => {}
3919+
// ^^
3920+
_ => {}
3921+
}
3922+
}
38513923
"#,
38523924
);
38533925
}

0 commit comments

Comments
 (0)