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