X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fdriver.rs;h=0c82f37d6a22e32572c15956bdf6ecd7e0c32d80;hb=a9e9b7f9b2ad52035fe7b57bb0fc8ba62d649c33;hp=30272c9b8006870747e1ce53704ce7c2f4248e4c;hpb=f2f2a005b4efd3e44ac6a02ea2b9660d28401679;p=rust.git diff --git a/src/driver.rs b/src/driver.rs index 30272c9b800..0c82f37d6a2 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -4,7 +4,7 @@ // warn on lints, that are included in `rust-lang/rust`s bootstrap #![warn(rust_2018_idioms, unused_lifetimes)] // warn on rustc internal lints -#![deny(rustc::internal)] +#![warn(rustc::internal)] // FIXME: switch to something more ergonomic here, once available. // (Currently there is no way to opt into sysroot crates without `extern crate`.) @@ -15,7 +15,7 @@ extern crate rustc_span; use rustc_interface::interface; -use rustc_session::Session; +use rustc_session::parse::ParseSess; use rustc_span::symbol::Symbol; use rustc_tools_util::VersionInfo; @@ -63,8 +63,8 @@ fn test_arg_value() { assert_eq!(arg_value(args, "--foo", |_| true), None); } -fn track_clippy_args(sess: &Session, args_env_var: &Option) { - sess.parse_sess.env_depinfo.borrow_mut().insert(( +fn track_clippy_args(parse_sess: &mut ParseSess, args_env_var: &Option) { + parse_sess.env_depinfo.get_mut().insert(( Symbol::intern("CLIPPY_ARGS"), args_env_var.as_deref().map(Symbol::intern), )); @@ -81,14 +81,9 @@ struct RustcCallbacks { impl rustc_driver::Callbacks for RustcCallbacks { fn config(&mut self, config: &mut interface::Config) { - let previous = config.register_lints.take(); let clippy_args_var = self.clippy_args_var.take(); - config.register_lints = Some(Box::new(move |sess, lint_store| { - if let Some(ref previous) = previous { - (previous)(sess, lint_store); - } - - track_clippy_args(sess, &clippy_args_var); + config.parse_sess_created = Some(Box::new(move |parse_sess| { + track_clippy_args(parse_sess, &clippy_args_var); })); } } @@ -101,19 +96,20 @@ impl rustc_driver::Callbacks for ClippyCallbacks { fn config(&mut self, config: &mut interface::Config) { let previous = config.register_lints.take(); let clippy_args_var = self.clippy_args_var.take(); - config.register_lints = Some(Box::new(move |sess, mut lint_store| { + config.parse_sess_created = Some(Box::new(move |parse_sess| { + track_clippy_args(parse_sess, &clippy_args_var); + })); + config.register_lints = Some(Box::new(move |sess, lint_store| { // technically we're ~guaranteed that this is none but might as well call anything that // is there already. Certainly it can't hurt. if let Some(previous) = &previous { (previous)(sess, lint_store); } - track_clippy_args(sess, &clippy_args_var); - - let conf = clippy_lints::read_conf(&[], &sess); - clippy_lints::register_plugins(&mut lint_store, &sess, &conf); - clippy_lints::register_pre_expansion_lints(&mut lint_store); - clippy_lints::register_renamed(&mut lint_store); + let conf = clippy_lints::read_conf(sess); + clippy_lints::register_plugins(lint_store, sess, &conf); + clippy_lints::register_pre_expansion_lints(lint_store); + clippy_lints::register_renamed(lint_store); })); // FIXME: #4825; This is required, because Clippy lints that are based on MIR have to be @@ -195,7 +191,7 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { ]; for note in &xs { - handler.note_without_error(¬e); + handler.note_without_error(note); } // If backtraces are enabled, also print the query stack