Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix float ICE #90927

Merged
merged 1 commit into from
Nov 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
@@ -1032,6 +1032,8 @@ impl<'a> Parser<'a> {
[IdentLike(_), Punct('+' | '-')] |
// 1e+2 | 1e-2
[IdentLike(_), Punct('+' | '-'), IdentLike(_)] |
// 1.2e+ | 1.2e-
[IdentLike(_), Punct('.'), IdentLike(_), Punct('+' | '-')] |
// 1.2e+3 | 1.2e-3
[IdentLike(_), Punct('.'), IdentLike(_), Punct('+' | '-'), IdentLike(_)] => {
// See the FIXME about `TokenCursor` above.
6 changes: 6 additions & 0 deletions src/test/ui/parser/issue-90728.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main() {
a.5.2E+
//~^ ERROR: unexpected token: `5.2E+`
//~| ERROR: expected one of `.`, `;`, `?`, `}`, or an operator, found `5.2E+`
//~| ERROR: expected at least one digit in exponent
}
20 changes: 20 additions & 0 deletions src/test/ui/parser/issue-90728.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error: expected at least one digit in exponent
--> $DIR/issue-90728.rs:2:7
|
LL | a.5.2E+
| ^^^^^
Comment on lines +1 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error in particular could likely be more actionable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you be a bit more precise about that?

Copy link
Contributor

@estebank estebank Nov 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean using a span_suggestion_verbose (and SourceMap::next_point(Span)) to produce something like the following (just a rough draft, doesn't have to look like this exactly):

error: expected at least one digit in exponent
  --> $DIR/issue-90728.rs:2:7
   |
LL |     a.5.2E+
   |       -----^ expected a number here
   |       |
   |       this numeric literal is incomplete
help: write a valid exponent
   |
LL |     a.5.2E+1
   |            +

This is similar to what we do on missing `;` or `,` in statements or between `fn` args.


error: unexpected token: `5.2E+`
--> $DIR/issue-90728.rs:2:7
|
LL | a.5.2E+
| ^^^^^

error: expected one of `.`, `;`, `?`, `}`, or an operator, found `5.2E+`
--> $DIR/issue-90728.rs:2:7
|
LL | a.5.2E+
| ^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
Comment on lines +7 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we could recover more gracefully after encountering it ^_^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean like spitting out no errors afterwards?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, but that doesn't have to be addressed in this PR.


error: aborting due to 3 previous errors

2 changes: 1 addition & 1 deletion src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ const ENTRY_LIMIT: usize = 1000;
// FIXME: The following limits should be reduced eventually.
const ROOT_ENTRY_LIMIT: usize = 983;
const ISSUES_ENTRY_LIMIT: usize = 2310;
const PARSER_LIMIT: usize = 1010;
const PARSER_LIMIT: usize = 1012;

fn check_entries(path: &Path, bad: &mut bool) {
let dirs = walkdir::WalkDir::new(&path.join("test/ui"))