diff options
| author | Michael Goulet <michael@errs.io> | 2022-12-17 23:20:16 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-12-27 17:14:45 +0000 |
| commit | 3cf22de90fcc23100bbecae3925896409d36aaa9 (patch) | |
| tree | 45d8d893bbc3e5bed389f6ffc403073b427f5b78 /src/test | |
| parent | b38a6d373cb254697411147c0e49cd2e84864258 (diff) | |
| download | rust-3cf22de90fcc23100bbecae3925896409d36aaa9.tar.gz rust-3cf22de90fcc23100bbecae3925896409d36aaa9.zip | |
Suggest rewriting a malformed hex literal if we expect a float
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/suggestions/bad-hex-float-lit.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/suggestions/bad-hex-float-lit.stderr | 48 |
2 files changed, 61 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/bad-hex-float-lit.rs b/src/test/ui/suggestions/bad-hex-float-lit.rs new file mode 100644 index 00000000000..cd6fdbde96c --- /dev/null +++ b/src/test/ui/suggestions/bad-hex-float-lit.rs @@ -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 +} diff --git a/src/test/ui/suggestions/bad-hex-float-lit.stderr b/src/test/ui/suggestions/bad-hex-float-lit.stderr new file mode 100644 index 00000000000..bc09abb1a56 --- /dev/null +++ b/src/test/ui/suggestions/bad-hex-float-lit.stderr @@ -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`. |
