]> git.lizzy.rs Git - rust.git/blob - src/test/ui-fulldeps/auxiliary/lint-for-crate.rs
Rollup merge of #65613 - Mark-Simulacrum:rustdoc-preserve-ws, r=GuillaumeGomez
[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 extern crate rustc_driver;
8 extern crate syntax;
9
10 use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LintArray};
11 use rustc_driver::plugin::Registry;
12 use rustc::hir;
13 use syntax::attr;
14 use syntax::symbol::Symbol;
15
16 declare_lint! {
17     CRATE_NOT_OKAY,
18     Warn,
19     "crate not marked with #![crate_okay]"
20 }
21
22 declare_lint_pass!(Pass => [CRATE_NOT_OKAY]);
23
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]");
29         }
30     }
31 }
32
33 #[plugin_registrar]
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);
37 }