Skip to content

Commit 3920433

Browse files
committed
Add test.
1 parent f3e2ccd commit 3920433

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#![deny(clippy::internal)]
2+
#![feature(rustc_private)]
3+
4+
extern crate rustc_session;
5+
extern crate rustc_errors;
6+
extern crate rustc_lint;
7+
extern crate syntax;
8+
extern crate clippy_lints;
9+
10+
use rustc_session::{declare_tool_lint, declare_lint_pass};
11+
use rustc_errors::Applicability;
12+
use rustc_lint::{EarlyContext, EarlyLintPass};
13+
use syntax::ast::Expr;
14+
use clippy_lints::utils::span_lint_and_then;
15+
16+
declare_tool_lint!{
17+
pub clippy::TEST_LINT,
18+
Warn,
19+
"",
20+
report_in_external_macro: true
21+
}
22+
23+
declare_lint_pass!(Pass => [TEST_LINT]);
24+
25+
impl EarlyLintPass for Pass {
26+
fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) {
27+
let lint_msg = "lint message";
28+
let help_msg = "help message";
29+
let note_msg = "note message";
30+
let sugg = "new_call()";
31+
span_lint_and_then(cx, expr.span, lint_msg, |db| {
32+
db.span_suggestion(expr.span, help_msg, sugg, Applicability::MachineApplicable);
33+
});
34+
span_lint_and_then(cx, expr.span, lint_msg, |db| {
35+
db.span_help(expr.span, help_msg);
36+
});
37+
span_lint_and_then(cx, expr.span, lint_msg, |db| {
38+
db.span_note(expr.span, note_msg);
39+
});
40+
}
41+
}
42+
43+
fn main() {}

0 commit comments

Comments
 (0)