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

Suggest adding a missing zero to a floating point number #98972

Conversation

TaKO8Ki
Copy link
Member

@TaKO8Ki TaKO8Ki commented Jul 6, 2022

fixes #98836

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 6, 2022
@rust-highfive
Copy link
Collaborator

r? @compiler-errors

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 6, 2022
@TaKO8Ki
Copy link
Member Author

TaKO8Ki commented Jul 6, 2022

I will also implement this suggestion for the following case later.

fn main() {
    3.e1f32;
}

)
.emit();
);
if expr_t.is_integral()
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible for you to check that the type we're dereferencing with . is a numerical literal? Specifically, I don't want it to fix:

let x = 1i32;
x.e10;

Copy link
Member

@compiler-errors compiler-errors Jul 6, 2022

Choose a reason for hiding this comment

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

Or if it already accounts for this, can you add a ui test for this case?

Copy link
Member

@compiler-errors compiler-errors Jul 7, 2022

Choose a reason for hiding this comment

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

To elaborate on this, I would probably just span_to_snippet and check that it parses as a valid number, to account for macro expansions. So you should also add a check for:

macro_rules! num { () => { 1 } }

fn main() {
    num!().e10;
}

@compiler-errors compiler-errors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 7, 2022
@compiler-errors
Copy link
Member

Thanks for the thorough test cases, when I am at my computer I will double check the implementation but it looks great.

@TaKO8Ki
Copy link
Member Author

TaKO8Ki commented Jul 12, 2022

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 12, 2022
@TaKO8Ki TaKO8Ki requested a review from compiler-errors July 12, 2022 04:22
@rust-log-analyzer

This comment has been minimized.

@TaKO8Ki TaKO8Ki force-pushed the suggest-adding-missing-zero-to-floating-point-number branch from e60c9a5 to e03cb7f Compare July 12, 2022 05:04
@compiler-errors
Copy link
Member

compiler-errors commented Jul 12, 2022

r=me after CI turns green, since i am sleeping soon

@bors delegate+

@bors
Copy link
Contributor

bors commented Jul 12, 2022

✌️ @TaKO8Ki can now approve this pull request

@TaKO8Ki
Copy link
Member Author

TaKO8Ki commented Jul 12, 2022

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Jul 12, 2022

📌 Commit e03cb7f has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 12, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jul 12, 2022
…-to-floating-point-number, r=compiler-errors

Suggest adding a missing zero to a floating point number

fixes rust-lang#98836
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jul 12, 2022
…-to-floating-point-number, r=compiler-errors

Suggest adding a missing zero to a floating point number

fixes rust-lang#98836
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 12, 2022
Rollup of 6 pull requests

Successful merges:

 - rust-lang#98622 (rustc_target: Flip the default for `TargetOptions::executables` to true)
 - rust-lang#98633 (Fix last `let_chains` blocker)
 - rust-lang#98972 (Suggest adding a missing zero to a floating point number)
 - rust-lang#99038 (Some more `EarlyBinder` cleanups)
 - rust-lang#99154 (use PlaceRef::iter_projections to fix old FIXME)
 - rust-lang#99171 (Put back UI test regex)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 99fc65b into rust-lang:master Jul 12, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 12, 2022
@TaKO8Ki TaKO8Ki deleted the suggest-adding-missing-zero-to-floating-point-number branch July 13, 2022 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggest adding zero to errornous floating point number with dot and exponent but no post-dot digit
6 participants