Skip to content

Commit 031197e

Browse files
committed
Remove driver_lint_caps
It was only used by rustdoc and doesn't seem like it was necessary there. No tests fail at least.
1 parent c8c4c83 commit 031197e

11 files changed

Lines changed: 16 additions & 59 deletions

File tree

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
212212
output_dir: odir,
213213
ice_file,
214214
file_loader: None,
215-
lint_caps: Default::default(),
216215
psess_created: None,
217216
track_state: None,
218217
register_lints: None,

compiler/rustc_interface/src/interface.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::sync::Arc;
44

55
use rustc_ast::{LitKind, MetaItemKind, token};
66
use rustc_codegen_ssa::traits::CodegenBackend;
7-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
7+
use rustc_data_structures::fx::FxHashSet;
88
use rustc_data_structures::jobserver::{self, Proxy};
99
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed};
1010
use rustc_lint::LintStore;
@@ -18,7 +18,7 @@ use rustc_parse::parser::attr::AllowLeadingUnsafe;
1818
use rustc_query_impl::print_query_stack;
1919
use rustc_session::config::{self, Cfg, CheckCfg, ExpectedValues, Input, OutFileName};
2020
use rustc_session::parse::ParseSess;
21-
use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, lint};
21+
use rustc_session::{CompilerIO, EarlyDiagCtxt, Session};
2222
use rustc_span::source_map::{FileLoader, RealFileLoader, SourceMapInputs};
2323
use rustc_span::{FileName, sym};
2424
use tracing::trace;
@@ -330,8 +330,6 @@ pub struct Config {
330330
/// running rustc without having to save". (See #102759.)
331331
pub file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
332332

333-
pub lint_caps: FxHashMap<lint::LintId, lint::Level>,
334-
335333
/// This is a callback from the driver that is called when [`ParseSess`] is created.
336334
pub psess_created: Option<Box<dyn FnOnce(&mut ParseSess) + Send>>,
337335

@@ -427,7 +425,6 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
427425
output_file: config.output_file,
428426
temps_dir,
429427
},
430-
config.lint_caps,
431428
target,
432429
util::rustc_version_str().unwrap_or("unknown"),
433430
config.ice_file,

compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,7 @@ where
6868

6969
static USING_INTERNAL_FEATURES: AtomicBool = AtomicBool::new(false);
7070

71-
let sess = build_session(
72-
sessopts,
73-
io,
74-
Default::default(),
75-
target,
76-
"",
77-
None,
78-
&USING_INTERNAL_FEATURES,
79-
);
71+
let sess = build_session(sessopts, io, target, "", None, &USING_INTERNAL_FEATURES);
8072
let cfg = parse_cfg(sess.dcx(), matches.opt_strs("cfg"));
8173
let cfg = build_configuration(&sess, cfg);
8274
f(sess, cfg)

compiler/rustc_middle/src/lint.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,6 @@ pub fn reveal_actual_level(
128128
cmp::min(level, sess.opts.lint_cap.unwrap_or(Level::Forbid))
129129
};
130130

131-
if let Some(driver_level) = sess.driver_lint_caps.get(&lint) {
132-
// Ensure that we never exceed driver level.
133-
level = cmp::min(*driver_level, level);
134-
}
135-
136131
(level, lint_id)
137132
}
138133

compiler/rustc_session/src/session.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize};
66
use std::{env, io};
77

