4

Don't lint various match lints when expanded by a proc-macro by Jarcho · Pull Re...

 2 years ago
source link: https://github.com/rust-lang/rust-clippy/pull/8667
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

New issue

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

Conversation

Copy link

Contributor

@Jarcho Jarcho commented 9 days ago

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.

Copy link

Collaborator

rust-highfive commented 9 days ago

r? @flip1995

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

rust-highfive

added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label

9 days ago

Copy link

Member

@flip1995 flip1995 left a comment

LGTM, small comment on the utils function.

fn helper(sm: &SourceMap, span: Span, text: &str) -> bool {

let pos = sm.lookup_byte_offset(span.lo());

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

@Jarcho Jarcho 6 days ago

It's to deal with duplication due to monomorphization on the lint context.

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

Copy link

Member

@flip1995 flip1995 6 days ago

edited

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

Copy link

Member

flip1995 commented 6 days ago

@bors r+

Thanks!

Copy link

Contributor

bors commented 6 days ago

pushpin Commit 63f6a79 has been approved by flip1995

Copy link

Contributor

bors commented 6 days ago

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

bors

merged commit 89ee6aa into

rust-lang:master 6 days ago

5 checks passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

flip1995

Assignees

flip1995

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK