2 #![deny(clippy::internal)]
3 #![feature(rustc_private)]
5 extern crate rustc_ast;
6 extern crate rustc_errors;
7 extern crate rustc_lint;
8 extern crate rustc_session;
9 extern crate rustc_span;
11 use rustc_ast::ast::Expr;
12 use rustc_errors::{Applicability, DiagnosticBuilder};
13 use rustc_lint::{EarlyContext, EarlyLintPass, Lint, LintContext};
14 use rustc_session::{declare_lint_pass, declare_tool_lint};
15 use rustc_span::source_map::Span;
17 #[allow(unused_variables)]
18 pub fn span_lint_and_then<'a, T: LintContext, F>(cx: &'a T, lint: &'static Lint, sp: Span, msg: &str, f: F)
20 F: for<'b> FnOnce(&mut DiagnosticBuilder<'b>),
24 #[allow(unused_variables)]
25 fn span_lint_and_help<'a, T: LintContext>(cx: &'a T, lint: &'static Lint, span: Span, msg: &str, help: &str) {}
27 #[allow(unused_variables)]
28 fn span_lint_and_note<'a, T: LintContext>(
38 #[allow(unused_variables)]
39 fn span_lint_and_sugg<'a, T: LintContext>(
46 applicability: Applicability,
51 pub clippy::TEST_LINT,
54 report_in_external_macro: true
57 declare_lint_pass!(Pass => [TEST_LINT]);
59 impl EarlyLintPass for Pass {
60 fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) {
61 let lint_msg = "lint message";
62 let help_msg = "help message";
63 let note_msg = "note message";
64 let sugg = "new_call()";
67 span_lint_and_sugg(cx, TEST_LINT, expr.span, lint_msg, help_msg, sugg.to_string(), Applicability::MachineApplicable);
68 span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, help_msg);
69 span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, help_msg);
70 span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, expr.span, note_msg);
71 span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, expr.span, note_msg);
73 // This expr shouldn't trigger this lint.
74 span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {