Skip to content

Commit 29eaf53

Browse files
Rollup merge of #156829 - Bryntet:levels_options_removal, r=nnethercote
Turn `lint_index` from `Option<u16>` to `u16` for LintExpectationId While doing lint attributes PR, I realised that the field `lint_index` didn't need to be Optional (this PR is part of a series of PRs that will make the lint attrs PR more easily reviewable) r? @nnethercote because you did #156596 recently
2 parents 7908120 + 4f12864 commit 29eaf53

3 files changed

Lines changed: 8 additions & 12 deletions

File tree

compiler/rustc_lint/src/expect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
3838
(tcx.hir_attrs(id.hir_id)[id.attr_index as usize].id(), id.lint_index)
3939
}
4040
};
41-
(attr_id, lint_index.expect("fulfilled expectations must have a lint index"))
41+
(attr_id, lint_index)
4242
};
4343

4444
let fulfilled_expectations: FxHashSet<_> =

compiler/rustc_lint/src/levels.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ pub trait LintLevelsProvider {
233233
&self,
234234
attr_id: AttrId,
235235
attr_index: usize,
236-
lint_index: Option<u16>,
236+
lint_index: u16,
237237
) -> Self::LintExpectationId;
238238
}
239239

@@ -258,7 +258,7 @@ impl LintLevelsProvider for TopDown {
258258
&self,
259259
attr_id: AttrId,
260260
_attr_index: usize,
261-
lint_index: Option<u16>,
261+
lint_index: u16,
262262
) -> Self::LintExpectationId {
263263
UnstableLintExpectationId { attr_id, lint_index }
264264
}
@@ -296,7 +296,7 @@ impl LintLevelsProvider for LintLevelQueryMap<'_> {
296296
&self,
297297
_attr_id: AttrId,
298298
attr_index: usize,
299-
lint_index: Option<u16>,
299+
lint_index: u16,
300300
) -> Self::LintExpectationId {
301301
let attr_index = attr_index.try_into().unwrap();
302302
StableLintExpectationId { hir_id: self.cur, attr_index, lint_index }
@@ -740,11 +740,7 @@ where
740740
// `Expect` is the only lint level with a `LintExpectationId` that can be created
741741
// from an attribute.
742742
let lint_id = (level == Level::Expect).then(|| {
743-
self.provider.mk_lint_expectation_id(
744-
attr.id(),
745-
attr_index,
746-
Some(lint_index as u16),
747-
)
743+
self.provider.mk_lint_expectation_id(attr.id(), attr_index, lint_index as u16)
748744
});
749745

750746
let sp = li.span();

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub enum LintExpectationId {
109109
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, Encodable, Decodable)]
110110
pub struct UnstableLintExpectationId {
111111
pub attr_id: AttrId,
112-
pub lint_index: Option<u16>,
112+
pub lint_index: u16,
113113
}
114114

115115
impl From<UnstableLintExpectationId> for LintExpectationId {
@@ -125,7 +125,7 @@ impl From<UnstableLintExpectationId> for LintExpectationId {
125125
pub struct StableLintExpectationId {
126126
pub hir_id: HirId,
127127
pub attr_index: u16,
128-
pub lint_index: Option<u16>,
128+
pub lint_index: u16,
129129
}
130130

131131
impl StableHash for StableLintExpectationId {
@@ -135,7 +135,7 @@ impl StableHash for StableLintExpectationId {
135135

136136
hir_id.stable_hash(hcx, hasher);
137137
attr_index.stable_hash(hcx, hasher);
138-
lint_index.expect("must be filled to call `stable_hash`").stable_hash(hcx, hasher);
138+
lint_index.stable_hash(hcx, hasher);
139139
}
140140
}
141141

0 commit comments

Comments
 (0)