]> git.lizzy.rs Git - rust.git/blob - src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs
Merge branch 'master' into rusty-hermit, resolve conflicts
[rust.git] / src / test / ui-fulldeps / auxiliary / lint-plugin-test.rs
1 // force-host
2
3 #![feature(plugin_registrar)]
4 #![feature(box_syntax, rustc_private)]
5
6 extern crate syntax;
7
8 // Load rustc as a plugin to get macros
9 #[macro_use]
10 extern crate rustc;
11 extern crate rustc_driver;
12
13 use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass, LintArray};
14 use rustc_driver::plugin::Registry;
15 use syntax::ast;
16 declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
17
18 declare_lint_pass!(Pass => [TEST_LINT]);
19
20 impl EarlyLintPass for Pass {
21     fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
22         if it.ident.name.as_str() == "lintme" {
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) {
30     reg.lint_store.register_lints(&[&TEST_LINT]);
31     reg.lint_store.register_early_pass(|| box Pass);
32 }