Unnamed repository; edit this file 'description' to name the repository.
Fix a failing test
The reason this test passed previously is not because it was working as intended, but because prior to the previous commit we did not resolve the `use` at all! Now, `use self as _` is invalid code anyway (it prints E0429), and because we fallback to the value namespace if we can't resolve in the type namespace (which is a reasonable behavior), this test now actually fails. I don't think we want to change the fallback, so I removed `use self as _` and instead added a new test, where the value can be resolved in the type namespace.
Chayim Refael Friedman 2025-02-05
parent 134b6f2 · commit bffc169
-rw-r--r--crates/ide/src/rename.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/crates/ide/src/rename.rs b/crates/ide/src/rename.rs
index 3d7ff5f76a..3e8295e3f0 100644
--- a/crates/ide/src/rename.rs
+++ b/crates/ide/src/rename.rs
@@ -2001,13 +2001,11 @@ impl Foo {
"foo",
r#"
fn f($0self) -> i32 {
- use self as _;
self.i
}
"#,
r#"
fn f(foo: _) -> i32 {
- use self as _;
foo.i
}
"#,
@@ -2015,6 +2013,26 @@ fn f(foo: _) -> i32 {
}
#[test]
+ fn no_type_value_ns_confuse() {
+ // Test that we don't rename items from different namespaces.
+ check(
+ "bar",
+ r#"
+struct foo {}
+fn f(foo$0: i32) -> i32 {
+ use foo as _;
+}
+"#,
+ r#"
+struct foo {}
+fn f(bar: i32) -> i32 {
+ use foo as _;
+}
+"#,
+ );
+ }
+
+ #[test]
fn test_self_in_path_to_parameter() {
check(
"foo",