Skip to content

Commit

Permalink
Fix a failing test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ChayimFriedman2 committed Feb 4, 2025
1 parent 5467091 commit 9d81503
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/tools/rust-analyzer/crates/ide/src/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2001,19 +2001,37 @@ impl Foo {
"foo",
r#"
fn f($0self) -> i32 {
use self as _;
self.i
}
"#,
r#"
fn f(foo: _) -> i32 {
use self as _;
foo.i
}
"#,
);
}

#[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(
Expand Down

0 comments on commit 9d81503

Please sign in to comment.