1 #![feature(plugin_registrar)]
2 #![feature(box_syntax, rustc_private)]
6 // Load rustc as a plugin to get macros
7 extern crate rustc_driver;
8 #[macro_use] extern crate rustc_lint;
9 #[macro_use] extern crate rustc_session;
11 use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass, LintId};
12 use rustc_driver::plugin::Registry;
14 declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff");
17 pub clippy::TEST_GROUP,
18 Warn, "Warn about other stuff"
23 pub rustc::TEST_RUSTC_TOOL_LINT,
28 declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP, TEST_RUSTC_TOOL_LINT]);
30 impl EarlyLintPass for Pass {
31 fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
32 if it.ident.name.as_str() == "lintme" {
33 cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'");
35 if it.ident.name.as_str() == "lintmetoo" {
36 cx.span_lint(TEST_GROUP, it.span, "item is named 'lintmetoo'");
42 pub fn plugin_registrar(reg: &mut Registry) {
43 reg.lint_store.register_lints(&[&TEST_RUSTC_TOOL_LINT, &TEST_LINT, &TEST_GROUP]);
44 reg.lint_store.register_early_pass(|| box Pass);
45 reg.lint_store.register_group(true, "clippy::group", Some("clippy_group"),
46 vec![LintId::of(&TEST_LINT), LintId::of(&TEST_GROUP)]);