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
mod button {pubenumButton{}}mod button2 {pubstructButton();}use button::Button;fnmain(){useself::Button::*;let b = unimplemented!();match b {// match a different button that needs to be imported, but isn't yetButton(..) => unimplemented!(),}}
This produces the error message:
error[E0532]: expected tuple struct/variant, found enum `Button`
--> src/main.rs:16:9
|
16 | Button(..) => unimplemented!(),
| ^^^^^^ not a tuple struct/variant
|
help: possible better candidate is found in another module, you can import it into scope
|
11 | fn main() use button2::Button;
|
error: aborting due to previous error
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
Notice that the suggested fix is:
11 | fn main() use button2::Button;
This is incorrect syntax.
More Details
If you remove the use self::Button::* line, the error is normal again:
error[E0532]: expected tuple struct/variant, found enum `Button`
--> src/main.rs:15:9
|
15 | Button(..) => unimplemented!(),
| ^^^^^^ not a tuple struct/variant
|
help: possible better candidate is found in another module, you can import it into scope
|
1 | use button2::Button;
|
error: aborting due to previous error
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
In fact, this only occurs if you have both a struct and an enum with the same name.
Minimal reproduction: (Playground)
This produces the error message:
Notice that the suggested fix is:
This is incorrect syntax.
More Details
If you remove the
use self::Button::*
line, the error is normal again:In fact, this only occurs if you have both a struct and an enum with the same name.
Meta
The text was updated successfully, but these errors were encountered: