]> git.lizzy.rs Git - rust.git/blob - src/test/ui-fulldeps/auxiliary/lint-tool-test.rs
move raw span to tt reader
[rust.git] / src / test / ui-fulldeps / auxiliary / lint-tool-test.rs
1 #![feature(plugin_registrar)]
2 #![feature(box_syntax, rustc_private)]
3
4 extern crate syntax;
5
6 // Load rustc as a plugin to get macros
7 #[macro_use]
8 extern crate rustc;
9 extern crate rustc_plugin;
10
11 use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
12                   LintArray};
13 use rustc_plugin::Registry;
14 use syntax::ast;
15 declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff");
16 declare_tool_lint!(
17     /// Some docs
18     pub clippy::TEST_GROUP,
19     Warn, "Warn about other stuff"
20 );
21
22 declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP]);
23
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'");
28         }
29         if it.ident.name == "lintmetoo" {
30             cx.span_lint(TEST_GROUP, it.span, "item is named 'lintmetoo'");
31         }
32     }
33 }
34
35 #[plugin_registrar]
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]);
39 }