88
use rustc_data_structures::flock;
9-
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
9+
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
1010
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
1111
use rustc_data_structures::sync::{
1212
AppendOnlyVec, DynSend, DynSync, Lock, MappedReadGuard, ReadGuard, RwLock,
@@ -117,9 +117,6 @@ pub struct Session {
117117
/// This only ever stores a `LintStore` but we don't want a dependency on that type here.
118118
pub lint_store: Option<Arc<dyn DynLintStore>>,
119119

120-
/// Cap lint level specified by a driver specifically.
121-
pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
122-
123120
/// Tracks the current behavior of the CTFE engine when an error occurs.
124121
/// Options range from returning the error without a backtrace to returning an error
125122
/// and immediately printing the backtrace to stderr.
@@ -1001,7 +998,6 @@ fn default_emitter(sopts: &config::Options, source_map: Arc<SourceMap>) -> Box<D
1001998
pub fn build_session(
1002999
sopts: config::Options,
10031000
io: CompilerIO,
1004-
driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
10051001
target: Target,
10061002
cfg_version: &'static str,
10071003
ice_file: Option<PathBuf>,
@@ -1107,7 +1103,6 @@ pub fn build_session(
11071103
timings,
11081104
code_stats: Default::default(),
11091105
lint_store: None,
1110-
driver_lint_caps,
11111106
ctfe_backtrace,
11121107
miri_unleashed_features: Lock::new(Default::default()),
11131108
asm_arch,

src/doc/rustc-dev-guide/examples/rustc-interface-example.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ fn main() {
2828
println!("{HELLO}");
2929
}
3030
"#
31-
.into(),
31+
.into(),
3232
},
33-
output_dir: None, // Option<PathBuf>
34-
output_file: None, // Option<PathBuf>
35-
file_loader: None, // Option<Box<dyn FileLoader + Send + Sync>>
36-
lint_caps: FxHashMap::default(), // FxHashMap<lint::LintId, lint::Level>
33+
output_dir: None, // Option<PathBuf>
34+
output_file: None, // Option<PathBuf>
35+
file_loader: None, // Option<Box<dyn FileLoader + Send + Sync>>
3736
// This is a callback from the driver that is called when [`ParseSess`] is created.
3837
psess_created: None, //Option<Box<dyn FnOnce(&mut ParseSess) + Send>>
3938
// This is a callback from the driver that is called when we're registering lints;

src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,13 @@ fn main() {
5959
let x: &str = 1;
6060
}
6161
"
62-
.into(),
62+
.into(),
6363
},
6464
crate_cfg: Vec::new(),
6565
crate_check_cfg: Vec::new(),
6666
output_dir: None,
6767
output_file: None,
6868
file_loader: None,
69-
lint_caps: rustc_hash::FxHashMap::default(),
7069
psess_created: Some(Box::new(|parse_sess| {
7170
parse_sess.dcx().set_emitter(Box::new(DebugEmitter {
7271
source_map: parse_sess.clone_source_map(),

src/librustdoc/core.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ pub(crate) fn create_config(
238238
];
239239
lints_to_show.extend(crate::lint::RUSTDOC_LINTS.iter().map(|lint| lint.name.to_string()));
240240

241-
let (lint_opts, lint_caps) = crate::lint::init_lints(lints_to_show, lint_opts, |lint| {
241+
let lint_opts = crate::lint::init_lints(lints_to_show, lint_opts, |lint| {
242242
Some((lint.name_lower(), lint::Allow))
243243
});
244244

@@ -293,7 +293,6 @@ pub(crate) fn create_config(
293293
Some(render_options.output.clone())
294294
},
295295
file_loader: None,
296-
lint_caps,
297296
psess_created: None,
298297
track_state: None,
299298
register_lints: Some(Box::new(crate::lint::register_lints)),

src/librustdoc/doctest.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
144144
lint::builtin::RENAMED_AND_REMOVED_LINTS.name.to_owned(),
145145
];
146146

147-
let (lint_opts, lint_caps) = init_lints(allowed_lints, options.lint_opts.clone(), |lint| {
147+
let lint_opts = init_lints(allowed_lints, options.lint_opts.clone(), |lint| {
148148
if lint.name == invalid_codeblock_attributes_name {
149149
None
150150
} else {
@@ -162,7 +162,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
162162
search_paths: options.libs.clone(),
163163
crate_types,
164164
lint_opts,
165-
lint_cap: Some(options.lint_cap.unwrap_or(lint::Forbid)),
165+
lint_cap: None,
166166
cg: options.codegen_options.clone(),
167167
externs: options.externs.clone(),
168168
unstable_features: options.unstable_features,
@@ -189,7 +189,6 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
189189
output_file: None,
190190
output_dir: None,
191191
file_loader: None,
192-
lint_caps,
193192
psess_created: None,
194193
track_state: None,
195194
register_lints: Some(Box::new(crate::lint::register_lints)),

src/librustdoc/lint.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::sync::LazyLock as Lazy;
22

3-
use rustc_data_structures::fx::FxHashMap;
43
use rustc_lint::LintStore;
54
use rustc_lint_defs::{Lint, LintId, declare_tool_lint};
65
use rustc_session::{Session, lint};
@@ -14,14 +13,12 @@ use rustc_session::{Session, lint};
1413
/// through the "WARNINGS" lint. To prevent this to happen, we set it back to its "normal" level
1514
/// inside this function.
1615
///
17-
/// It returns a tuple containing:
18-
/// * Vector of tuples of lints' name and their associated "max" level
19-
/// * HashMap of lint id with their associated "max" level
16+
/// It returns a vector of tuples of lints' name and their associated "max" level
2017
pub(crate) fn init_lints<F>(
2118
mut allowed_lints: Vec<String>,
2219
lint_opts: Vec<(String, lint::Level)>,
2320
filter_call: F,
24-
) -> (Vec<(String, lint::Level)>, FxHashMap<lint::LintId, lint::Level>)
21+
) -> Vec<(String, lint::Level)>
2522
where
2623
F: Fn(&lint::Lint) -> Option<(String, lint::Level)>,
2724
{
@@ -36,7 +33,7 @@ where
3633
.chain(rustc_lint::SoftLints::lint_vec())
3734
};
3835

39-
let lint_opts = lints()
36+
lints()
4037
.filter_map(|lint| {
4138
// Permit feature-gated lints to avoid feature errors when trying to
4239
// allow all lints.
@@ -47,20 +44,7 @@ where
4744
}
4845
})
4946
.chain(lint_opts)
50-
.collect::<Vec<_>>();
51-
52-
let lint_caps = lints()
53-
.filter_map(|lint| {
54-
// We don't want to allow *all* lints so let's ignore
55-
// those ones.
56-
if allowed_lints.iter().any(|l| lint.name == l) {
57-
None
58-
} else {
59-
Some((lint::LintId::of(lint), lint::Allow))
60-
}
61-
})
62-
.collect();
63-
(lint_opts, lint_caps)
47+
.collect::<Vec<_>>()
6448
}
6549

6650
macro_rules! declare_rustdoc_lint {

0 commit comments

Comments
 (0)