Skip to content

Commit e8d6170

Browse files
committed
Replace some Option<Diag> with Result<(), Diag>
1 parent ece3e3e commit e8d6170

File tree

1 file changed

+8
-8
lines changed
  • compiler/rustc_hir_typeck/src

1 file changed

+8
-8
lines changed

compiler/rustc_hir_typeck/src/pat.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1582,21 +1582,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15821582
}
15831583
match (inexistent_fields_err, unmentioned_err) {
15841584
(Some(i), Some(u)) => {
1585-
if let Some(e) = self.error_tuple_variant_as_struct_pat(pat, fields, variant) {
1585+
if let Err(e) = self.error_tuple_variant_as_struct_pat(pat, fields, variant) {
15861586
// We don't want to show the nonexistent fields error when this was
15871587
// `Foo { a, b }` when it should have been `Foo(a, b)`.
15881588
i.delay_as_bug();
15891589
u.delay_as_bug();
1590-
Err(e.emit())
1590+
Err(e)
15911591
} else {
15921592
i.emit();
15931593
Err(u.emit())
15941594
}
15951595
}
15961596
(None, Some(u)) => {
1597-
if let Some(e) = self.error_tuple_variant_as_struct_pat(pat, fields, variant) {
1597+
if let Err(e) = self.error_tuple_variant_as_struct_pat(pat, fields, variant) {
15981598
u.delay_as_bug();
1599-
Err(e.emit())
1599+
Err(e)
16001600
} else {
16011601
Err(u.emit())
16021602
}
@@ -1795,14 +1795,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17951795
pat: &Pat<'_>,
17961796
fields: &'tcx [hir::PatField<'tcx>],
17971797
variant: &ty::VariantDef,
1798-
) -> Option<Diag<'tcx>> {
1798+
) -> Result<(), ErrorGuaranteed> {
17991799
if let (Some(CtorKind::Fn), PatKind::Struct(qpath, pattern_fields, ..)) =
18001800
(variant.ctor_kind(), &pat.kind)
18011801
{
18021802
let is_tuple_struct_match = !pattern_fields.is_empty()
18031803
&& pattern_fields.iter().map(|field| field.ident.name.as_str()).all(is_number);
18041804
if is_tuple_struct_match {
1805-
return None;
1805+
return Ok(());
18061806
}
18071807

18081808
let path = rustc_hir_pretty::qpath_to_string(&self.tcx, qpath);
@@ -1830,9 +1830,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18301830
format!("({sugg})"),
18311831
appl,
18321832
);
1833-
return Some(err);
1833+
return Err(err.emit());
18341834
}
1835-
None
1835+
Ok(())
18361836
}
18371837

18381838
fn get_suggested_tuple_struct_pattern(

0 commit comments

Comments
 (0)