3 #![feature(plugin_registrar, rustc_private)]
4 #![feature(box_syntax)]
6 #[macro_use] extern crate rustc;
7 #[macro_use] extern crate rustc_session;
8 extern crate rustc_driver;
9 extern crate rustc_hir;
10 extern crate rustc_span;
13 use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LintArray};
14 use rustc_driver::plugin::Registry;
15 use rustc_span::symbol::Symbol;
21 "crate not marked with #![crate_okay]"
24 declare_lint_pass!(Pass => [CRATE_NOT_OKAY]);
26 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
27 fn check_crate(&mut self, cx: &LateContext, krate: &rustc_hir::Crate) {
28 if !attr::contains_name(&krate.attrs, Symbol::intern("crate_okay")) {
29 cx.span_lint(CRATE_NOT_OKAY, krate.span,
30 "crate is not marked with #![crate_okay]");
36 pub fn plugin_registrar(reg: &mut Registry) {
37 reg.lint_store.register_lints(&[&CRATE_NOT_OKAY]);
38 reg.lint_store.register_late_pass(|| box Pass);