Skip to content

Commit 2171749

Browse files
committed
Hacks to make Clippy build with nightly-2022-09-09
1 parent 5abb1f2 commit 2171749

File tree

13 files changed

+236
-227
lines changed

13 files changed

+236
-227
lines changed

clippy_lints/src/equatable_if_let.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn unary_pattern(pat: &Pat<'_>) -> bool {
5151
false
5252
},
5353
PatKind::Struct(_, a, etc) => !etc && a.iter().all(|x| unary_pattern(x.pat)),
54-
PatKind::Tuple(a, etc) | PatKind::TupleStruct(_, a, etc) => !etc.is_some() && array_rec(a),
54+
PatKind::Tuple(a, etc) | PatKind::TupleStruct(_, a, etc) => etc.as_opt_usize().is_none() && array_rec(a),
5555
PatKind::Ref(x, _) | PatKind::Box(x) => unary_pattern(x),
5656
PatKind::Path(_) | PatKind::Lit(_) => true,
5757
}

clippy_lints/src/lib.rs

Lines changed: 208 additions & 208 deletions
Large diffs are not rendered by default.

clippy_lints/src/lifetimes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
461461
sub_visitor.visit_fn_decl(decl);
462462
self.nested_elision_site_lts.append(&mut sub_visitor.all_lts());
463463
},
464-
TyKind::TraitObject(bounds, ref lt, _) => {
464+
TyKind::TraitObject(bounds, lt, _) => {
465465
if !lt.is_elided() {
466466
self.unelided_trait_object_lifetime = true;
467467
}

clippy_lints/src/matches/match_same_arms.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl<'a> NormalizedPat<'a> {
248248
} else {
249249
(None, adt.non_enum_variant())
250250
};
251-
let (front, back) = match wild_idx {
251+
let (front, back) = match wild_idx.as_opt_usize() {
252252
Some(i) => pats.split_at(i),
253253
None => (pats, [].as_slice()),
254254
};
@@ -268,7 +268,7 @@ impl<'a> NormalizedPat<'a> {
268268
ty::Tuple(subs) => subs.len(),
269269
_ => return Self::Wild,
270270
};
271-
let (front, back) = match wild_idx {
271+
let (front, back) = match wild_idx.as_opt_usize() {
272272
Some(i) => pats.split_at(i),
273273
None => (pats, [].as_slice()),
274274
};

clippy_lints/src/matches/single_match.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ fn form_exhaustive_matches<'a>(cx: &LateContext<'a>, ty: Ty<'a>, left: &Pat<'_>,
201201
// in the arms, so we need to evaluate the correct offsets here in order to iterate in
202202
// both arms at the same time.
203203
let len = max(
204-
left_in.len() + usize::from(left_pos.is_some()),
205-
right_in.len() + usize::from(right_pos.is_some()),
204+
left_in.len() + usize::from(left_pos.as_opt_usize().is_some()),
205+
right_in.len() + usize::from(right_pos.as_opt_usize().is_some()),
206206
);
207-
let mut left_pos = left_pos.unwrap_or(usize::MAX);
208-
let mut right_pos = right_pos.unwrap_or(usize::MAX);
207+
let mut left_pos = left_pos.as_opt_usize().unwrap_or(usize::MAX);
208+
let mut right_pos = right_pos.as_opt_usize().unwrap_or(usize::MAX);
209209
let mut left_dot_space = 0;
210210
let mut right_dot_space = 0;
211211
for i in 0..len {

clippy_lints/src/ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args:
669669
}
670670

671671
fn get_rptr_lm<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> Option<(&'tcx Lifetime, Mutability, Span)> {
672-
if let TyKind::Rptr(ref lt, ref m) = ty.kind {
672+
if let TyKind::Rptr(lt, ref m) = ty.kind {
673673
Some((lt, m.mutbl, ty.span))
674674
} else {
675675
None

clippy_lints/src/question_mark.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ fn check_if_let_some_or_err_and_early_return<'tcx>(cx: &LateContext<'tcx>, expr:
122122
if_chain! {
123123
if let Some(higher::IfLet { let_pat, let_expr, if_then, if_else }) = higher::IfLet::hir(cx, expr);
124124
if !is_else_clause(cx.tcx, expr);
125-
if let PatKind::TupleStruct(ref path1, [field], None) = let_pat.kind;
125+
if let PatKind::TupleStruct(ref path1, [field], dot_dot_pos) = let_pat.kind;
126+
if dot_dot_pos.as_opt_usize().is_none();
126127
if let PatKind::Binding(BindingAnnotation(by_ref, _), bind_id, ident, None) = field.kind;
127128
let caller_ty = cx.typeck_results().expr_ty(let_expr);
128129
let if_block = IfBlockType::IfLet(path1, caller_ty, ident.name, let_expr, if_then, if_else);

clippy_lints/src/types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ impl Types {
535535
QPath::LangItem(..) => {},
536536
}
537537
},
538-
TyKind::Rptr(ref lt, ref mut_ty) => {
538+
TyKind::Rptr(lt, ref mut_ty) => {
539539
context.is_nested_call = true;
540540
if !borrowed_box::check(cx, hir_ty, lt, mut_ty) {
541541
self.check_ty(cx, mut_ty.ty, context);

clippy_lints/src/unit_types/let_unit_value.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,17 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, local: &'tcx Local<'_>) {
1919
&& cx.typeck_results().pat_ty(local.pat).is_unit()
2020
{
2121
if (local.ty.map_or(false, |ty| !matches!(ty.kind, TyKind::Infer))
22-
|| matches!(local.pat.kind, PatKind::Tuple([], None)))
22+
|| match local.pat.kind {
23+
PatKind::Tuple([], dot_dot_pos) => dot_dot_pos.as_opt_usize().is_none(),
24+
_ => false,
25+
})
2326
&& expr_needs_inferred_result(cx, init)
2427
{
25-
if !matches!(local.pat.kind, PatKind::Wild | PatKind::Tuple([], None)) {
28+
if !match local.pat.kind {
29+
PatKind::Wild => true,
30+
PatKind::Tuple([], dot_dot_pos) => dot_dot_pos.as_opt_usize().is_none(),
31+
_ => false,
32+
} {
2633
span_lint_and_then(
2734
cx,
2835
LET_UNIT_VALUE,

clippy_utils/src/hir_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
962962
mut_ty.mutbl.hash(&mut self.s);
963963
},
964964
TyKind::Rptr(lifetime, ref mut_ty) => {
965-
self.hash_lifetime(*lifetime);
965+
self.hash_lifetime(**lifetime);
966966
self.hash_ty(mut_ty.ty);
967967
mut_ty.mutbl.hash(&mut self.s);
968968
},
@@ -991,7 +991,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
991991
self.hash_generic_args(arg_list);
992992
},
993993
TyKind::TraitObject(_, lifetime, _) => {
994-
self.hash_lifetime(*lifetime);
994+
self.hash_lifetime(**lifetime);
995995
},
996996
TyKind::Typeof(anon_const) => {
997997
self.hash_body(anon_const.body);
@@ -1017,7 +1017,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
10171017
fn hash_generic_args(&mut self, arg_list: &[GenericArg<'_>]) {
10181018
for arg in arg_list {
10191019
match *arg {
1020-
GenericArg::Lifetime(l) => self.hash_lifetime(l),
1020+
GenericArg::Lifetime(l) => self.hash_lifetime(*l),
10211021
GenericArg::Type(ty) => self.hash_ty(ty),
10221022
GenericArg::Const(ref ca) => self.hash_body(ca.value.body),
10231023
GenericArg::Infer(ref inf) => self.hash_ty(&inf.to_ty()),

0 commit comments

Comments
 (0)