Skip to content

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

Merged
bors merged 2 commits into
rust-lang:masterfrom
TaKO8Ki:suggest-adding-missing-zero-to-floating-point-number
Jul 12, 2022
Merged

Suggest adding a missing zero to a floating point number#98972
bors merged 2 commits into
rust-lang:masterfrom
TaKO8Ki:suggest-adding-missing-zero-to-floating-point-number

Conversation

@TaKO8Ki

Copy link
Copy Markdown
Member

fixes#98836

@rustbotrustbot 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
Copy Markdown
Contributor

r? @compiler-errors

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

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

TaKO8Ki commented Jul 6, 2022

Copy link
Copy Markdown
MemberAuthor

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

fnmain(){3.e1f32;}

Comment threadcompiler/rustc_typeck/src/check/expr.rs Outdated
)
.emit();
);
if expr_t.is_integral()

Copy link
Copy Markdown
Contributor

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;

@compiler-errorscompiler-errorsJul 6, 2022

Copy link
Copy Markdown
Contributor

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?

@compiler-errorscompiler-errorsJul 7, 2022

Copy link
Copy Markdown
Contributor

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-errorscompiler-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
Copy Markdown
Contributor

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
Copy Markdown
MemberAuthor

@rustbot ready

@rustbotrustbot 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
@rust-log-analyzer

This comment has been minimized.

@TaKO8Ki
TaKO8Kiforce-pushed the suggest-adding-missing-zero-to-floating-point-number branch from e60c9a5 to e03cb7fCompareJuly 12, 2022 05:04
@compiler-errors

compiler-errors commented Jul 12, 2022

Copy link
Copy Markdown
Contributor

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

@bors delegate+

@bors

bors commented Jul 12, 2022

Copy link
Copy Markdown
Collaborator

✌️ @TaKO8Ki can now approve this pull request

@TaKO8Ki

Copy link
Copy Markdown
MemberAuthor

@bors r=compiler-errors

@bors

bors commented Jul 12, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit e03cb7f has been approved by compiler-errors

It is now in the queue for this repository.

@borsbors 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
fixesrust-lang#98836
@Dylan-DPCDylan-DPC mentioned this pull request Jul 12, 2022
@Dylan-DPCDylan-DPC mentioned this pull request 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
fixesrust-lang#98836
@Dylan-DPCDylan-DPC mentioned this pull request Jul 12, 2022
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:masterJul 12, 2022
@rustbotrustbot 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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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

@TaKO8Ki@rust-highfive@compiler-errors@rust-log-analyzer@bors@rustbot