Fix a bug where enum variants were not considered properly in type ns resolution

They should be considered just as well as in value ns, for example for struct literals.
This commit is contained in:
Chayim Refael Friedman 2025-01-19 06:31:23 +02:00
parent 248bd511ae
commit 044c831f7f
3 changed files with 81 additions and 29 deletions

View file

@ -600,6 +600,25 @@ pub mod __private {
//- /bar.rs crate:bar deps:foo edition:2018
fn bar() {
_ = foo::__private::Result::<(), ()>::Ok;
}
"#,
);
}
#[test]
fn enum_variant_type_ns() {
check_diagnostics(
r#"
enum KvnDeserializerErr<I> {
UnexpectedKeyword { found: I, expected: I },
}
fn foo() {
let _x: KvnDeserializerErr<()> =
KvnDeserializerErr::<()>::UnexpectedKeyword { found: (), expected: () };
let _x: KvnDeserializerErr<()> =
KvnDeserializerErr::<()>::UnexpectedKeyword::<()> { found: (), expected: () };
// ^^^^^^ 💡 error: you can specify generic arguments on either the enum or the variant, but not both
}
"#,
);