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 double warning about illegal floating-point literal pattern #86888

Merged
merged 1 commit into from
Jul 9, 2021

Conversation

FabianWolff
Copy link
Contributor

This PR fixes #86600. The problem is that the ConstToPat struct contains a field include_lint_checks, which determines whether lints should be emitted or not, but this field is currently not obeyed at one point, leading to a warning being emitted more than once. I have fixed this behavior here.

@rust-highfive
Copy link
Collaborator

r? @davidtwco

(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 5, 2021
span,
|lint| lint.build("floating-point types cannot be used in patterns").emit(),
);
if self.include_lint_checks {
Copy link
Member

Choose a reason for hiding this comment

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

This isn't really new to this PR, but it would be nice if include_lint_checks had some documentation on when it's enabled and when not. Currently it seems to be enabled in rustc_mir_build::thir::pattern::MatchVisitor::lower_pattern but not in rustc_mir_build::thir::pattern::pat_from_hir. lower_pattern happens when checking the validity of matches and pat_from_hir happens when actually constructing mir. It might be nice to mention at the field definition site that include_lint_checks will be true when checking validity and false when building mir.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems somewhat wasteful that the ConstToPat lowering even has to run twice (if it didn't, we wouldn't need the include_lint_checks field). However, I don't know the broader design considerations behind all of this, I just developed a targeted fix for the issue you reported, so I'm not the right person to ask for additional documentation here...

Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

LGTM

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 9, 2021

📌 Commit d019c71 has been approved by davidtwco

@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 9, 2021
@bors
Copy link
Contributor

bors commented Jul 9, 2021

⌛ Testing commit d019c71 with merge e916b7c...

@bors
Copy link
Contributor

bors commented Jul 9, 2021

☀️ Test successful - checks-actions
Approved by: davidtwco
Pushing e916b7c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 9, 2021
@bors bors merged commit e916b7c into rust-lang:master Jul 9, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jul 9, 2021
@bors bors mentioned this pull request Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

illegal_floating_point_literal_pattern warns twice
6 participants