-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggest rewriting a malformed hex literal if we expect a float
- Loading branch information
1 parent
b38a6d3
commit 3cf22de
Showing
3 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
fn main() { | ||
let _f: f32 = 0xAAf32; | ||
//~^ ERROR mismatched types | ||
//~| HELP rewrite this | ||
|
||
let _f: f32 = 0xAB_f32; | ||
//~^ ERROR mismatched types | ||
//~| HELP rewrite this | ||
|
||
let _f: f64 = 0xFF_f64; | ||
//~^ ERROR mismatched types | ||
//~| HELP rewrite this | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/bad-hex-float-lit.rs:2:19 | ||
| | ||
LL | let _f: f32 = 0xAAf32; | ||
| --- ^^^^^^^ expected `f32`, found integer | ||
| | | ||
| expected due to this | ||
| | ||
help: rewrite this as a decimal floating point literal, or use `as` to turn a hex literal into a float | ||
| | ||
LL | let _f: f32 = 0xAA as f32; | ||
| ~~~~~~~~~~~ | ||
LL | let _f: f32 = 170_f32; | ||
| ~~~~~~~ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/bad-hex-float-lit.rs:6:19 | ||
| | ||
LL | let _f: f32 = 0xAB_f32; | ||
| --- ^^^^^^^^ expected `f32`, found integer | ||
| | | ||
| expected due to this | ||
| | ||
help: rewrite this as a decimal floating point literal, or use `as` to turn a hex literal into a float | ||
| | ||
LL | let _f: f32 = 0xAB as f32; | ||
| ~~~~~~~~~~~ | ||
LL | let _f: f32 = 171_f32; | ||
| ~~~~~~~ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/bad-hex-float-lit.rs:10:19 | ||
| | ||
LL | let _f: f64 = 0xFF_f64; | ||
| --- ^^^^^^^^ expected `f64`, found integer | ||
| | | ||
| expected due to this | ||
| | ||
help: rewrite this as a decimal floating point literal, or use `as` to turn a hex literal into a float | ||
| | ||
LL | let _f: f64 = 0xFF as f64; | ||
| ~~~~~~~~~~~ | ||
LL | let _f: f64 = 255_f64; | ||
| ~~~~~~~ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |