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

Commit 53e0eba

Browse files
committed
Fix CI, and use FxIndexSet
1 parent a226ebe commit 53e0eba

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

compiler/rustc_lint/src/levels.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_ast_pretty::pprust;
2-
use rustc_data_structures::{fx::FxIndexMap, sync::Lrc};
3-
use rustc_errors::{Diag, DiagMessage, LintDiagnostic, MultiSpan};
2+
use rustc_data_structures::{fx::FxIndexMap, fx::FxIndexSet, sync::Lrc};
3+
use rustc_errors::{Diag, LintDiagnostic, MultiSpan};
44
use rustc_feature::{Features, GateIssue};
55
use rustc_hir::intravisit::{self, Visitor};
66
use rustc_hir::HirId;
@@ -120,7 +120,7 @@ impl LintLevelSets {
120120
/// (and not allowed in the crate) and CLI lints. The returned value is a tuple
121121
/// of 1. The lints that will emit (or at least, should run), and 2.
122122
/// The lints that are allowed at the crate level and will not emit.
123-
pub fn lints_that_can_emit(tcx: TyCtxt<'_>, (): ()) -> Lrc<(Vec<String>, Vec<String>)> {
123+
pub fn lints_that_can_emit(tcx: TyCtxt<'_>, (): ()) -> Lrc<(FxIndexSet<String>, FxIndexSet<String>)> {
124124
let mut visitor = LintLevelMinimum::new(tcx);
125125
visitor.process_opts();
126126
tcx.hir().walk_attributes(&mut visitor);
@@ -133,11 +133,11 @@ pub fn lints_that_can_emit(tcx: TyCtxt<'_>, (): ()) -> Lrc<(Vec<String>, Vec<Str
133133
let group_name = name_without_tool(&binding).to_string();
134134
if visitor.lints_that_actually_run.contains(&group_name) {
135135
for lint in group.1 {
136-
visitor.lints_that_actually_run.push(name_without_tool(&lint.to_string()).to_string());
136+
visitor.lints_that_actually_run.insert(name_without_tool(&lint.to_string()).to_string());
137137
}
138138
} else if visitor.lints_allowed.contains(&group_name) {
139139
for lint in &group.1 {
140-
visitor.lints_allowed.push(name_without_tool(&lint.to_string()).to_string());
140+
visitor.lints_allowed.insert(name_without_tool(&lint.to_string()).to_string());
141141
}
142142
}
143143
}
@@ -347,20 +347,24 @@ struct LintLevelMinimum<'tcx> {
347347

348348
impl<'tcx> LintLevelMinimum<'tcx> {
349349
pub fn new(tcx: TyCtxt<'tcx>) -> Self {
350+
let mut lints_that_actually_run = FxIndexSet::default();
351+
lints_that_actually_run.reserve(230);
352+
let mut lints_allowed = FxIndexSet::default();
353+
lints_allowed.reserve(100);
350354
Self {
351355
tcx,
352356
// That magic number is the current number of lints + some more for possible future lints
353-
lints_that_actually_run: Vec::with_capacity(230),
354-
lints_allowed: Vec::with_capacity(100),
357+
lints_that_actually_run,
358+
lints_allowed,
355359
}
356360
}
357361

358362
fn process_opts(&mut self) {
359363
for (lint, level) in &self.tcx.sess.opts.lint_opts {
360364
if *level == Level::Allow {
361-
self.lints_allowed.push(lint.clone());
365+
self.lints_allowed.insert(lint.clone());
362366
} else {
363-
self.lints_that_actually_run.push(lint.to_string());
367+
self.lints_that_actually_run.insert(lint.to_string());
364368
}
365369
}
366370
}
@@ -385,13 +389,13 @@ impl<'tcx> Visitor<'tcx> for LintLevelMinimum<'tcx> {
385389
// If it's a tool lint (e.g. clippy::my_clippy_lint)
386390
if let ast::NestedMetaItem::MetaItem(meta_item) = meta_list {
387391
if meta_item.path.segments.len() == 1 {
388-
self.lints_that_actually_run.push(
392+
self.lints_that_actually_run.insert(
389393
// SAFETY: Lint attributes can only have literals
390394
meta_list.ident().unwrap().name.as_str().to_string(),
391395
);
392396
} else {
393397
self.lints_that_actually_run
394-
.push(meta_item.path.segments[1].ident.name.as_str().to_string());
398+
.insert(meta_item.path.segments[1].ident.name.as_str().to_string());
395399
}
396400
}
397401
}
@@ -403,10 +407,10 @@ impl<'tcx> Visitor<'tcx> for LintLevelMinimum<'tcx> {
403407
// If it's a tool lint (e.g. clippy::my_clippy_lint)
404408
if let ast::NestedMetaItem::MetaItem(meta_item) = meta_list {
405409
if meta_item.path.segments.len() == 1 {
406-
self.lints_allowed.push(meta_list.name_or_empty().as_str().to_string())
410+
self.lints_allowed.insert(meta_list.name_or_empty().as_str().to_string());
407411
} else {
408412
self.lints_allowed
409-
.push(meta_item.path.segments[1].ident.name.as_str().to_string());
413+
.insert(meta_item.path.segments[1].ident.name.as_str().to_string());
410414
}
411415
}
412416
}

compiler/rustc_lint/src/shadowed_into_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ declare_lint! {
6464
};
6565
}
6666

67-
#[derive(Copy, Clone)]
67+
#[derive(Copy, Clone, Default)]
6868
pub(crate) struct ShadowedIntoIter;
6969

7070
impl_lint_pass!(ShadowedIntoIter => [ARRAY_INTO_ITER, BOXED_SLICE_INTO_ITER]);

compiler/rustc_middle/src/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ rustc_queries! {
420420
desc { "computing `#[expect]`ed lints in this crate" }
421421
}
422422

423-
query lints_that_can_emit(_: ()) -> &'tcx Lrc<(Vec<String>, Vec<String>)> {
423+
query lints_that_can_emit(_: ()) -> &'tcx Lrc<(FxIndexSet<String>, FxIndexSet<String>)> {
424424
arena_cache
425425
desc { "Computing all lints that are explicitly enabled or with a default level greater than Allow" }
426426
}

0 commit comments

Comments
 (0)