diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2022-11-12 17:25:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-12 17:25:01 +0100 |
| commit | 55ae6516f9bed7a1cd65b784c56919133486f546 (patch) | |
| tree | 9a9f745eb560dcdc0cdf66932e2c7837b7b2edd1 /src/test/ui/suggestions | |
| parent | bef2da06294d7dddeccd1f6ede825fb77a31b6fc (diff) | |
| parent | 6018f115aa7365db39a9df1f883123076403a97b (diff) | |
| download | rust-55ae6516f9bed7a1cd65b784c56919133486f546.tar.gz rust-55ae6516f9bed7a1cd65b784c56919133486f546.zip | |
Rollup merge of #104144 - TaKO8Ki:suggest-removing-unnecessary-dot, r=fee1-dead
Suggest removing unnecessary `.` to use a floating point literal Fixes a part of #101883
Diffstat (limited to 'src/test/ui/suggestions')
| -rw-r--r-- | src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr | 59 |
2 files changed, 65 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.rs b/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.rs new file mode 100644 index 00000000000..c1a94456268 --- /dev/null +++ b/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.rs @@ -0,0 +1,6 @@ +fn main() { + let _: f64 = 0..10; //~ ERROR mismatched types + let _: f64 = 1..; //~ ERROR mismatched types + let _: f64 = ..10; //~ ERROR mismatched types + let _: f64 = std::ops::Range { start: 0, end: 1 }; //~ ERROR mismatched types +} diff --git a/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr b/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr new file mode 100644 index 00000000000..773f1392ae7 --- /dev/null +++ b/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr @@ -0,0 +1,59 @@ +error[E0308]: mismatched types + --> $DIR/unnecessary_dot_for_floating_point_literal.rs:2:18 + | +LL | let _: f64 = 0..10; + | --- ^^^^^ expected `f64`, found struct `std::ops::Range` + | | + | expected due to this + | + = note: expected type `f64` + found struct `std::ops::Range<{integer}>` +help: remove the unnecessary `.` operator for a floating point literal + | +LL | let _: f64 = 0.10; + | ~ + +error[E0308]: mismatched types + --> $DIR/unnecessary_dot_for_floating_point_literal.rs:3:18 + | +LL | let _: f64 = 1..; + | --- ^^^ expected `f64`, found struct `RangeFrom` + | | + | expected due to this + | + = note: expected type `f64` + found struct `RangeFrom<{integer}>` +help: remove the unnecessary `.` operator for a floating point literal + | +LL | let _: f64 = 1.; + | ~ + +error[E0308]: mismatched types + --> $DIR/unnecessary_dot_for_floating_point_literal.rs:4:18 + | +LL | let _: f64 = ..10; + | --- ^^^^ expected `f64`, found struct `RangeTo` + | | + | expected due to this + | + = note: expected type `f64` + found struct `RangeTo<{integer}>` +help: remove the unnecessary `.` operator and add an integer part for a floating point literal + | +LL | let _: f64 = 0.10; + | ~~ + +error[E0308]: mismatched types + --> $DIR/unnecessary_dot_for_floating_point_literal.rs:5:18 + | +LL | let _: f64 = std::ops::Range { start: 0, end: 1 }; + | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `f64`, found struct `std::ops::Range` + | | + | expected due to this + | + = note: expected type `f64` + found struct `std::ops::Range<{integer}>` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. |
