Skip to content

Commit f58db20

Browse files
committed
move rustc::lint::{context, passes} to rustc_lint.
Also do some cleanup of the interface.
1 parent 8c12c42 commit f58db20

File tree

24 files changed

+505
-513
lines changed

24 files changed

+505
-513
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3789,6 +3789,7 @@ dependencies = [
37893789
"rustc_error_codes",
37903790
"rustc_errors",
37913791
"rustc_hir",
3792+
"rustc_lint",
37923793
"rustc_metadata",
37933794
"rustc_span",
37943795
"syntax",

src/librustc/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ extern crate rustc_data_structures;
7272
#[macro_use]
7373
extern crate log;
7474
#[macro_use]
75-
extern crate syntax;
76-
#[macro_use]
7775
extern crate smallvec;
7876

7977
#[cfg(test)]

src/librustc/lint.rs

Lines changed: 49 additions & 394 deletions
Large diffs are not rendered by default.

src/librustc_ast_lowering/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ use rustc::arena::Arena;
3737
use rustc::dep_graph::DepGraph;
3838
use rustc::hir::map::definitions::{DefKey, DefPathData, Definitions};
3939
use rustc::hir::map::Map;
40-
use rustc::lint::builtin;
4140
use rustc::{bug, span_bug};
4241
use rustc_data_structures::captures::Captures;
4342
use rustc_data_structures::fx::FxHashSet;
@@ -51,7 +50,7 @@ use rustc_hir::intravisit;
5150
use rustc_hir::{ConstArg, GenericArg, ParamName};
5251
use rustc_index::vec::IndexVec;
5352
use rustc_session::config::nightly_options;
54-
use rustc_session::lint::{BuiltinLintDiagnostics, LintBuffer};
53+
use rustc_session::lint::{builtin, BuiltinLintDiagnostics, LintBuffer};
5554
use rustc_session::node_id::NodeMap;
5655
use rustc_session::Session;
5756
use rustc_span::hygiene::ExpnId;

src/librustc_driver/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ extern crate lazy_static;
2323

2424
pub extern crate rustc_plugin_impl as plugin;
2525

26-
//use rustc_resolve as resolve;
27-
use rustc::lint;
28-
use rustc::lint::Lint;
26+
use rustc::lint::{Lint, LintId};
2927
use rustc::middle::cstore::MetadataLoader;
3028
use rustc::session::config::nightly_options;
3129
use rustc::session::config::{ErrorOutputType, Input, OutputType, PrintRequest};
@@ -41,6 +39,7 @@ use rustc_feature::{find_gated_cfg, UnstableFeatures};
4139
use rustc_hir::def_id::LOCAL_CRATE;
4240
use rustc_interface::util::get_builtin_codegen_backend;
4341
use rustc_interface::{interface, Queries};
42+
use rustc_lint::LintStore;
4443
use rustc_metadata::locator;
4544
use rustc_save_analysis as save;
4645
use rustc_save_analysis::DumpHandler;
@@ -811,7 +810,7 @@ the command line flag directly.
811810
);
812811
}
813812

