Add ErrorGuaranteed
to Recovered::Yes
and use it more.
The starting point for this was identical comments on two different fields, in `ast::VariantData::Struct` and `hir::VariantData::Struct`: ``` // FIXME: investigate making this a `Option<ErrorGuaranteed>` recovered: bool ``` I tried that, and then found that I needed to add an `ErrorGuaranteed` to `Recovered::Yes`. Then I ended up using `Recovered` instead of `Option<ErrorGuaranteed>` for these two places and elsewhere, which required moving `ErrorGuaranteed` from `rustc_parse` to `rustc_ast`. This makes things more consistent, because `Recovered` is used in more places, and there are fewer uses of `bool` and `Option<ErrorGuaranteed>`. And safer, because it's difficult/impossible to set `recovered` to `Recovered::Yes` without having emitted an error.
This commit is contained in:
parent
87293c9585
commit
fd91925bce
16 changed files with 91 additions and 105 deletions
|
@ -158,13 +158,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
let ohs = self.lower_expr(ohs);
|
||||
hir::ExprKind::AddrOf(*k, *m, ohs)
|
||||
}
|
||||
ExprKind::Let(pat, scrutinee, span, is_recovered) => {
|
||||
ExprKind::Let(pat, scrutinee, span, recovered) => {
|
||||
hir::ExprKind::Let(self.arena.alloc(hir::LetExpr {
|
||||
span: self.lower_span(*span),
|
||||
pat: self.lower_pat(pat),
|
||||
ty: None,
|
||||
init: self.lower_expr(scrutinee),
|
||||
is_recovered: *is_recovered,
|
||||
recovered: *recovered,
|
||||
}))
|
||||
}
|
||||
ExprKind::If(cond, then, else_opt) => {
|
||||
|
|
|
@ -1283,7 +1283,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
fields.iter().enumerate().map(|f| this.lower_field_def(f)),
|
||||
);
|
||||
let span = t.span;
|
||||
let variant_data = hir::VariantData::Struct { fields, recovered: false };
|
||||
let variant_data =
|
||||
hir::VariantData::Struct { fields, recovered: ast::Recovered::No };
|
||||
// FIXME: capture the generics from the outer adt.
|
||||
let generics = hir::Generics::empty();
|
||||
let kind = match t.kind {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue