Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #22706 from j-ricardo-goncalves/master
fix: correct resolution to value when it shares the same name with type
Chayim Refael Friedman 11 days ago
parent aa24b5a · parent 0762412 · commit 3033d4f
-rw-r--r--crates/hir/src/source_analyzer.rs2
-rw-r--r--crates/ide/src/goto_definition.rs15
2 files changed, 16 insertions, 1 deletions
diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs
index 687f130af4..2ac3bc8f74 100644
--- a/crates/hir/src/source_analyzer.rs
+++ b/crates/hir/src/source_analyzer.rs
@@ -1155,7 +1155,7 @@ impl<'db> SourceAnalyzer<'db> {
let parent = path.syntax().parent();
let parent = || parent.clone();
- let mut prefer_value_ns = false;
+ let mut prefer_value_ns = parent().and_then(ast::PathExpr::cast).is_some();
let resolved = (|| {
let infer = self.infer()?;
if let Some(path_expr) = parent().and_then(ast::PathExpr::cast) {
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs
index 48eb0c43cd..032a431586 100644
--- a/crates/ide/src/goto_definition.rs
+++ b/crates/ide/src/goto_definition.rs
@@ -999,6 +999,21 @@ impl Trait for T {
}"#,
);
}
+
+ #[test]
+ fn goto_def_array_length_prefers_value_namespace() {
+ check(
+ r#"
+struct N;
+
+trait Trait {}
+
+impl<const N: usize> Trait for [N; N$0] {}
+ //^
+"#,
+ );
+ }
+
#[test]
fn goto_def_in_mac_call_in_attr_invoc() {
check(