]> git.lizzy.rs Git - rust.git/blob - src/test/ui-fulldeps/auxiliary/lint-for-crate.rs
Rollup merge of #66863 - osa1:fix_66702, r=cramertj
[rust.git] / src / test / ui-fulldeps / auxiliary / lint-for-crate.rs
1 // force-host
2
3 #![feature(plugin_registrar, rustc_private)]
4 #![feature(box_syntax)]
5
6 #[macro_use] extern crate rustc;
7 #[macro_use] extern crate rustc_session;
8 extern crate rustc_driver;
9 extern crate syntax;
10
11 use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LintArray};
12 use rustc_driver::plugin::Registry;
13 use rustc::hir;
14 use syntax::attr;
15 use syntax::symbol::Symbol;
16
17 declare_lint! {
18     CRATE_NOT_OKAY,
19     Warn,
20     "crate not marked with #![crate_okay]"
21 }
22
23 declare_lint_pass!(Pass => [CRATE_NOT_OKAY]);
24
25 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
26     fn check_crate(&mut self, cx: &LateContext, krate: &hir::Crate) {
27         if !attr::contains_name(&krate.attrs, Symbol::intern("crate_okay")) {
28             cx.span_lint(CRATE_NOT_OKAY, krate.span,
29                          "crate is not marked with #![crate_okay]");
30         }
31     }
32 }
33
34 #[plugin_registrar]
35 pub fn plugin_registrar(reg: &mut Registry) {
36     reg.lint_store.register_lints(&[&CRATE_NOT_OKAY]);
37     reg.lint_store.register_late_pass(|| box Pass);
38 }