Skip to content

Commit 24f6d64

Browse files
committed
Auto merge of rust-lang#5322 - phansch:or_patterns, r=matthiaskrgr
Make use of `or_patterns` feature changelog: none
2 parents d556bb7 + 548c417 commit 24f6d64

File tree

9 files changed

+16
-18
lines changed

9 files changed

+16
-18
lines changed

clippy_lints/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
320320
fn fetch_path(&mut self, qpath: &QPath<'_>, id: HirId, ty: Ty<'cc>) -> Option<Constant> {
321321
let res = self.tables.qpath_res(qpath, id);
322322
match res {
323-
Res::Def(DefKind::Const, def_id) | Res::Def(DefKind::AssocConst, def_id) => {
323+
Res::Def(DefKind::Const | DefKind::AssocConst, def_id) => {
324324
let substs = self.tables.node_substs(id);
325325
let substs = if self.substs.is_empty() {
326326
substs

clippy_lints/src/eval_order_dependence.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,8 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
106106
ExprKind::Match(ref e, arms, _) => {
107107
self.visit_expr(e);
108108
for arm in arms {
109-
if let Some(ref guard) = arm.guard {
110-
match guard {
111-
Guard::If(if_expr) => self.visit_expr(if_expr),
112-
}
109+
if let Some(Guard::If(if_expr)) = arm.guard {
110+
self.visit_expr(if_expr)
113111
}
114112
// make sure top level arm expressions aren't linted
115113
self.maybe_walk_expr(&*arm.body);

clippy_lints/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#![feature(box_syntax)]
44
#![feature(box_patterns)]
5+
#![feature(or_patterns)]
56
#![feature(rustc_private)]
67
#![feature(stmt_expr_attributes)]
78
#![allow(clippy::missing_docs_in_private_items, clippy::must_use_candidate)]

clippy_lints/src/lifetimes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl<'v, 't> RefVisitor<'v, 't> {
346346
{
347347
let hir_id = ty.hir_id;
348348
match self.cx.tables.qpath_res(qpath, hir_id) {
349-
Res::Def(DefKind::TyAlias, def_id) | Res::Def(DefKind::Struct, def_id) => {
349+
Res::Def(DefKind::TyAlias | DefKind::Struct, def_id) => {
350350
let generics = self.cx.tcx.generics_of(def_id);
351351
for _ in generics.params.as_slice() {
352352
self.record(&None);

clippy_lints/src/loops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
17801780
}
17811781
return false; // no need to walk further *on the variable*
17821782
}
1783-
Res::Def(DefKind::Static, ..) | Res::Def(DefKind::Const, ..) => {
1783+
Res::Def(DefKind::Static | DefKind::Const, ..) => {
17841784
if indexed_indirectly {
17851785
self.indexed_indirectly.insert(seqvar.segments[0].ident.name, None);
17861786
}

clippy_lints/src/methods/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1755,9 +1755,7 @@ fn lint_expect_fun_call(
17551755
)
17561756
}),
17571757
hir::ExprKind::Path(ref p) => match cx.tables.qpath_res(p, arg.hir_id) {
1758-
hir::def::Res::Def(hir::def::DefKind::Const, _) | hir::def::Res::Def(hir::def::DefKind::Static, _) => {
1759-
true
1760-
},
1758+
hir::def::Res::Def(hir::def::DefKind::Const | hir::def::DefKind::Static, _) => true,
17611759
_ => false,
17621760
},
17631761
_ => false,

clippy_lints/src/no_effect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn has_no_effect(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> bool {
6969
if let ExprKind::Path(ref qpath) = callee.kind {
7070
let res = qpath_res(cx, qpath, callee.hir_id);
7171
match res {
72-
Res::Def(DefKind::Struct, ..) | Res::Def(DefKind::Variant, ..) | Res::Def(DefKind::Ctor(..), _) => {
72+
Res::Def(DefKind::Struct | DefKind::Variant | DefKind::Ctor(..), ..) => {
7373
!has_drop(cx, cx.tables.expr_ty(expr)) && args.iter().all(|arg| has_no_effect(cx, arg))
7474
},
7575
_ => false,

clippy_lints/src/non_copy_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst {
191191

192192
// Make sure it is a const item.
193193
match qpath_res(cx, qpath, expr.hir_id) {
194-
Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) => {},
194+
Res::Def(DefKind::Const | DefKind::AssocConst, _) => {},
195195
_ => return,
196196
};
197197

clippy_lints/src/utils/mod.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ pub fn get_trait_def_id(cx: &LateContext<'_, '_>, path: &[&str]) -> Option<DefId
315315
};
316316

317317
match res {
318-
Res::Def(DefKind::Trait, trait_id) | Res::Def(DefKind::TraitAlias, trait_id) => Some(trait_id),
318+
Res::Def(DefKind::Trait | DefKind::TraitAlias, trait_id) => Some(trait_id),
319319
Res::Err => unreachable!("this trait resolution is impossible: {:?}", &path),
320320
_ => None,
321321
}
@@ -448,10 +448,11 @@ pub fn is_entrypoint_fn(cx: &LateContext<'_, '_>, def_id: DefId) -> bool {
448448
pub fn get_item_name(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Option<Name> {
449449
let parent_id = cx.tcx.hir().get_parent_item(expr.hir_id);
450450
match cx.tcx.hir().find(parent_id) {
451-
Some(Node::Item(&Item { ref ident, .. })) => Some(ident.name),
452-
Some(Node::TraitItem(&TraitItem { ident, .. })) | Some(Node::ImplItem(&ImplItem { ident, .. })) => {
453-
Some(ident.name)
454-
},
451+
Some(
452+
Node::Item(Item { ident, .. })
453+
| Node::TraitItem(TraitItem { ident, .. })
454+
| Node::ImplItem(ImplItem { ident, .. }),
455+
) => Some(ident.name),
455456
_ => None,
456457
}
457458
}
@@ -925,7 +926,7 @@ pub fn is_ctor_or_promotable_const_function(cx: &LateContext<'_, '_>, expr: &Exp
925926
if let ExprKind::Path(ref qp) = fun.kind {
926927
let res = cx.tables.qpath_res(qp, fun.hir_id);
927928
return match res {
928-
def::Res::Def(DefKind::Variant, ..) | Res::Def(DefKind::Ctor(..), _) => true,
929+
def::Res::Def(DefKind::Variant | DefKind::Ctor(..), ..) => true,
929930
def::Res::Def(_, def_id) => cx.tcx.is_promotable_const_fn(def_id),
930931
_ => false,
931932
};

0 commit comments

Comments
 (0)