Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a226ebe

Browse files
committed
Change lints_to_emit to lints_that_actually_run
1 parent 05dcfe3 commit a226ebe

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

compiler/rustc_lint/src/late.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
374374
store.late_module_passes.iter().map(|mk_pass| (mk_pass)(tcx)).collect();
375375

376376
// Filter unused lints
377-
let (lints_to_emit, lints_allowed) = &**tcx.lints_that_can_emit(());
378-
// let lints_to_emit = &lints_that_can_emit.0;
377+
let (lints_that_actually_run, lints_allowed) = &**tcx.lints_that_can_emit(());
378+
// let lints_that_actually_run = &lints_that_can_emit.0;
379379
// let lints_allowed = &lints_that_can_emit.1;
380380

381381
// Now, we'll filtered passes in a way that discards any lint that won't trigger.
@@ -387,7 +387,7 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
387387
let pass = LintPass::get_lints(pass);
388388
pass.iter().any(|&lint| {
389389
let lint_name = name_without_tool(&lint.name.to_lowercase()).to_string();
390-
lints_to_emit.contains(&lint_name)
390+
lints_that_actually_run.contains(&lint_name)
391391
|| (!lints_allowed.contains(&lint_name)
392392
&& lint.default_level != crate::Level::Allow)
393393
})

compiler/rustc_lint/src/levels.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ pub fn lints_that_can_emit(tcx: TyCtxt<'_>, (): ()) -> Lrc<(Vec<String>, Vec<Str
131131
for group in lint_groups {
132132
let binding = group.0.to_lowercase();
133133
let group_name = name_without_tool(&binding).to_string();
134-
if visitor.lints_to_emit.contains(&group_name) {
134+
if visitor.lints_that_actually_run.contains(&group_name) {
135135
for lint in group.1 {
136-
visitor.lints_to_emit.push(name_without_tool(&lint.to_string()).to_string());
136+
visitor.lints_that_actually_run.push(name_without_tool(&lint.to_string()).to_string());
137137
}
138138
} else if visitor.lints_allowed.contains(&group_name) {
139139
for lint in &group.1 {
@@ -142,7 +142,7 @@ pub fn lints_that_can_emit(tcx: TyCtxt<'_>, (): ()) -> Lrc<(Vec<String>, Vec<Str
142142
}
143143
}
144144

145-
Lrc::new((visitor.lints_to_emit, visitor.lints_allowed))
145+
Lrc::new((visitor.lints_that_actually_run, visitor.lints_allowed))
146146
}
147147

148148
#[instrument(level = "trace", skip(tcx), ret)]
@@ -341,16 +341,16 @@ impl<'tcx> Visitor<'tcx> for LintLevelsBuilder<'_, LintLevelQueryMap<'tcx>> {
341341
struct LintLevelMinimum<'tcx> {
342342
tcx: TyCtxt<'tcx>,
343343
/// The actual list of detected lints.
344-
lints_to_emit: Vec<String>,
345-
lints_allowed: Vec<String>,
344+
lints_that_actually_run: FxIndexSet<String>,
345+
lints_allowed: FxIndexSet<String>,
346346
}
347347

348348
impl<'tcx> LintLevelMinimum<'tcx> {
349349
pub fn new(tcx: TyCtxt<'tcx>) -> Self {
350350
Self {
351351
tcx,
352352
// That magic number is the current number of lints + some more for possible future lints
353-
lints_to_emit: Vec::with_capacity(230),
353+
lints_that_actually_run: Vec::with_capacity(230),
354354
lints_allowed: Vec::with_capacity(100),
355355
}
356356
}
@@ -360,7 +360,7 @@ impl<'tcx> LintLevelMinimum<'tcx> {
360360
if *level == Level::Allow {
361361
self.lints_allowed.push(lint.clone());
362362
} else {
363-
self.lints_to_emit.push(lint.to_string());
363+
self.lints_that_actually_run.push(lint.to_string());
364364
}
365365
}
366366
}
@@ -385,12 +385,12 @@ impl<'tcx> Visitor<'tcx> for LintLevelMinimum<'tcx> {
385385
// If it's a tool lint (e.g. clippy::my_clippy_lint)
386386
if let ast::NestedMetaItem::MetaItem(meta_item) = meta_list {
387387
if meta_item.path.segments.len() == 1 {
388-
self.lints_to_emit.push(
388+
self.lints_that_actually_run.push(
389389
// SAFETY: Lint attributes can only have literals
390390
meta_list.ident().unwrap().name.as_str().to_string(),
391391
);
392392
} else {
393-
self.lints_to_emit
393+
self.lints_that_actually_run
394394
.push(meta_item.path.segments[1].ident.name.as_str().to_string());
395395
}
396396
}

0 commit comments

Comments
 (0)