]>
Commit | Line | Data |
---|---|---|
c34b1796 AL |
1 | // force-host |
2 | ||
3 | #![feature(plugin_registrar, rustc_private)] | |
4 | #![feature(box_syntax)] | |
5 | ||
416331ca | 6 | extern crate rustc_driver; |
dfeec247 XL |
7 | extern crate rustc_hir; |
8 | #[macro_use] extern crate rustc_lint; | |
9 | #[macro_use] extern crate rustc_session; | |
10 | extern crate rustc_span; | |
b039eaaf | 11 | extern crate syntax; |
c34b1796 | 12 | |
dfeec247 | 13 | use rustc_lint::{LateContext, LintContext, LintPass, LateLintPass, LintArray}; |
e1599b0c | 14 | use rustc_driver::plugin::Registry; |
dfeec247 | 15 | use rustc_span::symbol::Symbol; |
b039eaaf | 16 | use syntax::attr; |
c34b1796 | 17 | |
532ac7d7 XL |
18 | declare_lint! { |
19 | CRATE_NOT_OKAY, | |
20 | Warn, | |
21 | "crate not marked with #![crate_okay]" | |
b039eaaf | 22 | } |
c34b1796 | 23 | |
532ac7d7 XL |
24 | declare_lint_pass!(Pass => [CRATE_NOT_OKAY]); |
25 | ||
476ff2be | 26 | impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { |
dfeec247 | 27 | fn check_crate(&mut self, cx: &LateContext, krate: &rustc_hir::Crate) { |
48663c56 | 28 | if !attr::contains_name(&krate.attrs, Symbol::intern("crate_okay")) { |
c34b1796 AL |
29 | cx.span_lint(CRATE_NOT_OKAY, krate.span, |
30 | "crate is not marked with #![crate_okay]"); | |
31 | } | |
32 | } | |
33 | } | |
34 | ||
35 | #[plugin_registrar] | |
36 | pub fn plugin_registrar(reg: &mut Registry) { | |
e74abb32 XL |
37 | reg.lint_store.register_lints(&[&CRATE_NOT_OKAY]); |
38 | reg.lint_store.register_late_pass(|| box Pass); | |
c34b1796 | 39 | } |