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.
Auto merge of rust-lang#105650 - cassaundra:float-literal-suggestion,…
… r=pnkfelix Fix invalid float literal suggestions when recovering an integer Only suggest adding a zero to integers with a preceding dot when the change will result in a valid floating point literal. For example, `.0x0` should not be turned into `0.0x0`. r? nnethercote
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
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,24 @@ | ||
// Check that suggestions to add a zero to integers with a preceding dot only appear when the change | ||
// will result in a valid floating point literal. | ||
|
||
fn main() {} | ||
|
||
fn a() { | ||
_ = .3u32; | ||
//~^ ERROR expected expression, found `.` | ||
} | ||
|
||
fn b() { | ||
_ = .0b0; | ||
//~^ ERROR expected expression, found `.` | ||
} | ||
|
||
fn c() { | ||
_ = .0o07; | ||
//~^ ERROR expected expression, found `.` | ||
} | ||
|
||
fn d() { | ||
_ = .0x0ABC; | ||
//~^ ERROR expected expression, found `.` | ||
} |
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,26 @@ | ||
error: expected expression, found `.` | ||
--> $DIR/recover-invalid-float-invalid.rs:7:9 | ||
| | ||
LL | _ = .3u32; | ||
| ^ expected expression | ||
|
||
error: expected expression, found `.` | ||
--> $DIR/recover-invalid-float-invalid.rs:12:9 | ||
| | ||
LL | _ = .0b0; | ||
| ^ expected expression | ||
|
||
error: expected expression, found `.` | ||
--> $DIR/recover-invalid-float-invalid.rs:17:9 | ||
| | ||
LL | _ = .0o07; | ||
| ^ expected expression | ||
|
||
error: expected expression, found `.` | ||
--> $DIR/recover-invalid-float-invalid.rs:22:9 | ||
| | ||
LL | _ = .0x0ABC; | ||
| ^ expected expression | ||
|
||
error: aborting due to 4 previous errors | ||
|