-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix into() cast paren check precedence
As discussed in #47699 the logic for determining if an expression needs parenthesis when suggesting an `.into()` cast is incorrect. Two broken examples from nightly are: ``` error[E0308]: mismatched types --> main.rs:4:10 | 4 | test(foo as i8); | ^^^^^^^^^ expected i32, found i8 help: you can cast an `i8` to `i32`, which will sign-extend the source value | 4 | test(foo as i8.into()); | ``` ``` error[E0308]: mismatched types --> main.rs:4:10 | 4 | test(*foo); | ^^^^ expected i32, found i8 help: you can cast an `i8` to `i32`, which will sign-extend the source value | 4 | test(*foo.into()); | ``` As suggested by @petrochenkov switch the precedence check to PREC_POSTFIX. This catches both `as` and unary operators. Fixes #47699.
- Loading branch information
Showing
3 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters