Skip to content

Commit b40ea20

Browse files
committed
Auto merge of #7051 - flip1995:rustup, r=flip1995
Rustup changelog: none r? `@ghost`
2 parents db6ea84 + 61eafbb commit b40ea20

24 files changed

+65
-61
lines changed

clippy_lints/src/default_numeric_fallback.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc_middle::{
1313
ty::{self, FloatTy, IntTy, PolyFnSig, Ty},
1414
};
1515
use rustc_session::{declare_lint_pass, declare_tool_lint};
16+
use std::iter;
1617

1718
declare_clippy_lint! {
1819
/// **What it does:** Checks for usage of unconstrained numeric literals which may cause default numeric fallback in type
@@ -107,7 +108,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
107108
match &expr.kind {
108109
ExprKind::Call(func, args) => {
109110
if let Some(fn_sig) = fn_sig_opt(self.cx, func.hir_id) {
110-
for (expr, bound) in args.iter().zip(fn_sig.skip_binder().inputs().iter()) {
111+
for (expr, bound) in iter::zip(*args, fn_sig.skip_binder().inputs()) {
111112
// Push found arg type, then visit arg.
112113
self.ty_bounds.push(TyBound::Ty(bound));
113114
self.visit_expr(expr);
@@ -120,7 +121,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
120121
ExprKind::MethodCall(_, _, args, _) => {
121122
if let Some(def_id) = self.cx.typeck_results().type_dependent_def_id(expr.hir_id) {
122123
let fn_sig = self.cx.tcx.fn_sig(def_id).skip_binder();
123-
for (expr, bound) in args.iter().zip(fn_sig.inputs().iter()) {
124+
for (expr, bound) in iter::zip(*args, fn_sig.inputs()) {
124125
self.ty_bounds.push(TyBound::Ty(bound));
125126
self.visit_expr(expr);
126127
self.ty_bounds.pop();

clippy_lints/src/functions/must_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn check_needless_must_use(
115115
);
116116
},
117117
);
118-
} else if !attr.is_value_str() && is_must_use_ty(cx, return_ty(cx, item_id)) {
118+
} else if attr.value_str().is_none() && is_must_use_ty(cx, return_ty(cx, item_id)) {
119119
span_lint_and_help(
120120
cx,
121121
DOUBLE_MUST_USE,

clippy_lints/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![feature(box_syntax)]
55
#![feature(drain_filter)]
66
#![feature(in_band_lifetimes)]
7+
#![feature(iter_zip)]
78
#![feature(once_cell)]
89
#![feature(rustc_private)]
910
#![feature(stmt_expr_attributes)]

clippy_lints/src/literal_representation.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc_errors::Applicability;
1313
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
1414
use rustc_middle::lint::in_external_macro;
1515
use rustc_session::{declare_tool_lint, impl_lint_pass};
16+
use std::iter;
1617

1718
declare_clippy_lint! {
1819
/// **What it does:** Warns if a long integral or floating-point constant does
@@ -349,7 +350,7 @@ impl LiteralDigitGrouping {
349350

350351
let group_sizes: Vec<usize> = num_lit.integer.split('_').map(str::len).collect();
351352
if UUID_GROUP_LENS.len() == group_sizes.len() {
352-
UUID_GROUP_LENS.iter().zip(&group_sizes).all(|(&a, &b)| a == b)
353+
iter::zip(&UUID_GROUP_LENS, &group_sizes).all(|(&a, &b)| a == b)
353354
} else {
354355
false
355356
}

clippy_lints/src/loops/needless_range_loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_middle::hir::map::Map;
1717
use rustc_middle::middle::region;
1818
use rustc_middle::ty::{self, Ty};
1919
use rustc_span::symbol::{sym, Symbol};
20-
use std::iter::Iterator;
20+
use std::iter::{self, Iterator};
2121
use std::mem;
2222

2323
/// Checks for looping over a range and then indexing a sequence with it.
@@ -367,7 +367,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
367367
},
368368
ExprKind::MethodCall(_, _, args, _) => {
369369
let def_id = self.cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap();
370-
for (ty, expr) in self.cx.tcx.fn_sig(def_id).inputs().skip_binder().iter().zip(args) {
370+
for (ty, expr) in iter::zip(self.cx.tcx.fn_sig(def_id).inputs().skip_binder(), args) {
371371
self.prefer_mutable = false;
372372
if let ty::Ref(_, _, mutbl) = *ty.kind() {
373373
if mutbl == Mutability::Mut {

clippy_lints/src/loops/never_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
142142
.map(|(o, _)| match o {
143143
InlineAsmOperand::In { expr, .. }
144144
| InlineAsmOperand::InOut { expr, .. }
145-
| InlineAsmOperand::Const { expr }
146145
| InlineAsmOperand::Sym { expr } => never_loop_expr(expr, main_loop_id),
147146
InlineAsmOperand::Out { expr, .. } => never_loop_expr_all(&mut expr.iter(), main_loop_id),
148147
InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
149148
never_loop_expr_all(&mut once(in_expr).chain(out_expr.iter()), main_loop_id)
150149
},
150+
InlineAsmOperand::Const { .. } => NeverLoopResult::Otherwise,
151151
})
152152
.fold(NeverLoopResult::Otherwise, combine_both),
153153
ExprKind::Struct(_, _, None)

clippy_lints/src/matches.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use rustc_span::source_map::{Span, Spanned};
2929
use rustc_span::sym;
3030
use std::cmp::Ordering;
3131
use std::collections::hash_map::Entry;
32+
use std::iter;
3233
use std::ops::Bound;
3334

3435
declare_clippy_lint! {
@@ -1670,7 +1671,7 @@ where
16701671

16711672
values.sort();
16721673

1673-
for (a, b) in values.iter().zip(values.iter().skip(1)) {
1674+
for (a, b) in iter::zip(&values, values.iter().skip(1)) {
16741675
match (a, b) {
16751676
(&Kind::Start(_, ra), &Kind::End(_, rb)) => {
16761677
if ra.node != rb.node {

clippy_lints/src/missing_doc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ impl MissingDoc {
9393
return;
9494
}
9595

96-
let has_doc = attrs
97-
.iter()
98-
.any(|a| a.is_doc_comment() || a.doc_str().is_some() || a.is_value_str() || Self::has_include(a.meta()));
96+
let has_doc = attrs.iter().any(|a| {
97+
a.is_doc_comment() || a.doc_str().is_some() || a.value_str().is_some() || Self::has_include(a.meta())
98+
});
9999
if !has_doc {
100100
span_lint(
101101
cx,
@@ -121,7 +121,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
121121

122122
fn check_crate(&mut self, cx: &LateContext<'tcx>, krate: &'tcx hir::Crate<'_>) {
123123
let attrs = cx.tcx.hir().attrs(hir::CRATE_HIR_ID);
124-
self.check_missing_docs_attrs(cx, attrs, krate.item.span, "the", "crate");
124+
self.check_missing_docs_attrs(cx, attrs, krate.item.inner, "the", "crate");
125125
}
126126

127127
fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {

clippy_lints/src/mut_key.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_middle::ty::TypeFoldable;
66
use rustc_middle::ty::{Adt, Array, RawPtr, Ref, Slice, Tuple, Ty, TypeAndMut};
77
use rustc_session::{declare_lint_pass, declare_tool_lint};
88
use rustc_span::source_map::Span;
9+
use std::iter;
910

1011
declare_clippy_lint! {
1112
/// **What it does:** Checks for sets/maps with mutable key types.
@@ -87,7 +88,7 @@ impl<'tcx> LateLintPass<'tcx> for MutableKeyType {
8788
fn check_sig<'tcx>(cx: &LateContext<'tcx>, item_hir_id: hir::HirId, decl: &hir::FnDecl<'_>) {
8889
let fn_def_id = cx.tcx.hir().local_def_id(item_hir_id);
8990
let fn_sig = cx.tcx.fn_sig(fn_def_id);
90-
for (hir_ty, ty) in decl.inputs.iter().zip(fn_sig.inputs().skip_binder().iter()) {
91+
for (hir_ty, ty) in iter::zip(decl.inputs, fn_sig.inputs().skip_binder()) {
9192
check_ty(cx, hir_ty.span, ty);
9293
}
9394
check_ty(cx, decl.output.span(), cx.tcx.erase_late_bound_regions(fn_sig.output()));

clippy_lints/src/mut_reference.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use rustc_lint::{LateContext, LateLintPass};
44
use rustc_middle::ty::subst::Subst;
55
use rustc_middle::ty::{self, Ty};
66
use rustc_session::{declare_lint_pass, declare_tool_lint};
7+
use std::iter;
78

89
declare_clippy_lint! {
910
/// **What it does:** Detects passing a mutable reference to a function that only
@@ -64,7 +65,7 @@ fn check_arguments<'tcx>(
6465
match type_definition.kind() {
6566
ty::FnDef(..) | ty::FnPtr(_) => {
6667
let parameters = type_definition.fn_sig(cx.tcx).skip_binder().inputs();
67-
for (argument, parameter) in arguments.iter().zip(parameters.iter()) {
68+
for (argument, parameter) in iter::zip(arguments, parameters) {
6869
match parameter.kind() {
6970
ty::Ref(_, _, Mutability::Not)
7071
| ty::RawPtr(ty::TypeAndMut {

0 commit comments

Comments
 (0)