1
Fork 0

Rollup merge of #121146 - compiler-errors:ignore-diverging-arms, r=estebank

Only point out non-diverging arms for match suggestions

Fixes #121144

There is no reason to point at diverging arms, which will always coerce to whatever is the match block's evaluated type.

This also removes the suggestion from #106601, since as I pointed out in https://github.com/rust-lang/rust/issues/72634#issuecomment-1946210898 the added suggestion is not firing in the right cases, but instead only when one of the match arms already *actually* evaluates to `()`.

r? estebank
This commit is contained in:
Guillaume Gomez 2024-02-16 00:27:34 +01:00 committed by GitHub
commit 77eaa80d5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 69 additions and 48 deletions

View file

@ -569,9 +569,8 @@ pub struct MatchExpressionArmCause<'tcx> {
pub prior_arm_ty: Ty<'tcx>,
pub prior_arm_span: Span,
pub scrut_span: Span,
pub scrut_hir_id: hir::HirId,
pub source: hir::MatchSource,
pub prior_arms: Vec<Span>,
pub prior_non_diverging_arms: Vec<Span>,
pub opt_suggest_box_span: Option<Span>,
}