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:
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user