3 #![feature(plugin_registrar)]
4 #![feature(box_syntax, rustc_private)]
6 extern crate rustc_ast;
8 // Load rustc as a plugin to get macros
9 extern crate rustc_driver;
11 extern crate rustc_lint;
13 extern crate rustc_session;
15 use rustc_driver::plugin::Registry;
16 use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
18 declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
20 declare_lint_pass!(Pass => [TEST_LINT]);
22 impl EarlyLintPass for Pass {
23 fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
24 if it.ident.name.as_str() == "lintme" {
25 cx.lint(TEST_LINT, |lint| {
26 lint.build("item is named 'lintme'").set_span(it.span).emit()
33 pub fn plugin_registrar(reg: &mut Registry) {
34 reg.lint_store.register_lints(&[&TEST_LINT]);
35 reg.lint_store.register_early_pass(|| box Pass);