814-
fn describe_lints(sess: &Session, lint_store: &lint::LintStore, loaded_plugins: bool) {
813+
fn describe_lints(sess: &Session, lint_store: &LintStore, loaded_plugins: bool) {
815814
println!(
816815
"
817816
Available lint options:
@@ -832,8 +831,8 @@ Available lint options:
832831
}
833832

834833
fn sort_lint_groups(
835-
lints: Vec<(&'static str, Vec<lint::LintId>, bool)>,
836-
) -> Vec<(&'static str, Vec<lint::LintId>)> {
834+
lints: Vec<(&'static str, Vec<LintId>, bool)>,
835+
) -> Vec<(&'static str, Vec<LintId>)> {
837836
let mut lints: Vec<_> = lints.into_iter().map(|(x, y, _)| (x, y)).collect();
838837
lints.sort_by_key(|l| l.0);
839838
lints
@@ -892,7 +891,7 @@ Available lint options:
892891
println!(" {} {}", padded("----"), "---------");
893892
println!(" {} {}", padded("warnings"), "all lints that are set to issue warnings");
894893

895-
let print_lint_groups = |lints: Vec<(&'static str, Vec<lint::LintId>)>| {
894+
let print_lint_groups = |lints: Vec<(&'static str, Vec<LintId>)>| {
896895
for (name, to) in lints {
897896
let name = name.to_lowercase().replace("_", "-");
898897
let desc = to

src/librustc_interface/interface.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1212
use rustc_data_structures::sync::Lrc;
1313
use rustc_data_structures::OnDrop;
1414
use rustc_errors::registry::Registry;
15+
use rustc_lint::LintStore;
1516
use rustc_parse::new_parser_from_source_str;
1617
use rustc_span::edition;
1718
use rustc_span::source_map::{FileLoader, FileName, SourceMap};
@@ -36,7 +37,7 @@ pub struct Compiler {
3637
pub(crate) output_dir: Option<PathBuf>,
3738
pub(crate) output_file: Option<PathBuf>,
3839
pub(crate) crate_name: Option<String>,
39-
pub(crate) register_lints: Option<Box<dyn Fn(&Session, &mut lint::LintStore) + Send + Sync>>,
40+
pub(crate) register_lints: Option<Box<dyn Fn(&Session, &mut LintStore) + Send + Sync>>,
4041
pub(crate) override_queries:
4142
Option<fn(&Session, &mut ty::query::Providers<'_>, &mut ty::query::Providers<'_>)>,
4243
}
@@ -136,7 +137,7 @@ pub struct Config {
136137
///
137138
/// Note that if you find a Some here you probably want to call that function in the new
138139
/// function being registered.
139-
pub register_lints: Option<Box<dyn Fn(&Session, &mut lint::LintStore) + Send + Sync>>,
140+
pub register_lints: Option<Box<dyn Fn(&Session, &mut LintStore) + Send + Sync>>,
140141

141142
/// This is a callback from the driver that is called just after we have populated
142143
/// the list of queries.

src/librustc_interface/passes.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use rustc_errors::PResult;
2727
use rustc_expand::base::ExtCtxt;
2828
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
2929
use rustc_incremental;
30+
use rustc_lint::LintStore;
3031
use rustc_mir as mir;
3132
use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str};
3233
use rustc_passes::{self, hir_stats, layout_test};
@@ -100,7 +101,7 @@ declare_box_region_type!(
100101
/// Returns `None` if we're aborting after handling -W help.
101102
pub fn configure_and_expand(
102103
sess: Lrc<Session>,
103-
lint_store: Lrc<lint::LintStore>,
104+
lint_store: Lrc<LintStore>,
104105
metadata_loader: Box<MetadataLoaderDyn>,
105106
krate: ast::Crate,
106107
crate_name: &str,
@@ -150,10 +151,10 @@ impl BoxedResolver {
150151
pub fn register_plugins<'a>(
151152
sess: &'a Session,
152153
metadata_loader: &'a dyn MetadataLoader,
153-
register_lints: impl Fn(&Session, &mut lint::LintStore),
154+
register_lints: impl Fn(&Session, &mut LintStore),
154155
mut krate: ast::Crate,
155156
crate_name: &str,
156-
) -> Result<(ast::Crate, Lrc<lint::LintStore>)> {
157+
) -> Result<(ast::Crate, Lrc<LintStore>)> {
157158
krate = sess.time("attributes_injection", || {
158159
rustc_builtin_macros::cmdline_attrs::inject(
159160
krate,
@@ -214,7 +215,7 @@ pub fn register_plugins<'a>(
214215

215216
fn configure_and_expand_inner<'a>(
216217
sess: &'a Session,
217-
lint_store: &'a lint::LintStore,
218+
lint_store: &'a LintStore,
218219
mut krate: ast::Crate,
219220
crate_name: &str,
220221
resolver_arenas: &'a ResolverArenas<'a>,
@@ -420,7 +421,7 @@ fn configure_and_expand_inner<'a>(
420421

421422
pub fn lower_to_hir<'res, 'tcx>(
422423
sess: &'tcx Session,
423-
lint_store: &lint::LintStore,
424+
lint_store: &LintStore,
424425
resolver: &'res mut Resolver<'_>,
425426
dep_graph: &'res DepGraph,
426427
krate: &'res ast::Crate,
@@ -705,7 +706,7 @@ impl<'tcx> QueryContext<'tcx> {
705706

706707
pub fn create_global_ctxt<'tcx>(
707708
compiler: &'tcx Compiler,
708-
lint_store: Lrc<lint::LintStore>,
709+
lint_store: Lrc<LintStore>,
709710
hir_forest: &'tcx map::Forest<'tcx>,
710711
mut resolver_outputs: ResolverOutputs,
711712
outputs: OutputFilenames,

src/librustc_interface/queries.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use crate::passes::{self, BoxedResolver, QueryContext};
44
use rustc::arena::Arena;
55
use rustc::dep_graph::DepGraph;
66
use rustc::hir::map;
7-
use rustc::lint;
8-
use rustc::lint::LintStore;
97
use rustc::session::config::{OutputFilenames, OutputType};
108
use rustc::session::Session;
119
use rustc::ty::steal::Steal;
@@ -15,6 +13,7 @@ use rustc_codegen_utils::codegen_backend::CodegenBackend;
1513
use rustc_data_structures::sync::{Lrc, Once, WorkerLocal};
1614
use rustc_hir::def_id::LOCAL_CRATE;
1715
use rustc_incremental::DepGraphFuture;
16+
use rustc_lint::LintStore;
1817
use std::any::Any;
1918
use std::cell::{Ref, RefCell, RefMut};
2019
use std::mem;
@@ -133,7 +132,7 @@ impl<'tcx> Queries<'tcx> {
133132
let crate_name = self.crate_name()?.peek().clone();
134133
let krate = self.parse()?.take();
135134

136-
let empty: &(dyn Fn(&Session, &mut lint::LintStore) + Sync + Send) = &|_, _| {};
135+
let empty: &(dyn Fn(&Session, &mut LintStore) + Sync + Send) = &|_, _| {};
137136
let result = passes::register_plugins(
138137
self.session(),
139138
&*self.codegen_backend().metadata_loader(),

src/librustc_lint/array_into_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc::lint::{LateContext, LateLintPass, LintContext};
1+
use crate::{LateContext, LateLintPass, LintContext};
22
use rustc::ty;
33
use rustc::ty::adjustment::{Adjust, Adjustment};
44
use rustc_errors::Applicability;

src/librustc_lint/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
//! If you define a new `LateLintPass`, you will also need to add it to the
2222
//! `late_lint_methods!` invocation in `lib.rs`.
2323
24+
use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
2425
use rustc::hir::map::Map;
25-
use rustc::lint::{self, EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
2626
use rustc::traits::misc::can_type_implement_copy;
2727
use rustc::ty::{self, layout::VariantIdx, Ty, TyCtxt};
2828
use rustc_data_structures::fx::FxHashSet;
@@ -51,7 +51,7 @@ use log::debug;
5151
use std::fmt::Write;
5252

5353
// hardwired lints from librustc
54-
pub use lint::builtin::*;
54+
pub use rustc_session::lint::builtin::*;
5555

5656
declare_lint! {
5757
WHILE_TRUE,

0 commit comments

Comments
 (0)