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.
This commit is contained in:
Chayim Refael Friedman 2025-02-04 19:10:04 +02:00
parent 134b6f2228
commit bffc169925

View File

@ -2001,19 +2001,37 @@ impl Foo {
"foo", "foo",
r#" r#"
fn f($0self) -> i32 { fn f($0self) -> i32 {
use self as _;
self.i self.i
} }
"#, "#,
r#" r#"
fn f(foo: _) -> i32 { fn f(foo: _) -> i32 {
use self as _;
foo.i 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] #[test]
fn test_self_in_path_to_parameter() { fn test_self_in_path_to_parameter() {
check( check(