2 #![deny(clippy::internal)]
3 #![feature(rustc_private)]
5 extern crate clippy_utils;
6 extern crate rustc_ast;
7 extern crate rustc_errors;
8 extern crate rustc_lint;
9 extern crate rustc_session;
10 extern crate rustc_span;
12 use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note, span_lint_and_sugg, span_lint_and_then};
13 use rustc_ast::ast::Expr;
14 use rustc_errors::Applicability;
15 use rustc_lint::{EarlyContext, EarlyLintPass};
16 use rustc_session::{declare_lint_pass, declare_tool_lint};
19 pub clippy::TEST_LINT,
22 report_in_external_macro: true
25 declare_lint_pass!(Pass => [TEST_LINT]);
27 impl EarlyLintPass for Pass {
28 fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) {
29 let lint_msg = "lint message";
30 let help_msg = "help message";
31 let note_msg = "note message";
32 let sugg = "new_call()";
35 span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
36 db.span_suggestion(expr.span, help_msg, sugg.to_string(), Applicability::MachineApplicable);
38 span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
39 db.span_help(expr.span, help_msg);
41 span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
44 span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
45 db.span_note(expr.span, note_msg);
47 span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
51 // This expr shouldn't trigger this lint.
52 span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {