Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongmao86 committed Feb 6, 2020
1 parent f3e2ccd commit 3920433
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/ui/collapsible_span_lint_calls.rs
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() {}

0 comments on commit 3920433

Please sign in to comment.