Skip to content

Commit f9fd7f7

Browse files
committed
Rename DeadItem::level
The name is misleading because the field contains a `Level` *and* an `Option<LintExpectationId>`. This commit renames it `level_plus` which better communicates that it's more than just a level.
1 parent ccfac54 commit f9fd7f7

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

compiler/rustc_passes/src/dead.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ fn mark_live_symbols_and_ignored_derived_traits(
10351035
struct DeadItem {
10361036
def_id: LocalDefId,
10371037
name: Symbol,
1038-
level: (lint::Level, Option<LintExpectationId>),
1038+
level_plus: (lint::Level, Option<LintExpectationId>),
10391039
}
10401040

10411041
struct DeadVisitor<'tcx> {
@@ -1082,7 +1082,7 @@ impl<'tcx> DeadVisitor<'tcx> {
10821082
ShouldWarnAboutField::Yes
10831083
}
10841084

1085-
fn def_lint_level(&self, id: LocalDefId) -> (lint::Level, Option<LintExpectationId>) {
1085+
fn def_lint_level_plus(&self, id: LocalDefId) -> (lint::Level, Option<LintExpectationId>) {
10861086
let hir_id = self.tcx.local_def_id_to_hir_id(id);
10871087
let level_spec = self.tcx.lint_level_spec_at_node(self.target_lint, hir_id);
10881088
(level_spec.level, level_spec.lint_id)
@@ -1108,8 +1108,8 @@ impl<'tcx> DeadVisitor<'tcx> {
11081108
let Some(&first_item) = dead_codes.first() else { return };
11091109
let tcx = self.tcx;
11101110

1111-
let first_lint_level = first_item.level;
1112-
assert!(dead_codes.iter().skip(1).all(|item| item.level == first_lint_level));
1111+
let first_lint_level_plus = first_item.level_plus;
1112+
assert!(dead_codes.iter().skip(1).all(|item| item.level_plus == first_lint_level_plus));
11131113

11141114
let names: Vec<_> = dead_codes.iter().map(|item| item.name).collect();
11151115
let spans: Vec<_> = dead_codes
@@ -1266,9 +1266,10 @@ impl<'tcx> DeadVisitor<'tcx> {
12661266
if dead_codes.is_empty() {
12671267
return;
12681268
}
1269-
// FIXME: `dead_codes` should probably be morally equivalent to `IndexMap<(Level, LintExpectationId), (DefId, Symbol)>`
1270-
dead_codes.sort_by_key(|v| v.level.0);
1271-
for group in dead_codes.chunk_by(|a, b| a.level == b.level) {
1269+
// FIXME: `dead_codes` should probably be morally equivalent to
1270+
// `IndexMap<(Level, LintExpectationId), (DefId, Symbol)>`
1271+
dead_codes.sort_by_key(|v| v.level_plus.0);
1272+
for group in dead_codes.chunk_by(|a, b| a.level_plus == b.level_plus) {
12721273
self.lint_at_single_level(&group, participle, Some(def_id), report_on);
12731274
}
12741275
}
@@ -1277,7 +1278,7 @@ impl<'tcx> DeadVisitor<'tcx> {
12771278
let item = DeadItem {
12781279
def_id: id,
12791280
name: self.tcx.item_name(id.to_def_id()),
1280-
level: self.def_lint_level(id),
1281+
level_plus: self.def_lint_level_plus(id),
12811282
};
12821283
self.lint_at_single_level(&[&item], participle, None, ReportOn::NamedField);
12831284
}
@@ -1381,8 +1382,8 @@ fn lint_dead_codes<'tcx>(
13811382
&& !visitor.is_live_code(local_def_id)
13821383
{
13831384
let name = tcx.item_name(def_id);
1384-
let level = visitor.def_lint_level(local_def_id);
1385-
dead_codes.push(DeadItem { def_id: local_def_id, name, level });
1385+
let level_plus = visitor.def_lint_level_plus(local_def_id);
1386+
dead_codes.push(DeadItem { def_id: local_def_id, name, level_plus });
13861387
}
13871388
}
13881389
}
@@ -1408,8 +1409,8 @@ fn lint_dead_codes<'tcx>(
14081409
let def_id = variant.def_id.expect_local();
14091410
if !live_symbols.contains(&def_id) {
14101411
// Record to group diagnostics.
1411-
let level = visitor.def_lint_level(def_id);
1412-
dead_variants.push(DeadItem { def_id, name: variant.name, level });
1412+
let level_plus = visitor.def_lint_level_plus(def_id);
1413+
dead_variants.push(DeadItem { def_id, name: variant.name, level_plus });
14131414
continue;
14141415
}
14151416

@@ -1424,8 +1425,8 @@ fn lint_dead_codes<'tcx>(
14241425
.filter_map(|field| {
14251426
let def_id = field.did.expect_local();
14261427
if let ShouldWarnAboutField::Yes = visitor.should_warn_about_field(field) {
1427-
let level = visitor.def_lint_level(def_id);
1428-
Some(DeadItem { def_id, name: field.name, level })
1428+
let level_plus = visitor.def_lint_level_plus(def_id);
1429+
Some(DeadItem { def_id, name: field.name, level_plus })
14291430
} else {
14301431
None
14311432
}

0 commit comments

Comments
 (0)