diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index fc46102f6a30f..d3598efcbb09d 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -212,7 +212,6 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send)) output_dir: odir, ice_file, file_loader: None, - lint_caps: Default::default(), psess_created: None, hash_untracked_state: None, register_lints: None, diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 91b7f234d5f64..573925bccc795 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use rustc_ast::{LitKind, MetaItemKind, token}; use rustc_codegen_ssa::traits::CodegenBackend; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::jobserver::{self, Proxy}; use rustc_data_structures::stable_hasher::StableHasher; use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed}; @@ -19,7 +19,7 @@ use rustc_parse::parser::attr::AllowLeadingUnsafe; use rustc_query_impl::print_query_stack; use rustc_session::config::{self, Cfg, CheckCfg, ExpectedValues, Input, OutFileName}; use rustc_session::parse::ParseSess; -use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, lint}; +use rustc_session::{CompilerIO, EarlyDiagCtxt, Session}; use rustc_span::source_map::{FileLoader, RealFileLoader, SourceMapInputs}; use rustc_span::{FileName, sym}; use rustc_target::spec::Target; @@ -332,8 +332,6 @@ pub struct Config { /// running rustc without having to save". (See #102759.) pub file_loader: Option>, - pub lint_caps: FxHashMap, - /// This is a callback from the driver that is called when [`ParseSess`] is created. pub psess_created: Option>, @@ -443,7 +441,6 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se output_file: config.output_file, temps_dir, }, - config.lint_caps, target, util::rustc_version_str().unwrap_or("unknown"), config.ice_file, diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 88056a0db966d..72e92a289cda7 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -68,15 +68,7 @@ where static USING_INTERNAL_FEATURES: AtomicBool = AtomicBool::new(false); - let sess = build_session( - sessopts, - io, - Default::default(), - target, - "", - None, - &USING_INTERNAL_FEATURES, - ); + let sess = build_session(sessopts, io, target, "", None, &USING_INTERNAL_FEATURES); let cfg = parse_cfg(sess.dcx(), matches.opt_strs("cfg")); let cfg = build_configuration(&sess, cfg); f(sess, cfg) diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index f039799c3b7b6..4a4547e956dff 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -114,11 +114,6 @@ pub fn reveal_actual_level( cmp::min(level, sess.opts.lint_cap.unwrap_or(Level::Forbid)) }; - if let Some(driver_level) = sess.driver_lint_caps.get(&lint) { - // Ensure that we never exceed driver level. - level = cmp::min(*driver_level, level); - } - (level, lint_id) } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index dc18b05c75763..0eb629cbb83e2 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -8,7 +8,7 @@ use std::{env, io}; use rand::{RngCore, rng}; use rustc_data_structures::base_n::{CASE_INSENSITIVE, ToBaseN}; use rustc_data_structures::flock; -use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; +use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef}; use rustc_data_structures::sync::{DynSend, DynSync, Lock, MappedReadGuard, ReadGuard, RwLock}; use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter; @@ -108,9 +108,6 @@ pub struct Session { /// This only ever stores a `LintStore` but we don't want a dependency on that type here. pub lint_store: Option>, - /// Cap lint level specified by a driver specifically. - pub driver_lint_caps: FxHashMap, - /// Tracks the current behavior of the CTFE engine when an error occurs. /// Options range from returning the error without a backtrace to returning an error /// and immediately printing the backtrace to stderr. @@ -974,7 +971,6 @@ fn default_emitter(sopts: &config::Options, source_map: Arc) -> Box, target: Target, cfg_version: &'static str, ice_file: Option, @@ -1082,7 +1078,6 @@ pub fn build_session( timings, code_stats: Default::default(), lint_store: None, - driver_lint_caps, ctfe_backtrace, miri_unleashed_features: Lock::new(Default::default()), asm_arch, diff --git a/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs b/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs index b4439504650a1..0bd4b2e953482 100644 --- a/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs +++ b/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs @@ -28,12 +28,11 @@ fn main() { println!("{HELLO}"); } "# - .into(), + .into(), }, - output_dir: None, // Option - output_file: None, // Option - file_loader: None, // Option> - lint_caps: FxHashMap::default(), // FxHashMap + output_dir: None, // Option + output_file: None, // Option + file_loader: None, // Option> // This is a callback from the driver that is called when [`ParseSess`] is created. psess_created: None, //Option> // This is a callback from the driver that is called when we're registering lints; @@ -72,4 +71,4 @@ fn main() { } }); }); -} \ No newline at end of file +} diff --git a/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs b/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs index 342316ba670af..ceb611b422f52 100644 --- a/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs +++ b/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs @@ -59,14 +59,13 @@ fn main() { let x: &str = 1; } " - .into(), + .into(), }, crate_cfg: Vec::new(), crate_check_cfg: Vec::new(), output_dir: None, output_file: None, file_loader: None, - lint_caps: rustc_hash::FxHashMap::default(), psess_created: Some(Box::new(|parse_sess| { parse_sess.dcx().set_emitter(Box::new(DebugEmitter { source_map: parse_sess.clone_source_map(), @@ -97,4 +96,4 @@ fn main() { buffer.lock().unwrap().iter().for_each(|diagnostic| { println!("{diagnostic:#?}"); }); -} \ No newline at end of file +} diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 375f8338319b6..ce2018c981c49 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -237,7 +237,7 @@ pub(crate) fn create_config( ]; lints_to_show.extend(crate::lint::RUSTDOC_LINTS.iter().map(|lint| lint.name.to_string())); - let (lint_opts, lint_caps) = crate::lint::init_lints(lints_to_show, lint_opts, |lint| { + let lint_opts = crate::lint::init_lints(lints_to_show, lint_opts, |lint| { Some((lint.name_lower(), lint::Allow)) }); @@ -287,7 +287,6 @@ pub(crate) fn create_config( output_file: None, output_dir: None, file_loader: None, - lint_caps, psess_created: None, hash_untracked_state: None, register_lints: Some(Box::new(crate::lint::register_lints)), diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 5d3715c70e087..a8783915e3ee1 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -144,7 +144,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions lint::builtin::RENAMED_AND_REMOVED_LINTS.name.to_owned(), ]; - let (lint_opts, lint_caps) = init_lints(allowed_lints, options.lint_opts.clone(), |lint| { + let lint_opts = init_lints(allowed_lints, options.lint_opts.clone(), |lint| { if lint.name == invalid_codeblock_attributes_name { None } else { @@ -162,7 +162,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions search_paths: options.libs.clone(), crate_types, lint_opts, - lint_cap: Some(options.lint_cap.unwrap_or(lint::Forbid)), + lint_cap: None, cg: options.codegen_options.clone(), externs: options.externs.clone(), unstable_features: options.unstable_features, @@ -188,7 +188,6 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions output_file: None, output_dir: None, file_loader: None, - lint_caps, psess_created: None, hash_untracked_state: None, register_lints: Some(Box::new(crate::lint::register_lints)), diff --git a/src/librustdoc/lint.rs b/src/librustdoc/lint.rs index b09ea05688595..1a3e6d4bf51fb 100644 --- a/src/librustdoc/lint.rs +++ b/src/librustdoc/lint.rs @@ -1,6 +1,5 @@ use std::sync::LazyLock as Lazy; -use rustc_data_structures::fx::FxHashMap; use rustc_lint::LintStore; use rustc_lint_defs::{Lint, LintId, declare_tool_lint}; use rustc_session::{Session, lint}; @@ -14,14 +13,12 @@ use rustc_session::{Session, lint}; /// through the "WARNINGS" lint. To prevent this to happen, we set it back to its "normal" level /// inside this function. /// -/// It returns a tuple containing: -/// * Vector of tuples of lints' name and their associated "max" level -/// * HashMap of lint id with their associated "max" level +/// It returns a vector of tuples of lints' name and their associated "max" level pub(crate) fn init_lints( mut allowed_lints: Vec, lint_opts: Vec<(String, lint::Level)>, filter_call: F, -) -> (Vec<(String, lint::Level)>, FxHashMap) +) -> Vec<(String, lint::Level)> where F: Fn(&lint::Lint) -> Option<(String, lint::Level)>, { @@ -36,7 +33,7 @@ where .chain(rustc_lint::SoftLints::lint_vec()) }; - let lint_opts = lints() + lints() .filter_map(|lint| { // Permit feature-gated lints to avoid feature errors when trying to // allow all lints. @@ -47,20 +44,7 @@ where } }) .chain(lint_opts) - .collect::>(); - - let lint_caps = lints() - .filter_map(|lint| { - // We don't want to allow *all* lints so let's ignore - // those ones. - if allowed_lints.iter().any(|l| lint.name == l) { - None - } else { - Some((lint::LintId::of(lint), lint::Allow)) - } - }) - .collect(); - (lint_opts, lint_caps) + .collect::>() } macro_rules! declare_rustdoc_lint { diff --git a/tests/ui-fulldeps/run-compiler-twice.rs b/tests/ui-fulldeps/run-compiler-twice.rs index bd92cc6218f19..8acf0bd8905cb 100644 --- a/tests/ui-fulldeps/run-compiler-twice.rs +++ b/tests/ui-fulldeps/run-compiler-twice.rs @@ -64,7 +64,6 @@ fn compile(code: String, output: PathBuf, sysroot: Sysroot, linker: Option<&Path output_dir: None, ice_file: None, file_loader: None, - lint_caps: Default::default(), psess_created: None, hash_untracked_state: None, register_lints: None,