diff options
| author | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-11-08 19:45:41 +0900 |
|---|---|---|
| committer | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-11-11 10:51:00 +0900 |
| commit | c467006fd0d0fd046590c7867fcfef2062d144a3 (patch) | |
| tree | 247e6a0592cc9ae6e439e4125acec46e67b8ebf3 /src/test/ui | |
| parent | c1a859b25a95999ba276075bbd8e284ea675b41a (diff) | |
| download | rust-c467006fd0d0fd046590c7867fcfef2062d144a3.tar.gz rust-c467006fd0d0fd046590c7867fcfef2062d144a3.zip | |
suggest removing unnecessary . to use a floating point literal
Diffstat (limited to 'src/test/ui')
| -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 | 52 |
2 files changed, 58 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..b1eda63d56e --- /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 = 0..; //~ 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..2f1d7dc230f --- /dev/null +++ b/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr @@ -0,0 +1,52 @@ +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 to to use a floating point literal + | +LL - let _: f64 = 0..10; +LL + let _: f64 = 0.10; + | + +error[E0308]: mismatched types + --> $DIR/unnecessary_dot_for_floating_point_literal.rs:3:18 + | +LL | let _: f64 = 0..; + | --- ^^^ expected `f64`, found struct `RangeFrom` + | | + | expected due to this + | + = note: expected type `f64` + found struct `RangeFrom<{integer}>` + +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}>` + +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`. |
