Closed
Description
Given the following code: Playground
fn main() {
let _ = 1 as (i32) < 2;
}
The current output is:
warning: unnecessary parentheses around type
--> src/main.rs:2:18
|
2 | let _ = 1 as (i32) < 2;
| ^ ^
|
= note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
|
2 - let _ = 1 as (i32) < 2;
2 + let _ = 1 as i32 < 2;
|
But with the suggestion applied the compiler displays an error with a different suggestion:
error: `<` is interpreted as a start of generic arguments for `i32`, not a comparison
--> src/main.rs:2:22
|
2 | let _ = 1 as i32 < 2;
| ^ -- interpreted as generic arguments
| |
| not interpreted as comparison
|
help: try comparing the cast value
|
2 | let _ = (1 as i32) < 2;
|
Ideally the compiler should not output a warning and treat x as (T) < y
and (x as T) < y
as identical.
@rustbot label D-incorrect A-suggestion-diagnostics