Skip to content

Commit 01d0944

Browse files
committed
code clean up and remove crash test
1 parent 0e248f7 commit 01d0944

File tree

5 files changed

+7
-19
lines changed

5 files changed

+7
-19
lines changed

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ fn lower_variant(
10921092
})
10931093
.collect();
10941094
let recovered = match def {
1095-
hir::VariantData::Struct { recovered: Recovered::Yes(guard), .. } => Some(guard).copied(),
1095+
hir::VariantData::Struct { recovered: Recovered::Yes(guard), .. } => Some(*guard),
10961096
_ => None,
10971097
};
10981098
ty::VariantDef::new(

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,7 +2177,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21772177
skip_fields: &[hir::ExprField<'_>],
21782178
kind_name: &str,
21792179
) -> ErrorGuaranteed {
2180-
if let Some(guaranteed) = variant.has_errors() {
2180+
if let Err(guaranteed) = variant.has_errors() {
21812181
return guaranteed;
21822182
}
21832183
let mut err = self.err_ctxt().type_error_struct_with_diag(
@@ -2550,7 +2550,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25502550
&& !def.is_enum()
25512551
{
25522552
let variant = def.non_enum_variant();
2553-
if let Some(taint) = variant.has_errors() {
2553+
if let Err(taint) = variant.has_errors() {
25542554
return taint;
25552555
}
25562556
}

compiler/rustc_hir_typeck/src/pat.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,9 +1534,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15341534
let inexistent_fields_err = if !inexistent_fields.is_empty()
15351535
&& !inexistent_fields.iter().any(|field| field.ident.name == kw::Underscore)
15361536
{
1537-
if let Some(guard) = variant.has_errors() {
1538-
return Err(guard);
1539-
}
1537+
variant.has_errors()?;
15401538
Some(self.error_inexistent_fields(
15411539
adt.variant_descr(),
15421540
&inexistent_fields,
@@ -1815,9 +1813,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18151813
return Ok(());
18161814
}
18171815

1818-
if let Some(guaranteed) = variant.has_errors() {
1819-
return Err(guaranteed);
1820-
}
1816+
variant.has_errors()?;
18211817

18221818
let path = rustc_hir_pretty::qpath_to_string(&self.tcx, qpath);
18231819
let mut err = struct_span_code_err!(

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,8 +1259,8 @@ impl VariantDef {
12591259
}
12601260

12611261
/// Was this variant obtained as part of recovering from a syntactic error?
1262-
pub fn has_errors(&self) -> Option<ErrorGuaranteed> {
1263-
self.tainted
1262+
pub fn has_errors(&self) -> Result<(), ErrorGuaranteed> {
1263+
self.tainted.map_or(Ok(()), Err)
12641264
}
12651265

12661266
#[inline]

tests/crashes/126744.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)