-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3e2ccd
commit 3920433
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,43 @@ | ||
#![deny(clippy::internal)] | ||
#![feature(rustc_private)] | ||
|
||
extern crate rustc_session; | ||
extern crate rustc_errors; | ||
extern crate rustc_lint; | ||
extern crate syntax; | ||
extern crate clippy_lints; | ||
|
||
use rustc_session::{declare_tool_lint, declare_lint_pass}; | ||
use rustc_errors::Applicability; | ||
use rustc_lint::{EarlyContext, EarlyLintPass}; | ||
use syntax::ast::Expr; | ||
use clippy_lints::utils::span_lint_and_then; | ||
|
||
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()"; | ||
span_lint_and_then(cx, expr.span, lint_msg, |db| { | ||
db.span_suggestion(expr.span, help_msg, sugg, Applicability::MachineApplicable); | ||
}); | ||
span_lint_and_then(cx, expr.span, lint_msg, |db| { | ||
db.span_help(expr.span, help_msg); | ||
}); | ||
span_lint_and_then(cx, expr.span, lint_msg, |db| { | ||
db.span_note(expr.span, note_msg); | ||
}); | ||
} | ||
} | ||
|
||
fn main() {} |