diff --git a/tests/ui/collapsible_span_lint_calls.rs b/tests/ui/collapsible_span_lint_calls.rs new file mode 100644 index 000000000000..6f25fb6cd7cd --- /dev/null +++ b/tests/ui/collapsible_span_lint_calls.rs @@ -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() {}