]> git.lizzy.rs Git - rust.git/blob - src/test/ui-fulldeps/auxiliary/lint-for-crate.rs
move raw span to tt reader
[rust.git] / src / test / ui-fulldeps / auxiliary / lint-for-crate.rs
1 // force-host
2
3 #![feature(plugin_registrar, rustc_private)]
4 #![feature(box_syntax)]
5
6 #[macro_use] extern crate rustc;
7 extern crate rustc_plugin;
8 extern crate syntax;
9
10 use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray};
11 use rustc_plugin::Registry;
12 use rustc::hir;
13 use syntax::attr;
14
15 declare_lint! {
16     CRATE_NOT_OKAY,
17     Warn,
18     "crate not marked with #![crate_okay]"
19 }
20
21 declare_lint_pass!(Pass => [CRATE_NOT_OKAY]);
22
23 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
24     fn check_crate(&mut self, cx: &LateContext, krate: &hir::Crate) {
25         if !attr::contains_name(&krate.attrs, "crate_okay") {
26             cx.span_lint(CRATE_NOT_OKAY, krate.span,
27                          "crate is not marked with #![crate_okay]");
28         }
29     }
30 }
31
32 #[plugin_registrar]
33 pub fn plugin_registrar(reg: &mut Registry) {
34     reg.register_late_lint_pass(box Pass);
35 }