3 #![feature(plugin_registrar)]
4 #![feature(box_syntax, rustc_private)]
6 // Load rustc as a plugin to get macros.
7 #[macro_use] extern crate rustc;
8 #[macro_use] extern crate rustc_session;
9 extern crate rustc_driver
;
12 use rustc
::lint
::{LateContext, LintContext, LintPass, LateLintPass, LintArray, LintId}
;
13 use rustc_driver
::plugin
::Registry
;
15 declare_lint
!(TEST_LINT
, Warn
, "Warn about items named 'lintme'");
17 declare_lint
!(PLEASE_LINT
, Warn
, "Warn about items named 'pleaselintme'");
19 declare_lint_pass
!(Pass
=> [TEST_LINT
, PLEASE_LINT
]);
21 impl<'a
, 'tcx
> LateLintPass
<'a
, 'tcx
> for Pass
{
22 fn check_item(&mut self, cx
: &LateContext
, it
: &hir
::Item
) {
23 match &*it
.ident
.as_str() {
24 "lintme" => cx
.span_lint(TEST_LINT
, it
.span
, "item is named 'lintme'"),
25 "pleaselintme" => cx
.span_lint(PLEASE_LINT
, it
.span
, "item is named 'pleaselintme'"),
32 pub fn plugin_registrar(reg
: &mut Registry
) {
33 reg
.lint_store
.register_lints(&[&TEST_LINT
, &PLEASE_LINT
]);
34 reg
.lint_store
.register_late_pass(|| box Pass
);
35 reg
.lint_store
.register_group(true, "lint_me", None
,
36 vec
![LintId
::of(&TEST_LINT
), LintId
::of(&PLEASE_LINT
)]);