-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fixes issue 5095 #5141
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
Merged
Merged
Fixes issue 5095 #5141
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bdd32e7
Implement collapsible_span_lint_calls lint.
xiongmao86 d03d3bd
Fixes internal lint warning in code base.
xiongmao86 cf4e353
Add an Option<Span> argument to span_lint_and_help.
xiongmao86 d7f1a1e
Change note_span argument for span_lint_and_note.
xiongmao86 41115d9
Formatting and naming
flip1995 98a244f
Formatting and naming
flip1995 7aeb3a4
Update empty_enum.stderr
flip1995 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Implement collapsible_span_lint_calls lint.
- Loading branch information
commit bdd32e77007bb1ac0fe22d5f60bd9c7efe5b98c3
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| // run-rustfix | ||
| #![deny(clippy::internal)] | ||
| #![feature(rustc_private)] | ||
|
|
||
| extern crate rustc_ast; | ||
| extern crate rustc_errors; | ||
| extern crate rustc_lint; | ||
| extern crate rustc_session; | ||
| extern crate rustc_span; | ||
|
|
||
| use rustc_ast::ast::Expr; | ||
| use rustc_errors::{Applicability, DiagnosticBuilder}; | ||
| use rustc_lint::{EarlyContext, EarlyLintPass, Lint, LintContext}; | ||
| use rustc_session::{declare_lint_pass, declare_tool_lint}; | ||
| use rustc_span::source_map::Span; | ||
|
|
||
| #[allow(unused_variables)] | ||
| pub fn span_lint_and_then<'a, T: LintContext, F>(cx: &'a T, lint: &'static Lint, sp: Span, msg: &str, f: F) | ||
| where | ||
| F: for<'b> FnOnce(&mut DiagnosticBuilder<'b>), | ||
| { | ||
| } | ||
|
|
||
| #[allow(unused_variables)] | ||
| fn span_lint_and_help<'a, T: LintContext>(cx: &'a T, lint: &'static Lint, span: Span, msg: &str, help: &str) {} | ||
|
|
||
| #[allow(unused_variables)] | ||
| fn span_lint_and_note<'a, T: LintContext>( | ||
| cx: &'a T, | ||
| lint: &'static Lint, | ||
| span: Span, | ||
| msg: &str, | ||
| note_span: Span, | ||
| note: &str, | ||
| ) { | ||
| } | ||
|
|
||
| #[allow(unused_variables)] | ||
| fn span_lint_and_sugg<'a, T: LintContext>( | ||
| cx: &'a T, | ||
| lint: &'static Lint, | ||
| sp: Span, | ||
| msg: &str, | ||
| help: &str, | ||
| sugg: String, | ||
| applicability: Applicability, | ||
| ) { | ||
| } | ||
|
|
||
| declare_tool_lint! { | ||
| pub clippy::TEST_LINT, | ||
| Warn, | ||
| "", | ||
| report_in_external_macro: true | ||
| } | ||
|
|
||
| declare_lint_pass!(Pass => [TEST_LINT]); | ||
|
|
||
| impl EarlyLintPass for Pass { | ||
| fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) { | ||
| let lint_msg = "lint message"; | ||
| let help_msg = "help message"; | ||
| let note_msg = "note message"; | ||
| let sugg = "new_call()"; | ||
| let predicate = true; | ||
|
|
||
| span_lint_and_sugg(cx, TEST_LINT, expr.span, lint_msg, help_msg, sugg.to_string(), Applicability::MachineApplicable); | ||
| span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, help_msg); | ||
| span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, help_msg); | ||
| span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, expr.span, note_msg); | ||
| span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, expr.span, note_msg); | ||
|
|
||
| // This expr shouldn't trigger this lint. | ||
| span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| { | ||
| db.note(note_msg); | ||
| if predicate { | ||
| db.note(note_msg); | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| fn main() {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.