Skip to content

Commit 9d81503

Browse files
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.
1 parent 5467091 commit 9d81503

File tree

1 file changed

+20
-2
lines changed
  • src/tools/rust-analyzer/crates/ide/src

1 file changed

+20
-2
lines changed

src/tools/rust-analyzer/crates/ide/src/rename.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,19 +2001,37 @@ impl Foo {
20012001
"foo",
20022002
r#"
20032003
fn f($0self) -> i32 {
2004-
use self as _;
20052004
self.i
20062005
}
20072006
"#,
20082007
r#"
20092008
fn f(foo: _) -> i32 {
2010-
use self as _;
20112009
foo.i
20122010
}
20132011
"#,
20142012
);
20152013
}
20162014

2015+
#[test]
2016+
fn no_type_value_ns_confuse() {
2017+
// Test that we don't rename items from different namespaces.
2018+
check(
2019+
"bar",
2020+
r#"
2021+
struct foo {}
2022+
fn f(foo$0: i32) -> i32 {
2023+
use foo as _;
2024+
}
2025+
"#,
2026+
r#"
2027+
struct foo {}
2028+
fn f(bar: i32) -> i32 {
2029+
use foo as _;
2030+
}
2031+
"#,
2032+
);
2033+
}
2034+
20172035
#[test]
20182036
fn test_self_in_path_to_parameter() {
20192037
check(

0 commit comments

Comments
 (0)