]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // force-host |
2 | ||
3 | #![feature(plugin_registrar)] | |
c34b1796 | 4 | #![feature(box_syntax, rustc_private)] |
1a4d82fc | 5 | |
b039eaaf | 6 | extern crate syntax; |
1a4d82fc JJ |
7 | |
8 | // Load rustc as a plugin to get macros | |
60c5eb7d XL |
9 | #[macro_use] extern crate rustc; |
10 | #[macro_use] extern crate rustc_session; | |
416331ca | 11 | extern crate rustc_driver; |
1a4d82fc | 12 | |
e74abb32 | 13 | use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass, LintArray}; |
e1599b0c | 14 | use rustc_driver::plugin::Registry; |
b039eaaf | 15 | use syntax::ast; |
1a4d82fc JJ |
16 | declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); |
17 | ||
532ac7d7 | 18 | declare_lint_pass!(Pass => [TEST_LINT]); |
1a4d82fc | 19 | |
b039eaaf SL |
20 | impl EarlyLintPass for Pass { |
21 | fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { | |
48663c56 | 22 | if it.ident.name.as_str() == "lintme" { |
1a4d82fc JJ |
23 | cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"); |
24 | } | |
25 | } | |
26 | } | |
27 | ||
28 | #[plugin_registrar] | |
29 | pub fn plugin_registrar(reg: &mut Registry) { | |
e74abb32 XL |
30 | reg.lint_store.register_lints(&[&TEST_LINT]); |
31 | reg.lint_store.register_early_pass(|| box Pass); | |
1a4d82fc | 32 | } |