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
|
@ -14,6 +14,7 @@
|
|||
//! At present, however, we do run collection across all items in the
|
||||
//! crate as a kind of pass. This should eventually be factored away.
|
||||
|
||||
use rustc_ast::Recovered;
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
|
||||
use rustc_data_structures::unord::UnordMap;
|
||||
|
@ -1005,10 +1006,7 @@ fn lower_variant(
|
|||
vis: tcx.visibility(f.def_id),
|
||||
})
|
||||
.collect();
|
||||
let recovered = match def {
|
||||
hir::VariantData::Struct { recovered, .. } => *recovered,
|
||||
_ => false,
|
||||
};
|
||||
let recovered = matches!(def, hir::VariantData::Struct { recovered: Recovered::Yes(_), .. });
|
||||
ty::VariantDef::new(
|
||||
ident.name,
|
||||
variant_did.map(LocalDefId::to_def_id),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue