forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#98972 - TaKO8Ki:suggest-adding-missing-zero…
…-to-floating-point-number, r=compiler-errors Suggest adding a missing zero to a floating point number fixes rust-lang#98836
- Loading branch information
Showing
6 changed files
with
219 additions
and
4 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
21 changes: 21 additions & 0 deletions
21
src/test/ui/typeck/do-not-suggest-adding-missing-zero-to-floating-point-number.rs
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,21 @@ | ||
macro_rules! num { () => { 1 } } | ||
|
||
fn main() { | ||
let x = 1i32; | ||
x.e10; //~ERROR `i32` is a primitive type and therefore doesn't have fields | ||
|
||
let y = 1; | ||
y.e10; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
|
||
2u32.e10; //~ERROR `u32` is a primitive type and therefore doesn't have fields | ||
|
||
num!().e10; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
|
||
2.e10foo; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
|
||
42._; | ||
//~^ERROR expected identifier, found reserved identifier `_` | ||
//~|ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
|
||
42.a; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
} |
51 changes: 51 additions & 0 deletions
51
src/test/ui/typeck/do-not-suggest-adding-missing-zero-to-floating-point-number.stderr
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,51 @@ | ||
error: expected identifier, found reserved identifier `_` | ||
--> $DIR/do-not-suggest-adding-missing-zero-to-floating-point-number.rs:16:8 | ||
| | ||
LL | 42._; | ||
| ^ expected identifier, found reserved identifier | ||
|
||
error[E0610]: `i32` is a primitive type and therefore doesn't have fields | ||
--> $DIR/do-not-suggest-adding-missing-zero-to-floating-point-number.rs:5:7 | ||
| | ||
LL | x.e10; | ||
| ^^^ | ||
|
||
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields | ||
--> $DIR/do-not-suggest-adding-missing-zero-to-floating-point-number.rs:8:7 | ||
| | ||
LL | y.e10; | ||
| ^^^ | ||
|
||
error[E0610]: `u32` is a primitive type and therefore doesn't have fields | ||
--> $DIR/do-not-suggest-adding-missing-zero-to-floating-point-number.rs:10:10 | ||
| | ||
LL | 2u32.e10; | ||
| ^^^ | ||
|
||
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields | ||
--> $DIR/do-not-suggest-adding-missing-zero-to-floating-point-number.rs:12:12 | ||
| | ||
LL | num!().e10; | ||
| ^^^ | ||
|
||
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields | ||
--> $DIR/do-not-suggest-adding-missing-zero-to-floating-point-number.rs:14:7 | ||
| | ||
LL | 2.e10foo; | ||
| ^^^^^^ | ||
|
||
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields | ||
--> $DIR/do-not-suggest-adding-missing-zero-to-floating-point-number.rs:16:8 | ||
| | ||
LL | 42._; | ||
| ^ | ||
|
||
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields | ||
--> $DIR/do-not-suggest-adding-missing-zero-to-floating-point-number.rs:20:8 | ||
| | ||
LL | 42.a; | ||
| ^ | ||
|
||
error: aborting due to 8 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0610`. |
11 changes: 11 additions & 0 deletions
11
src/test/ui/typeck/suggest-adding-missing-zero-to-floating-point-number.fixed
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,11 @@ | ||
// run-rustfix | ||
|
||
fn main() { | ||
2.0e1; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
2.0E1; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
2.0f32; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
2.0f64; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
2.0e+12; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
2.0e-12; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
2.0e1f32; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
} |
11 changes: 11 additions & 0 deletions
11
src/test/ui/typeck/suggest-adding-missing-zero-to-floating-point-number.rs
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,11 @@ | ||
// run-rustfix | ||
|
||
fn main() { | ||
2.e1; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
2.E1; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
2.f32; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
2.f64; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
2.e+12; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
2.e-12; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
2.e1f32; //~ERROR `{integer}` is a primitive type and therefore doesn't have fields | ||
} |
80 changes: 80 additions & 0 deletions
80
src/test/ui/typeck/suggest-adding-missing-zero-to-floating-point-number.stderr
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,80 @@ | ||
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields | ||
--> $DIR/suggest-adding-missing-zero-to-floating-point-number.rs:4:7 | ||
| | ||
LL | 2.e1; | ||
| ^^ | ||
| | ||
help: If the number is meant to be a floating point number, consider adding a `0` after the period | ||
| | ||
LL | 2.0e1; | ||
| + | ||
|
||
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields | ||
--> $DIR/suggest-adding-missing-zero-to-floating-point-number.rs:5:7 | ||
| | ||
LL | 2.E1; | ||
| ^^ | ||
| | ||
help: If the number is meant to be a floating point number, consider adding a `0` after the period | ||
| | ||
LL | 2.0E1; | ||
| + | ||
|
||
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields | ||
--> $DIR/suggest-adding-missing-zero-to-floating-point-number.rs:6:7 | ||
| | ||
LL | 2.f32; | ||
| ^^^ | ||
| | ||
help: If the number is meant to be a floating point number, consider adding a `0` after the period | ||
| | ||
LL | 2.0f32; | ||
| + | ||
|
||
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields | ||
--> $DIR/suggest-adding-missing-zero-to-floating-point-number.rs:7:7 | ||
| | ||
LL | 2.f64; | ||
| ^^^ | ||
| | ||
help: If the number is meant to be a floating point number, consider adding a `0` after the period | ||
| | ||
LL | 2.0f64; | ||
| + | ||
|
||
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields | ||
--> $DIR/suggest-adding-missing-zero-to-floating-point-number.rs:8:7 | ||
| | ||
LL | 2.e+12; | ||
| ^ | ||
| | ||
help: If the number is meant to be a floating point number, consider adding a `0` after the period | ||
| | ||
LL | 2.0e+12; | ||
| + | ||
|
||
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields | ||
--> $DIR/suggest-adding-missing-zero-to-floating-point-number.rs:9:7 | ||
| | ||
LL | 2.e-12; | ||
| ^ | ||
| | ||
help: If the number is meant to be a floating point number, consider adding a `0` after the period | ||
| | ||
LL | 2.0e-12; | ||
| + | ||
|
||
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields | ||
--> $DIR/suggest-adding-missing-zero-to-floating-point-number.rs:10:7 | ||
| | ||
LL | 2.e1f32; | ||
| ^^^^^ | ||
| | ||
help: If the number is meant to be a floating point number, consider adding a `0` after the period | ||
| | ||
LL | 2.0e1f32; | ||
| + | ||
|
||
error: aborting due to 7 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0610`. |