Skip to content

Commit 2aa9c6c

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 fbd6934 commit 2aa9c6c

11 files changed

Lines changed: 18 additions & 62 deletions

File tree

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
217217
output_dir: odir,
218218
ice_file,
219219
file_loader: None,
220-
lint_caps: Default::default(),
221220
psess_created: None,
222221
hash_untracked_state: None,
223222
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_data_structures::stable_hasher::StableHasher;
1010
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed};
@@ -19,7 +19,7 @@ use rustc_parse::parser::attr::AllowLeadingUnsafe;
1919
use rustc_query_impl::print_query_stack;
2020
use rustc_session::config::{self, Cfg, CheckCfg, ExpectedValues, Input, OutFileName};
2121
use rustc_session::parse::ParseSess;
22-
use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, lint};
22+
use rustc_session::{CompilerIO, EarlyDiagCtxt, Session};
2323
use rustc_span::source_map::{FileLoader, RealFileLoader, SourceMapInputs};
2424
use rustc_span::{FileName, sym};
2525
use rustc_target::spec::Target;
@@ -332,8 +332,6 @@ pub struct Config {
332332
/// running rustc without having to save". (See #102759.)
333333
pub file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
334334

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

@@ -454,7 +452,6 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
454452
temps_dir,
455453
},
456454
bundle,
457-
config.lint_caps,
458455
target,
459456
util::rustc_version_str().unwrap_or("unknown"),
460457
config.ice_file,

compiler/rustc_interface/src/tests.rs

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

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

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

compiler/rustc_middle/src/lint.rs

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

117-
if let Some(driver_level) = sess.driver_lint_caps.get(&lint) {
118-
// Ensure that we never exceed driver level.
119-
level = cmp::min(*driver_level, level);
120-
}
121-
122117
(level, lint_id)
123118
}
124119

compiler/rustc_session/src/session.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{env, io};
88
use rand::{RngCore, rng};
99
use rustc_data_structures::base_n::{CASE_INSENSITIVE, ToBaseN};
1010
use rustc_data_structures::flock;
11-
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
11+
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
1212
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
1313
use rustc_data_structures::sync::{DynSend, DynSync, Lock, MappedReadGuard, ReadGuard, RwLock};
1414
use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter;
@@ -109,9 +109,6 @@ pub struct Session {
109109
/// This only ever stores a `LintStore` but we don't want a dependency on that type here.
110110
pub lint_store: Option<Arc<dyn DynLintStore>>,
111111

112-
/// Cap lint level specified by a driver specifically.
113-
pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
114-
115112
/// Tracks the current behavior of the CTFE engine when an error occurs.
116113
/// Options range from returning the error without a backtrace to returning an error
117114
/// and immediately printing the backtrace to stderr.
@@ -985,7 +982,6 @@ pub fn build_session(
985982
sopts: config::Options,
986983
io: CompilerIO,
987984
fluent_bundle: Option<Arc<rustc_errors::FluentBundle>>,
988-
driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
989985
target: Target,
990986
cfg_version: &'static str,
991987
ice_file: Option<PathBuf>,
@@ -1094,7 +1090,6 @@ pub fn build_session(
10941090
timings,
10951091
code_stats: Default::default(),
10961092
lint_store: None,
1097-
driver_lint_caps,
10981093
ctfe_backtrace,
10991094
miri_unleashed_features: Lock::new(Default::default()),
11001095
asm_arch,

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

Lines changed: 5 additions & 6 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;
@@ -72,4 +71,4 @@ fn main() {
7271
}
7372
});
7473
});
75-
}
74+
}

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

Lines changed: 2 additions & 3 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(),
@@ -97,4 +96,4 @@ fn main() {
9796
buffer.lock().unwrap().iter().for_each(|diagnostic| {
9897
println!("{diagnostic:#?}");
9998
});
100-
}
99+
}

src/librustdoc/core.rs

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

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

@@ -289,7 +289,6 @@ pub(crate) fn create_config(
289289
output_file: None,
290290
output_dir: None,
291291
file_loader: None,
292-
lint_caps,
293292
psess_created: None,
294293
hash_untracked_state: None,
295294
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,
@@ -188,7 +188,6 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
188188
output_file: None,
189189
output_dir: None,
190190
file_loader: None,
191-
lint_caps,
192191
psess_created: None,
193192
hash_untracked_state: None,
194193
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)