Auto merge of #6619 - camsteffen:collapsible-match, r=camsteffen
Improve collapsible_match changelog: Fix collapsible_match false negatives Allow `&` and/or `*` on the binding and make sure the type still matches.
This commit is contained in:
commit
41d750c76c
7 changed files with 95 additions and 13 deletions
|
|
@ -158,8 +158,7 @@ pub fn for_loop<'tcx>(
|
|||
/// `while cond { body }` becomes `(cond, body)`.
|
||||
pub fn while_loop<'tcx>(expr: &'tcx hir::Expr<'tcx>) -> Option<(&'tcx hir::Expr<'tcx>, &'tcx hir::Expr<'tcx>)> {
|
||||
if_chain! {
|
||||
if let hir::ExprKind::Loop(block, _, hir::LoopSource::While) = &expr.kind;
|
||||
if let hir::Block { expr: Some(expr), .. } = &**block;
|
||||
if let hir::ExprKind::Loop(hir::Block { expr: Some(expr), .. }, _, hir::LoopSource::While) = &expr.kind;
|
||||
if let hir::ExprKind::Match(cond, arms, hir::MatchSource::WhileDesugar) = &expr.kind;
|
||||
if let hir::ExprKind::DropTemps(cond) = &cond.kind;
|
||||
if let [hir::Arm { body, .. }, ..] = &arms[..];
|
||||
|
|
|
|||
|
|
@ -1126,8 +1126,7 @@ pub fn is_self(slf: &Param<'_>) -> bool {
|
|||
|
||||
pub fn is_self_ty(slf: &hir::Ty<'_>) -> bool {
|
||||
if_chain! {
|
||||
if let TyKind::Path(ref qp) = slf.kind;
|
||||
if let QPath::Resolved(None, ref path) = *qp;
|
||||
if let TyKind::Path(QPath::Resolved(None, ref path)) = slf.kind;
|
||||
if let Res::SelfTy(..) = path.res;
|
||||
then {
|
||||
return true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue