Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_interface/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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;
Expand Down Expand Up @@ -332,8 +332,6 @@ pub struct Config {
/// running rustc without having to save". (See #102759.)
pub file_loader: Option<Box<dyn FileLoader + Send + Sync>>,

pub lint_caps: FxHashMap<lint::LintId, lint::Level>,

/// This is a callback from the driver that is called when [`ParseSess`] is created.
pub psess_created: Option<Box<dyn FnOnce(&mut ParseSess) + Send>>,

Expand Down Expand Up @@ -443,7 +441,6 @@ pub fn run_compiler<R: Send>(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,
Expand Down
10 changes: 1 addition & 9 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Arc<dyn DynLintStore>>,

/// Cap lint level specified by a driver specifically.
pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,

/// 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.
Expand Down Expand Up @@ -974,7 +971,6 @@ fn default_emitter(sopts: &config::Options, source_map: Arc<SourceMap>) -> Box<D
pub fn build_session(
sopts: config::Options,
io: CompilerIO,
driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
target: Target,
cfg_version: &'static str,
ice_file: Option<PathBuf>,
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 5 additions & 6 deletions src/doc/rustc-dev-guide/examples/rustc-interface-example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ fn main() {
println!("{HELLO}");
}
"#
.into(),
.into(),
},
output_dir: None, // Option<PathBuf>
output_file: None, // Option<PathBuf>
file_loader: None, // Option<Box<dyn FileLoader + Send + Sync>>
lint_caps: FxHashMap::default(), // FxHashMap<lint::LintId, lint::Level>
output_dir: None, // Option<PathBuf>
output_file: None, // Option<PathBuf>
file_loader: None, // Option<Box<dyn FileLoader + Send + Sync>>
// This is a callback from the driver that is called when [`ParseSess`] is created.
psess_created: None, //Option<Box<dyn FnOnce(&mut ParseSess) + Send>>
// This is a callback from the driver that is called when we're registering lints;
Expand Down Expand Up @@ -72,4 +71,4 @@ fn main() {
}
});
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -97,4 +96,4 @@ fn main() {
buffer.lock().unwrap().iter().for_each(|diagnostic| {
println!("{diagnostic:#?}");
});
}
}
3 changes: 1 addition & 2 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
});

Expand Down Expand Up @@ -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)),
Expand Down
5 changes: 2 additions & 3 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand All @@ -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)),
Expand Down
24 changes: 4 additions & 20 deletions src/librustdoc/lint.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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<F>(
mut allowed_lints: Vec<String>,
lint_opts: Vec<(String, lint::Level)>,
filter_call: F,
) -> (Vec<(String, lint::Level)>, FxHashMap<lint::LintId, lint::Level>)
) -> Vec<(String, lint::Level)>
where
F: Fn(&lint::Lint) -> Option<(String, lint::Level)>,
{
Expand All @@ -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.
Expand All @@ -47,20 +44,7 @@ where
}
})
.chain(lint_opts)
.collect::<Vec<_>>();

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::<Vec<_>>()
}

macro_rules! declare_rustdoc_lint {
Expand Down
1 change: 0 additions & 1 deletion tests/ui-fulldeps/run-compiler-twice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading