2 #![deny(clippy::internal)]
3 #![allow(clippy::missing_clippy_version_attribute)]
4 #![feature(rustc_private)]
6 extern crate clippy_utils;
7 extern crate rustc_ast;
8 extern crate rustc_errors;
9 extern crate rustc_lint;
10 extern crate rustc_session;
11 extern crate rustc_span;
13 use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note, span_lint_and_sugg, span_lint_and_then};
14 use rustc_ast::ast::Expr;
15 use rustc_errors::Applicability;
16 use rustc_lint::{EarlyContext, EarlyLintPass};
17 use rustc_session::{declare_lint_pass, declare_tool_lint};
20 pub clippy::TEST_LINT,
23 report_in_external_macro: true
26 declare_lint_pass!(Pass => [TEST_LINT]);
28 impl EarlyLintPass for Pass {
29 fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) {
30 let lint_msg = "lint message";
31 let help_msg = "help message";
32 let note_msg = "note message";
33 let sugg = "new_call()";
36 span_lint_and_sugg(cx, TEST_LINT, expr.span, lint_msg, help_msg, sugg.to_string(), Applicability::MachineApplicable);
37 span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), help_msg);
38 span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, None, help_msg);
39 span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), note_msg);
40 span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, None, note_msg);
42 // This expr shouldn't trigger this lint.
43 span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
51 span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
52 db.help(help_msg).help(help_msg);