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(_)`.
This commit is contained in:
Nicholas Nethercote
2025-08-19 15:06:48 +10:00
parent 425a9c0a0e
commit bfd5d59f97
17 changed files with 28 additions and 25 deletions

View File

@@ -43,7 +43,7 @@ impl<'a> Parser<'a> {
self.expect(exp!(OpenBrace))?;
let (inner_attrs, items, inner_span) = self.parse_mod(exp!(CloseBrace))?;
attrs.extend(inner_attrs);
ModKind::Loaded(items, Inline::Yes, inner_span, Ok(()))
ModKind::Loaded(items, Inline::Yes, inner_span)
};
Ok(ItemKind::Mod(safety, ident, mod_kind))
}