You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reword error when data-less enum variant called as function
Given a file like:
``` rust
enum Test {
Variant,
Variant2 {a: u32},
}
fn main(){
let x = Test::Variant("Hello");
let y = Test::Variant2("World");
}
```
Both errors now look similar:
``` bash
error[E0423]: `Test::Variant2` is the name of a struct or struct variant, but this expression uses it like a function name
--> file3.rs:10:13
|
10 | let y = Test::Variant2("Hello");
| ^^^^^^^^^^^^^^ struct called like a function
|
= help: did you mean to write: `Test::Variant2 { /* fields */ }`?
error: `Test::Variant` is the name of a data-less enum, but this expression uses it like a function name
--> file3.rs:9:13
|
9 | let x = Test::Variant("World");
| ^^^^^^^^^^^^^^^^^^^^^^ data-less enum called like a function
|
= help: did you mean to write: `Test::Variant`?
note: defined here
--> file3.rs:2:5
|
2 | Variant,
| ^^^^^^^
error: aborting due to previous error
```
Re: #28533
Closing, we suggest to not call it today and provide the definition site.
error: `Test::Variant` is being called, but it is not a function
--> test.rs:8:13
|
8 | let x = Test::Variant("World");
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: did you mean to write `Test::Variant`?
note: defined here
--> test.rs:2:5
|
2 | Variant,
| ^^^^^^^
error: aborting due to previous error(s)
results in
The error should say something about variant not being able to contain any data instead.
The text was updated successfully, but these errors were encountered: