]> git.lizzy.rs Git - rust.git/blob - src/test/ui-fulldeps/auxiliary/lint-tool-test.rs
Deprecate using rustc_plugin without the rustc_driver dylib.
[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_driver;
10
11 use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
12 use rustc_driver::plugin::Registry;
13 use syntax::ast;
14 declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff");
15 declare_tool_lint!(
16     /// Some docs
17     pub clippy::TEST_GROUP,
18     Warn, "Warn about other stuff"
19 );
20
21 declare_tool_lint!(
22     /// Some docs
23     pub rustc::TEST_RUSTC_TOOL_LINT,
24     Deny,
25     "Deny internal stuff"
26 );
27
28 declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP, TEST_RUSTC_TOOL_LINT]);
29
30 impl EarlyLintPass for Pass {
31     fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
32         if it.ident.name.as_str() == "lintme" {
33             cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'");
34         }
35         if it.ident.name.as_str() == "lintmetoo" {
36             cx.span_lint(TEST_GROUP, it.span, "item is named 'lintmetoo'");
37         }
38     }
39 }
40
41 #[plugin_registrar]
42 pub fn plugin_registrar(reg: &mut Registry) {
43     reg.register_early_lint_pass(box Pass);
44     reg.register_lint_group("clippy::group", Some("clippy_group"), vec![TEST_LINT, TEST_GROUP]);
45 }