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

Don't lint various match lints when expanded by a proc-macro #8667

Merged
merged 1 commit into from
Apr 11, 2022

Conversation

Jarcho
Copy link
Contributor

@Jarcho Jarcho commented Apr 8, 2022

fixes #4952

As always for proc-macro output this is a hack-job of a fix. It would be really nice if more proc-macro authors would set spans correctly.

changelog: Don't lint various lints on proc-macro output.

@rust-highfive
Copy link

r? @flip1995

(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 Apr 8, 2022
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

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

LGTM, small comment on the utils function.

Comment on lines +19 to +20
fn helper(sm: &SourceMap, span: Span, text: &str) -> bool {
let pos = sm.lookup_byte_offset(span.lo());
Copy link
Member

Choose a reason for hiding this comment

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

Removing this helper function would only change this line inside the whole helper function

Suggested change
fn helper(sm: &SourceMap, span: Span, text: &str) -> bool {
let pos = sm.lookup_byte_offset(span.lo());
cx.sess().source_map().lookup_byte_offset(span.lo());

but we save a level of indentation and an inner function

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's to deal with duplication due to monomorphization on the lint context.

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't that just get optimized out by the outliner or other opt passes?

Copy link
Member

@flip1995 flip1995 Apr 11, 2022

Choose a reason for hiding this comment

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

Just checked: it doesn't. This saves around 1 kB in code size.

@flip1995
Copy link
Member

@bors r+

Thanks!

@bors
Copy link
Contributor

bors commented Apr 11, 2022

📌 Commit 63f6a79 has been approved by flip1995

@bors
Copy link
Contributor

bors commented Apr 11, 2022

⌛ Testing commit 63f6a79 with merge 89ee6aa...

@bors
Copy link
Contributor

bors commented Apr 11, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing 89ee6aa to master...

@bors bors merged commit 89ee6aa into rust-lang:master Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

single_match_else false positive
4 participants