Skip to content

Add span_lint_note and span_lint_help to the LintContext #29100

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from
Closed

Add span_lint_note and span_lint_help to the LintContext #29100

wants to merge 1 commit into from

Conversation

nxnfufunezn
Copy link
Contributor

Fixes #19668

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Aatch (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@nxnfufunezn
Copy link
Contributor Author

r? @Manishearth

@rust-highfive rust-highfive assigned Manishearth and unassigned Aatch Oct 16, 2015
} else {
self.sess().span_note(note_span, note)
}
self.sess().fileline_help(span, &format!("for further information visit \
Copy link
Member

Choose a reason for hiding this comment

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

This part shouldn't be here, it's clippy-specific 😄

@Manishearth
Copy link
Member

Good start! The code from clippy isn't exactly what we want though, just the first bits.

(Sorry, I had to go out, so I couldn't finish explaining in IRC). span_lint will emit a warning, error, or nothing, depending on the "lint level" of the code it originated from. When the lint level is allow (i.e. there's an #[allow(name_of_lint)] somewhere enclosing the code), the lint isn't shown. Often, one wants to show a note with the lint -- but it shouldn't be shown if the lint itself isn't shown. So we check the lint level before emitting the note. This is a task which probably is required often, so we should have a help method to do it.

You should also update

ctx.span_lint(DROP_WITH_REPR_EXTERN,
to use this code.

To test, make check-stage2-cfail -j4 should work. If you want it to be faster and only run the specific test corresponding to that span_lint, try TESTNAME=lint-no-drop-on-repr-extern make check-stage2-cfail -j4

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants