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
steffahn opened this issue
Jan 3, 2021
· 3 comments
· Fixed by #115424
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-parserArea: The parsing of Rust source code to an ASTC-bugCategory: This is a bug.
Compiling playground v0.0.1 (/playground)
warning: unnecessary parentheses around type
--> src/lib.rs:3:13
|
3 | if x as (i32) < 0 {
| ^^^^^ help: remove these parentheses
|
= note: `#[warn(unused_parens)]` on by default
warning: 1 warning emitted
Finished dev [unoptimized + debuginfo] target(s) in 2.64s
Following this warning’s help: remove these parentheses results in
pubfnfoo(){let x:u32 = 100;if x asi32 < 0{// ...}}
Compiling playground v0.0.1 (/playground)
error: `<` is interpreted as a start of generic arguments for `i32`, not a comparison
--> src/lib.rs:3:17
|
3 | if x as i32 < 0 {
| -------- ^ --- interpreted as generic arguments
| | |
| | not interpreted as comparison
| help: try comparing the cast value: `(x as i32)`
error: aborting due to previous error
error: could not compile `playground`
To learn more, run the command again with --verbose.
Similarly, cargo fix results in
Checking playground v0.1.0 (/home/frank/playground)
warning: failed to automatically apply fixes suggested by rustc to crate `playground`
after fixes were automatically applied the compiler reported errors within these files:
* src/lib.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error: `<` is interpreted as a start of generic arguments for `i32`, not a comparison
--> src/lib.rs:3:17
|
3 | if x as i32 < 0 {
| -------- ^ --- interpreted as generic arguments
| | |
| | not interpreted as comparison
| help: try comparing the cast value: `(x as i32)`
error: aborting due to previous error
Original diagnostics will follow.
warning: unnecessary parentheses around type
--> src/lib.rs:3:13
|
3 | if x as (i32) < 0 {
| ^^^^^ help: remove these parentheses
|
= note: `#[warn(unused_parens)]` on by default
warning: unnecessary parentheses around type
--> src/lib.rs:3:13
|
3 | if x as (i32) < 0 {
| ^^^^^ help: remove these parentheses
|
= note: `#[warn(unused_parens)]` on by default
warning: 1 warning emitted
warning: 1 warning emitted
Finished dev [unoptimized + debuginfo] target(s) in 0.62s
(for some reason the warning is duplicated in the cargo fix output...)
The text was updated successfully, but these errors were encountered:
jyn514
added
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-bug
Category: This is a bug.
labels
Jan 3, 2021
I think this requires adding a special case for _ as (_) <binary op> _ where <binary op> is << or <. In this case we don't want to generate the warning as removing the parens around the type breaks the code.
In all cases I think the warning can work as before.
I'm not sure how to implement this special case though..
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-parserArea: The parsing of Rust source code to an ASTC-bugCategory: This is a bug.
(Playground)
Warnings:
Following this warning’s
help: remove these parentheses
results inSimilarly,
cargo fix
results in(for some reason the warning is duplicated in the
cargo fix
output...)The text was updated successfully, but these errors were encountered: