-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Conversation
r? @davidtwco (rust-highfive has picked a reviewer for you, use r? to override) |
span, | ||
|lint| lint.build("floating-point types cannot be used in patterns").emit(), | ||
); | ||
if self.include_lint_checks { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@bors r+ |
📌 Commit d019c71 has been approved by |
☀️ Test successful - checks-actions |
This PR fixes #86600. The problem is that the
ConstToPat
struct contains a fieldinclude_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.