-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Suggest to change numeric literal instead of casting #54273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1984079
lint to change numeric literal instead of into
csmoe 0ff0669
replace old literal in expr
csmoe 17a28f7
add test for numeric literal cast
csmoe d31a2a0
trim type numeric literal suffix
csmoe 9d6c4f0
merge into/literal suggestion for DRY
csmoe 2fb6585
add test for float/integer
csmoe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
add test for float/integer
- Loading branch information
commit 2fb6585f33bf1af3b6b5143347eb534cebd257e4
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/numeric-literal-cast.rs:13:9 | ||
--> $DIR/numeric-literal-cast.rs:16:9 | ||
| | ||
LL | foo(8u8); | ||
LL | foo(1u8); | ||
| ^^^ expected u16, found u8 | ||
help: change the type of the numeric literal from `u8` to `u16` | ||
| | ||
LL | foo(8u16); | ||
LL | foo(1u16); | ||
| ^^^^ | ||
|
||
error: aborting due to previous error | ||
error[E0308]: mismatched types | ||
--> $DIR/numeric-literal-cast.rs:17:10 | ||
| | ||
LL | foo1(2f32); | ||
| ^^^^ expected f64, found f32 | ||
help: change the type of the numeric literal from `f32` to `f64` | ||
| | ||
LL | foo1(2f64); | ||
| ^^^^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/numeric-literal-cast.rs:18:10 | ||
| | ||
LL | foo2(3i16); | ||
| ^^^^ expected i32, found i16 | ||
help: change the type of the numeric literal from `i16` to `i32` | ||
| | ||
LL | foo2(3i32); | ||
| ^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test for floats too?