Closed
Description
Minimal reproduction: (Playground)
mod button {
pub enum Button {}
}
mod button2 {
pub struct Button();
}
use button::Button;
fn main() {
use self::Button::*;
let b = unimplemented!();
match b {
// match a different button that needs to be imported, but isn't yet
Button(..) => 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.
Meta
$ rustc --version --verbose
rustc 1.20.0 (f3d6973f4 2017-08-27)
binary: rustc
commit-hash: f3d6973f41a7d1fb83029c9c0ceaf0f5d4fd7208
commit-date: 2017-08-27
host: x86_64-unknown-linux-gnu
release: 1.20.0
LLVM version: 4.0