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.
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.
13 #![feature(plugin_registrar, rustc_private)]
14 #![feature(box_syntax)]
16 #[macro_use] extern crate rustc;
17 extern crate rustc_front;
19 use rustc::lint::{Context, LintPass, LintPassObject, LintArray};
20 use rustc::plugin::Registry;
21 use rustc_front::{hir, attr};
23 declare_lint!(CRATE_NOT_OKAY, Warn, "crate not marked with #![crate_okay]");
27 impl LintPass for Pass {
28 fn get_lints(&self) -> LintArray {
29 lint_array!(CRATE_NOT_OKAY)
32 fn check_crate(&mut self, cx: &Context, krate: &hir::Crate) {
33 if !attr::contains_name(&krate.attrs, "crate_okay") {
34 cx.span_lint(CRATE_NOT_OKAY, krate.span,
35 "crate is not marked with #![crate_okay]");
41 pub fn plugin_registrar(reg: &mut Registry) {
42 reg.register_lint_pass(box Pass as LintPassObject);