1
Fork 0

Suggest boxed trait objects in tail match and if expressions

When encountering a `match` or `if` as a tail expression where the
different arms do not have the same type *and* the return type of that
`fn` is an `impl Trait`, check whether those arms can implement `Trait`
and if so, suggest using boxed trait objects.
This commit is contained in:
Esteban Küber 2020-08-17 22:39:46 -07:00
parent c8ee33714b
commit fd9133b9c3
6 changed files with 203 additions and 12 deletions

View file

@ -350,13 +350,16 @@ pub struct MatchExpressionArmCause<'tcx> {
pub prior_arms: Vec<Span>,
pub last_ty: Ty<'tcx>,
pub scrut_hir_id: hir::HirId,
pub suggest_box: Option<Span>,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct IfExpressionCause {
pub then: Span,
pub else_sp: Span,
pub outer: Option<Span>,
pub semicolon: Option<Span>,
pub suggest_box: Option<Span>,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, Lift)]