Skip to content

Commit bea2e2b

Browse files
authored
Rollup merge of rust-lang#145590 - nnethercote:ModKind-Inline, r=petrochenkov
Prevent impossible combinations in `ast::ModKind`. `ModKind::Loaded` has an `inline` field and a `had_parse_error` field. If the `inline` field is `Inline::Yes` then `had_parse_error` must be `Ok(())`. This commit moves the `had_parse_error` field into the `Inline::No` variant. This makes it impossible to create the nonsensical combination of `inline == Inline::Yes` and `had_parse_error = Err(_)`. r? ```@Urgau```
2 parents 4b2b9c2 + c1dfeea commit bea2e2b

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

clippy_lints/src/duplicate_mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl_lint_pass!(DuplicateMod => [DUPLICATE_MOD]);
6363

6464
impl EarlyLintPass for DuplicateMod {
6565
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
66-
if let ItemKind::Mod(_, _, ModKind::Loaded(_, Inline::No, mod_spans, _)) = &item.kind
66+
if let ItemKind::Mod(_, _, ModKind::Loaded(_, Inline::No { .. }, mod_spans)) = &item.kind
6767
&& let FileName::Real(real) = cx.sess().source_map().span_to_filename(mod_spans.inner_span)
6868
&& let Some(local_path) = real.into_local_path()
6969
&& let Ok(absolute_path) = local_path.canonicalize()

clippy_lints/src/empty_line_after.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ impl EmptyLineAfter {
442442
None => span.shrink_to_lo(),
443443
},
444444
mod_items: match kind {
445-
ItemKind::Mod(_, _, ModKind::Loaded(items, _, _, _)) => items
445+
ItemKind::Mod(_, _, ModKind::Loaded(items, _, _)) => items
446446
.iter()
447447
.filter(|i| !matches!(i.span.ctxt().outer_expn_data().kind, ExpnKind::AstPass(_)))
448448
.map(|i| i.id)

clippy_lints/src/excessive_nesting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl Visitor<'_> for NestingVisitor<'_, '_> {
164164
}
165165

166166
match &item.kind {
167-
ItemKind::Trait(_) | ItemKind::Impl(_) | ItemKind::Mod(.., ModKind::Loaded(_, Inline::Yes, _, _)) => {
167+
ItemKind::Trait(_) | ItemKind::Impl(_) | ItemKind::Mod(.., ModKind::Loaded(_, Inline::Yes, _)) => {
168168
self.nest_level += 1;
169169

170170
if !self.check_indent(item.span, item.id) {

clippy_utils/src/ast_utils/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
403403
ls == rs
404404
&& eq_id(*li, *ri)
405405
&& match (lmk, rmk) {
406-
(ModKind::Loaded(litems, linline, _, _), ModKind::Loaded(ritems, rinline, _, _)) => {
406+
(ModKind::Loaded(litems, linline, _), ModKind::Loaded(ritems, rinline, _)) => {
407407
linline == rinline && over(litems, ritems, |l, r| eq_item(l, r, eq_item_kind))
408408
},
409409
(ModKind::Unloaded, ModKind::Unloaded) => true,

0 commit comments

Comments
 (0)