]> git.proxmox.com Git - rustc.git/blame - src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui-fulldeps / auxiliary / lint-plugin-test.rs
CommitLineData
1a4d82fc
JJ
1// force-host
2
3#![feature(plugin_registrar)]
c34b1796 4#![feature(box_syntax, rustc_private)]
1a4d82fc 5
b039eaaf 6extern 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 11extern crate rustc_driver;
1a4d82fc 12
e74abb32 13use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass, LintArray};
e1599b0c 14use rustc_driver::plugin::Registry;
b039eaaf 15use syntax::ast;
1a4d82fc
JJ
16declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
17
532ac7d7 18declare_lint_pass!(Pass => [TEST_LINT]);
1a4d82fc 19
b039eaaf
SL
20impl 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]
29pub 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}