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:
parent
c8ee33714b
commit
fd9133b9c3
6 changed files with 203 additions and 12 deletions
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue