Prioritize variants as inherent associated items during name resolution

This commit is contained in:
Vadim Petrochenkov 2019-01-10 23:23:30 +03:00
parent ceb2512144
commit 01d0ae9618
11 changed files with 227 additions and 105 deletions

View file

@ -0,0 +1,13 @@
#![feature(type_alias_enum_variants)]
enum E {
V(u8)
}
impl E {
fn V() {}
}
fn main() {
<E>::V(); //~ ERROR this function takes 1 parameter but 0 parameters were supplied
}

View file

@ -0,0 +1,12 @@
error[E0061]: this function takes 1 parameter but 0 parameters were supplied
--> $DIR/type-alias-enum-variants-priority-2.rs:12:5
|
LL | V(u8)
| ----- defined here
...
LL | <E>::V(); //~ ERROR this function takes 1 parameter but 0 parameters were supplied
| ^^^^^^^^ expected 1 parameter
error: aborting due to previous error
For more information about this error, try `rustc --explain E0061`.

View file

@ -0,0 +1,10 @@
#![feature(type_alias_enum_variants)]
enum E {
V
}
fn check() -> <E>::V {}
//~^ ERROR expected type, found variant `V`
fn main() {}

View file

@ -0,0 +1,8 @@
error: expected type, found variant `V`
--> $DIR/type-alias-enum-variants-priority-3.rs:7:15
|
LL | fn check() -> <E>::V {}
| ^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,20 @@
#![feature(type_alias_enum_variants)]
#![deny(ambiguous_associated_items)]
enum E {
V
}
trait Tr {
type V;
fn f() -> Self::V;
}
impl Tr for E {
type V = u8;
fn f() -> Self::V { 0 }
//~^ ERROR ambiguous associated item
//~| WARN this was previously accepted
}
fn main() {}

View file

@ -0,0 +1,26 @@
error: ambiguous associated item
--> $DIR/type-alias-enum-variants-priority.rs:15:15
|
LL | fn f() -> Self::V { 0 }
| ^^^^^^^ help: use fully-qualified syntax: `<E as Trait>::V`
|
note: lint level defined here
--> $DIR/type-alias-enum-variants-priority.rs:2:9
|
LL | #![deny(ambiguous_associated_items)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57644 <https://github.com/rust-lang/rust/issues/57644>
note: `V` could refer to variant defined here
--> $DIR/type-alias-enum-variants-priority.rs:5:5
|
LL | V
| ^
note: `V` could also refer to associated type defined here
--> $DIR/type-alias-enum-variants-priority.rs:9:5
|
LL | type V;
| ^^^^^^^
error: aborting due to previous error