1 #![feature(plugin_registrar)]
2 #![feature(box_syntax, rustc_private)]
6 // Load rustc as a plugin to get macros
9 extern crate rustc_plugin;
11 use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
13 use rustc_plugin::Registry;
15 declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff");
18 pub clippy::TEST_GROUP,
19 Warn, "Warn about other stuff"
22 declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP]);
24 impl EarlyLintPass for Pass {
25 fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
26 if it.ident.name == "lintme" {
27 cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'");
29 if it.ident.name == "lintmetoo" {
30 cx.span_lint(TEST_GROUP, it.span, "item is named 'lintmetoo'");
36 pub fn plugin_registrar(reg: &mut Registry) {
37 reg.register_early_lint_pass(box Pass);
38 reg.register_lint_group("clippy::group", Some("clippy_group"), vec![TEST_LINT, TEST_GROUP]);