Skip to content

Commit fa0f6a8

Browse files
committed
Auto merge of #5711 - flip1995:rustup, r=flip1995
Rustup changelog: none
2 parents 7427065 + 51592f8 commit fa0f6a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+192
-222
lines changed

clippy_lints/src/atomic_ordering.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn match_ordering_def_path(cx: &LateContext<'_, '_>, did: DefId, orderings: &[&s
7070

7171
fn check_atomic_load_store(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
7272
if_chain! {
73-
if let ExprKind::MethodCall(ref method_path, _, args) = &expr.kind;
73+
if let ExprKind::MethodCall(ref method_path, _, args, _) = &expr.kind;
7474
let method = method_path.ident.name.as_str();
7575
if type_is_atomic(cx, &args[0]);
7676
if method == "load" || method == "store";

clippy_lints/src/booleans.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ fn simplify_not(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Option<String> {
247247
))
248248
})
249249
},
250-
ExprKind::MethodCall(path, _, args) if args.len() == 1 => {
250+
ExprKind::MethodCall(path, _, args, _) if args.len() == 1 => {
251251
let type_of_receiver = cx.tables.expr_ty(&args[0]);
252252
if !is_type_diagnostic_item(cx, type_of_receiver, sym!(option_type))
253253
&& !is_type_diagnostic_item(cx, type_of_receiver, sym!(result_type))

clippy_lints/src/bytecount.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ declare_lint_pass!(ByteCount => [NAIVE_BYTECOUNT]);
3838
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
3939
fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
4040
if_chain! {
41-
if let ExprKind::MethodCall(ref count, _, ref count_args) = expr.kind;
41+
if let ExprKind::MethodCall(ref count, _, ref count_args, _) = expr.kind;
4242
if count.ident.name == sym!(count);
4343
if count_args.len() == 1;
44-
if let ExprKind::MethodCall(ref filter, _, ref filter_args) = count_args[0].kind;
44+
if let ExprKind::MethodCall(ref filter, _, ref filter_args, _) = count_args[0].kind;
4545
if filter.ident.name == sym!(filter);
4646
if filter_args.len() == 2;
4747
if let ExprKind::Closure(_, _, body_id, _, _) = filter_args[1].kind;
@@ -66,7 +66,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
6666
if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.tables.expr_ty(needle)).kind {
6767
return;
6868
}
69-
let haystack = if let ExprKind::MethodCall(ref path, _, ref args) =
69+
let haystack = if let ExprKind::MethodCall(ref path, _, ref args, _) =
7070
filter_args[0].kind {
7171
let p = path.ident.name;
7272
if (p == sym!(iter) || p == sym!(iter_mut)) && args.len() == 1 {

clippy_lints/src/checked_conversions.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn double_check<'a>(cx: &LateContext<'_, '_>, left: &'a Expr<'_>, right: &'a Exp
8888
let upper = check_upper_bound(l);
8989
let lower = check_lower_bound(r);
9090

91-
transpose(upper, lower).and_then(|(l, r)| l.combine(r, cx))
91+
upper.zip(lower).and_then(|(l, r)| l.combine(r, cx))
9292
};
9393

9494
upper_lower(left, right).or_else(|| upper_lower(right, left))
@@ -131,7 +131,10 @@ impl<'a> Conversion<'a> {
131131

132132
/// Checks if the to-type is the same (if there is a type constraint)
133133
fn has_compatible_to_type(&self, other: &Self) -> bool {
134-
transpose(self.to_type.as_ref(), other.to_type.as_ref()).map_or(true, |(l, r)| l == r)
134+
match (self.to_type, other.to_type) {
135+
(Some(l), Some(r)) => l == r,
136+
_ => true,
137+
}
135138
}
136139

137140
/// Try to construct a new conversion if the conversion type is valid
@@ -322,14 +325,6 @@ fn int_ty_to_sym<'tcx>(path: &QPath<'_>) -> Option<&'tcx str> {
322325
}
323326
}
324327

325-
/// (Option<T>, Option<U>) -> Option<(T, U)>
326-
fn transpose<T, U>(lhs: Option<T>, rhs: Option<U>) -> Option<(T, U)> {
327-
match (lhs, rhs) {
328-
(Some(l), Some(r)) => Some((l, r)),
329-
_ => None,
330-
}
331-
}
332-
333328
/// Will return the expressions as if they were expr1 <= expr2
334329
fn normalize_le_ge<'a>(op: &BinOp, left: &'a Expr<'a>, right: &'a Expr<'a>) -> Option<(&'a Expr<'a>, &'a Expr<'a>)> {
335330
match op.node {

clippy_lints/src/consts.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,11 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
254254
if let ["core", "num", int_impl, "max_value"] = *def_path;
255255
then {
256256
let value = match int_impl {
257-
"<impl i8>" => i8::max_value() as u128,
258-
"<impl i16>" => i16::max_value() as u128,
259-
"<impl i32>" => i32::max_value() as u128,
260-
"<impl i64>" => i64::max_value() as u128,
261-
"<impl i128>" => i128::max_value() as u128,
257+
"<impl i8>" => i8::MAX as u128,
258+
"<impl i16>" => i16::MAX as u128,
259+
"<impl i32>" => i32::MAX as u128,
260+
"<impl i64>" => i64::MAX as u128,
261+
"<impl i128>" => i128::MAX as u128,
262262
_ => return None,
263263
};
264264
Some(Constant::Int(value))

clippy_lints/src/dereference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Dereferencing {
4242
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
4343
if_chain! {
4444
if !expr.span.from_expansion();
45-
if let ExprKind::MethodCall(ref method_name, _, ref args) = &expr.kind;
45+
if let ExprKind::MethodCall(ref method_name, _, ref args, _) = &expr.kind;
4646
if args.len() == 1;
4747

4848
then {

clippy_lints/src/double_parens.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl EarlyLintPass for DoubleParens {
7070
}
7171
}
7272
},
73-
ExprKind::MethodCall(_, ref params) => {
73+
ExprKind::MethodCall(_, ref params, _) => {
7474
if params.len() == 2 {
7575
let param = &params[1];
7676
if let ExprKind::Paren(_) = param.kind {

clippy_lints/src/duration_subsec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DurationSubsec {
4242
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
4343
if_chain! {
4444
if let ExprKind::Binary(Spanned { node: BinOpKind::Div, .. }, ref left, ref right) = expr.kind;
45-
if let ExprKind::MethodCall(ref method_path, _ , ref args) = left.kind;
45+
if let ExprKind::MethodCall(ref method_path, _ , ref args, _) = left.kind;
4646
if match_type(cx, walk_ptrs_ty(cx.tables.expr_ty(&args[0])), &paths::DURATION);
4747
if let Some((Constant::Int(divisor), _)) = constant(cx, cx.tables, right);
4848
then {

clippy_lints/src/entry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn check_cond<'a, 'tcx, 'b>(
103103
check: &'b Expr<'b>,
104104
) -> Option<(&'static str, &'b Expr<'b>, &'b Expr<'b>)> {
105105
if_chain! {
106-
if let ExprKind::MethodCall(ref path, _, ref params) = check.kind;
106+
if let ExprKind::MethodCall(ref path, _, ref params, _) = check.kind;
107107
if params.len() >= 2;
108108
if path.ident.name == sym!(contains_key);
109109
if let ExprKind::AddrOf(BorrowKind::Ref, _, ref key) = params[1].kind;
@@ -140,7 +140,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
140140

141141
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
142142
if_chain! {
143-
if let ExprKind::MethodCall(ref path, _, ref params) = expr.kind;
143+
if let ExprKind::MethodCall(ref path, _, ref params, _) = expr.kind;
144144
if params.len() == 3;
145145
if path.ident.name == sym!(insert);
146146
if get_item_name(self.cx, self.map) == get_item_name(self.cx, &params[0]);

clippy_lints/src/enum_clike.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
6565
continue;
6666
}
6767
},
68-
ty::Uint(UintTy::Usize) if val > u128::from(u32::max_value()) => {},
68+
ty::Uint(UintTy::Usize) if val > u128::from(u32::MAX) => {},
6969
_ => continue,
7070
}
7171
span_lint(

clippy_lints/src/escape.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_middle::ty::{self, Ty};
66
use rustc_session::{declare_tool_lint, impl_lint_pass};
77
use rustc_span::source_map::Span;
88
use rustc_target::abi::LayoutOf;
9-
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, Place, PlaceBase};
9+
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
1010

1111
use crate::utils::span_lint;
1212

@@ -112,9 +112,9 @@ fn is_argument(map: rustc_middle::hir::map::Map<'_>, id: HirId) -> bool {
112112
}
113113

114114
impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
115-
fn consume(&mut self, cmt: &Place<'tcx>, mode: ConsumeMode) {
116-
if cmt.projections.is_empty() {
117-
if let PlaceBase::Local(lid) = cmt.base {
115+
fn consume(&mut self, cmt: &PlaceWithHirId<'tcx>, mode: ConsumeMode) {
116+
if cmt.place.projections.is_empty() {
117+
if let PlaceBase::Local(lid) = cmt.place.base {
118118
if let ConsumeMode::Move = mode {
119119
// moved out or in. clearly can't be localized
120120
self.set.remove(&lid);
@@ -132,16 +132,16 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
132132
}
133133
}
134134

135-
fn borrow(&mut self, cmt: &Place<'tcx>, _: ty::BorrowKind) {
136-
if cmt.projections.is_empty() {
137-
if let PlaceBase::Local(lid) = cmt.base {
135+
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: ty::BorrowKind) {
136+
if cmt.place.projections.is_empty() {
137+
if let PlaceBase::Local(lid) = cmt.place.base {
138138
self.set.remove(&lid);
139139
}
140140
}
141141
}
142142

143-
fn mutate(&mut self, cmt: &Place<'tcx>) {
144-
if cmt.projections.is_empty() {
143+
fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>) {
144+
if cmt.place.projections.is_empty() {
145145
let map = &self.cx.tcx.hir();
146146
if is_argument(*map, cmt.hir_id) {
147147
// Skip closure arguments
@@ -150,7 +150,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
150150
return;
151151
}
152152

153-
if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
153+
if is_non_trait_box(cmt.place.ty) && !self.is_large_box(cmt.place.ty) {
154154
self.set.insert(cmt.hir_id);
155155
}
156156
return;

clippy_lints/src/eta_reduction.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EtaReduction {
7171
}
7272

7373
match expr.kind {
74-
ExprKind::Call(_, args) | ExprKind::MethodCall(_, _, args) => {
74+
ExprKind::Call(_, args) | ExprKind::MethodCall(_, _, args, _) => {
7575
for arg in args {
7676
check_closure(cx, arg)
7777
}
@@ -120,7 +120,7 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
120120
);
121121

122122
if_chain!(
123-
if let ExprKind::MethodCall(ref path, _, ref args) = ex.kind;
123+
if let ExprKind::MethodCall(ref path, _, ref args, _) = ex.kind;
124124

125125
// Not the same number of arguments, there is no way the closure is the same as the function return;
126126
if args.len() == decl.inputs.len();

clippy_lints/src/explicit_write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitWrite {
3232
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
3333
if_chain! {
3434
// match call to unwrap
35-
if let ExprKind::MethodCall(ref unwrap_fun, _, ref unwrap_args) = expr.kind;
35+
if let ExprKind::MethodCall(ref unwrap_fun, _, ref unwrap_args, _) = expr.kind;
3636
if unwrap_fun.ident.name == sym!(unwrap);
3737
// match call to write_fmt
3838
if !unwrap_args.is_empty();
39-
if let ExprKind::MethodCall(ref write_fun, _, write_args) =
39+
if let ExprKind::MethodCall(ref write_fun, _, write_args, _) =
4040
unwrap_args[0].kind;
4141
if write_fun.ident.name == sym!(write_fmt);
4242
// match calls to std::io::stdout() / std::io::stderr ()

clippy_lints/src/floating_point_arithmetic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ fn check_expm1(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
301301
if cx.tables.expr_ty(lhs).is_floating_point();
302302
if let Some((value, _)) = constant(cx, cx.tables, rhs);
303303
if F32(1.0) == value || F64(1.0) == value;
304-
if let ExprKind::MethodCall(ref path, _, ref method_args) = lhs.kind;
304+
if let ExprKind::MethodCall(ref path, _, ref method_args, _) = lhs.kind;
305305
if cx.tables.expr_ty(&method_args[0]).is_floating_point();
306306
if path.ident.name.as_str() == "exp";
307307
then {
@@ -481,7 +481,7 @@ fn check_custom_abs(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
481481

482482
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FloatingPointArithmetic {
483483
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
484-
if let ExprKind::MethodCall(ref path, _, args) = &expr.kind {
484+
if let ExprKind::MethodCall(ref path, _, args, _) = &expr.kind {
485485
let recv_ty = cx.tables.expr_ty(&args[0]);
486486

487487
if recv_ty.is_floating_point() {

clippy_lints/src/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn on_argumentv1_new<'a, 'tcx>(
104104
}
105105
} else {
106106
let snip = snippet(cx, format_args.span, "<arg>");
107-
if let ExprKind::MethodCall(ref path, _, _) = format_args.kind {
107+
if let ExprKind::MethodCall(ref path, _, _, _) = format_args.kind {
108108
if path.ident.name == sym!(to_string) {
109109
return Some(format!("{}", snip));
110110
}

clippy_lints/src/functions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
556556
}
557557
}
558558
},
559-
hir::ExprKind::MethodCall(_, _, args) => {
559+
hir::ExprKind::MethodCall(_, _, args, _) => {
560560
let def_id = self.tables.type_dependent_def_id(expr.hir_id).unwrap();
561561
let base_type = self.cx.tcx.type_of(def_id);
562562

@@ -610,7 +610,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
610610
return;
611611
}
612612
match expr.kind {
613-
Call(_, args) | MethodCall(_, _, args) => {
613+
Call(_, args) | MethodCall(_, _, args, _) => {
614614
let mut tys = FxHashSet::default();
615615
for arg in args {
616616
let def_id = arg.hir_id.owner.to_def_id();

clippy_lints/src/get_last_with_len.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen {
4747
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
4848
if_chain! {
4949
// Is a method call
50-
if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind;
50+
if let ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind;
5151

5252
// Method name is "get"
5353
if path.ident.name == sym!(get);
@@ -69,7 +69,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen {
6969
) = &get_index_arg.kind;
7070

7171
// LHS of subtraction is "x.len()"
72-
if let ExprKind::MethodCall(arg_lhs_path, _, lhs_args) = &lhs.kind;
72+
if let ExprKind::MethodCall(arg_lhs_path, _, lhs_args, _) = &lhs.kind;
7373
if arg_lhs_path.ident.name == sym!(len);
7474
if let Some(arg_lhs_struct) = lhs_args.get(0);
7575

clippy_lints/src/if_let_mutex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'tcx, 'l> ArmVisitor<'tcx, 'l> {
147147

148148
fn is_mutex_lock_call<'a>(cx: &LateContext<'a, '_>, expr: &'a Expr<'_>) -> Option<&'a Expr<'a>> {
149149
if_chain! {
150-
if let ExprKind::MethodCall(path, _span, args) = &expr.kind;
150+
if let ExprKind::MethodCall(path, _span, args, _) = &expr.kind;
151151
if path.ident.to_string() == "lock";
152152
let ty = cx.tables.expr_ty(&args[0]);
153153
if is_type_diagnostic_item(cx, ty, sym!(mutex_type));

clippy_lints/src/if_let_some_result.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OkIfLet {
4242
if_chain! { //begin checking variables
4343
if let ExprKind::Match(ref op, ref body, source) = expr.kind; //test if expr is a match
4444
if let MatchSource::IfLetDesugar { .. } = source; //test if it is an If Let
45-
if let ExprKind::MethodCall(_, ok_span, ref result_types) = op.kind; //check is expr.ok() has type Result<T,E>.ok()
45+
if let ExprKind::MethodCall(_, ok_span, ref result_types, _) = op.kind; //check is expr.ok() has type Result<T,E>.ok(, _)
4646
if let PatKind::TupleStruct(QPath::Resolved(_, ref x), ref y, _) = body[0].pat.kind; //get operation
4747
if method_chain_args(op, &["ok"]).is_some(); //test to see if using ok() methoduse std::marker::Sized;
4848
if is_type_diagnostic_item(cx, cx.tables.expr_ty(&result_types[0]), sym!(result_type));

clippy_lints/src/infinite_iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const HEURISTICS: [(&str, usize, Heuristic, Finiteness); 19] = [
142142

143143
fn is_infinite(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Finiteness {
144144
match expr.kind {
145-
ExprKind::MethodCall(ref method, _, ref args) => {
145+
ExprKind::MethodCall(ref method, _, ref args, _) => {
146146
for &(name, len, heuristic, cap) in &HEURISTICS {
147147
if method.ident.name.as_str() == name && args.len() == len {
148148
return (match heuristic {
@@ -218,7 +218,7 @@ const INFINITE_COLLECTORS: [&[&str]; 8] = [
218218

219219
fn complete_infinite_iter(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Finiteness {
220220
match expr.kind {
221-
ExprKind::MethodCall(ref method, _, ref args) => {
221+
ExprKind::MethodCall(ref method, _, ref args, _) => {
222222
for &(name, len) in &COMPLETING_METHODS {
223223
if method.ident.name.as_str() == name && args.len() == len {
224224
return is_infinite(cx, &args[0]);

clippy_lints/src/len_zero.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item<'_>, impl_items: &[Imp
211211
}
212212

213213
fn check_cmp(cx: &LateContext<'_, '_>, span: Span, method: &Expr<'_>, lit: &Expr<'_>, op: &str, compare_to: u32) {
214-
if let (&ExprKind::MethodCall(ref method_path, _, ref args), &ExprKind::Lit(ref lit)) = (&method.kind, &lit.kind) {
214+
if let (&ExprKind::MethodCall(ref method_path, _, ref args, _), &ExprKind::Lit(ref lit)) = (&method.kind, &lit.kind)
215+
{
215216
// check if we are in an is_empty() method
216217
if let Some(name) = get_item_name(cx, method) {
217218
if name.as_str() == "is_empty" {

clippy_lints/src/lifetimes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
379379
TyKind::Path(ref path) => {
380380
self.collect_anonymous_lifetimes(path, ty);
381381
},
382-
TyKind::Def(item, _) => {
382+
TyKind::OpaqueDef(item, _) => {
383383
let map = self.cx.tcx.hir();
384384
if let ItemKind::OpaqueTy(ref exist_ty) = map.expect_item(item.id).kind {
385385
for bound in exist_ty.bounds {

0 commit comments

Comments
 (0)