]>
Commit | Line | Data |
---|---|---|
c34b1796 AL |
1 | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | // force-host | |
12 | ||
13 | #![feature(plugin_registrar, rustc_private)] | |
14 | #![feature(box_syntax)] | |
abe05a73 | 15 | #![feature(macro_vis_matcher)] |
c34b1796 | 16 | |
c34b1796 | 17 | #[macro_use] extern crate rustc; |
92a42be0 | 18 | extern crate rustc_plugin; |
b039eaaf | 19 | extern crate syntax; |
c34b1796 | 20 | |
b039eaaf | 21 | use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray}; |
92a42be0 | 22 | use rustc_plugin::Registry; |
54a0048b | 23 | use rustc::hir; |
b039eaaf | 24 | use syntax::attr; |
c34b1796 AL |
25 | |
26 | declare_lint!(CRATE_NOT_OKAY, Warn, "crate not marked with #![crate_okay]"); | |
27 | ||
28 | struct Pass; | |
29 | ||
30 | impl LintPass for Pass { | |
31 | fn get_lints(&self) -> LintArray { | |
32 | lint_array!(CRATE_NOT_OKAY) | |
33 | } | |
b039eaaf | 34 | } |
c34b1796 | 35 | |
476ff2be | 36 | impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { |
b039eaaf | 37 | fn check_crate(&mut self, cx: &LateContext, krate: &hir::Crate) { |
c34b1796 AL |
38 | if !attr::contains_name(&krate.attrs, "crate_okay") { |
39 | cx.span_lint(CRATE_NOT_OKAY, krate.span, | |
40 | "crate is not marked with #![crate_okay]"); | |
41 | } | |
42 | } | |
43 | } | |
44 | ||
45 | #[plugin_registrar] | |
46 | pub fn plugin_registrar(reg: &mut Registry) { | |
476ff2be | 47 | reg.register_late_lint_pass(box Pass); |
c34b1796 | 48 | } |