Closed
Description
Code
mod module {
#[derive(Eq, PartialEq)]
pub struct Type {
pub x: u8,
pub y: u8,
}
pub const C: u8 = 32u8;
}
fn test(x: module::Type) -> i32 {
if x == module::Type { x: module::C, y: 1 } {
1
} else {
0
}
}
Current output
error: invalid struct literal
--> <source>:12:21
|
12 | if x == module::Type { x: module::C, y: 1 } {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: you might need to surround the struct literal in parentheses
|
12 | if x == module::(Type { x: module::C, y: 1 }) {
| + +
Desired output
error: invalid struct literal
--> <source>:12:21
|
12 | if x == module::Type { x: module::C, y: 1 } {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: you might need to surround the struct literal in parentheses
|
12 | if x == (module::Type { x: module::C, y: 1 }) {
| + +
Rationale and extra context
No response
Other cases
No response
Anything else?
This defect is reproducible with (at least) 1.68, 1.69, beta, and nightly.
Furthermore, I think it would be good to reword the message to suggest surrounding with parentheses.