Skip to content

Commit a98e7ab

Browse files
committed
Auto merge of #8359 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents ea4db3a + b96e768 commit a98e7ab

File tree

166 files changed

+479
-795
lines changed

Some content is hidden

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

166 files changed

+479
-795
lines changed

clippy_lints/src/approx_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::{meets_msrv, msrvs};
33
use rustc_ast::ast::{FloatTy, LitFloatType, LitKind};
44
use rustc_hir::{Expr, ExprKind};
5-
use rustc_lint::{LateContext, LateLintPass, LintContext};
5+
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_semver::RustcVersion;
77
use rustc_session::{declare_tool_lint, impl_lint_pass};
88
use rustc_span::symbol;

clippy_lints/src/as_conversions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use rustc_ast::ast::{Expr, ExprKind};
3-
use rustc_lint::{EarlyContext, EarlyLintPass};
3+
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
44
use rustc_middle::lint::in_external_macro;
55
use rustc_session::{declare_lint_pass, declare_tool_lint};
66

@@ -48,7 +48,7 @@ declare_lint_pass!(AsConversions => [AS_CONVERSIONS]);
4848

4949
impl EarlyLintPass for AsConversions {
5050
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
51-
if in_external_macro(cx.sess, expr.span) {
51+
if in_external_macro(cx.sess(), expr.span) {
5252
return;
5353
}
5454

clippy_lints/src/assign_ops.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ use clippy_utils::{eq_expr_value, trait_ref_of_method};
66
use if_chain::if_chain;
77
use rustc_errors::Applicability;
88
use rustc_hir as hir;
9-
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
9+
use rustc_hir::intravisit::{walk_expr, Visitor};
1010
use rustc_lint::{LateContext, LateLintPass};
11-
use rustc_middle::hir::map::Map;
1211
use rustc_session::{declare_lint_pass, declare_tool_lint};
1312

1413
declare_clippy_lint! {
@@ -220,16 +219,11 @@ struct ExprVisitor<'a, 'tcx> {
220219
}
221220

222221
impl<'a, 'tcx> Visitor<'tcx> for ExprVisitor<'a, 'tcx> {
223-
type Map = Map<'tcx>;
224-
225222
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
226223
if eq_expr_value(self.cx, self.assignee, expr) {
227224
self.counter += 1;
228225
}
229226

230227
walk_expr(self, expr);
231228
}
232-
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
233-
NestedVisitorMap::None
234-
}
235229
}

clippy_lints/src/blocks_in_if_conditions.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ use clippy_utils::ty::implements_trait;
55
use clippy_utils::{differing_macro_contexts, get_parent_expr};
66
use if_chain::if_chain;
77
use rustc_errors::Applicability;
8-
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
8+
use rustc_hir::intravisit::{walk_expr, Visitor};
99
use rustc_hir::{BlockCheckMode, Expr, ExprKind};
1010
use rustc_lint::{LateContext, LateLintPass, LintContext};
11-
use rustc_middle::hir::map::Map;
1211
use rustc_middle::lint::in_external_macro;
1312
use rustc_session::{declare_lint_pass, declare_tool_lint};
1413
use rustc_span::sym;
@@ -55,14 +54,12 @@ struct ExVisitor<'a, 'tcx> {
5554
}
5655

5756
impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
58-
type Map = Map<'tcx>;
59-
6057
fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
6158
if let ExprKind::Closure(_, _, eid, _, _) = expr.kind {
6259
// do not lint if the closure is called using an iterator (see #1141)
6360
if_chain! {
6461
if let Some(parent) = get_parent_expr(self.cx, expr);
65-
if let ExprKind::MethodCall(_, _, [self_arg, ..], _) = &parent.kind;
62+
if let ExprKind::MethodCall(_, [self_arg, ..], _) = &parent.kind;
6663
let caller = self.cx.typeck_results().expr_ty(self_arg);
6764
if let Some(iter_id) = self.cx.tcx.get_diagnostic_item(sym::Iterator);
6865
if implements_trait(self.cx, caller, iter_id, &[]);
@@ -82,9 +79,6 @@ impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
8279
}
8380
walk_expr(self, expr);
8481
}
85-
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
86-
NestedVisitorMap::None
87-
}
8882
}
8983

9084
const BRACED_EXPR_MESSAGE: &str = "omit braces around single expression condition";

clippy_lints/src/booleans.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ use clippy_utils::{eq_expr_value, get_trait_def_id, paths};
55
use if_chain::if_chain;
66
use rustc_ast::ast::LitKind;
77
use rustc_errors::Applicability;
8-
use rustc_hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
8+
use rustc_hir::intravisit::{walk_expr, FnKind, Visitor};
99
use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, HirId, UnOp};
1010
use rustc_lint::{LateContext, LateLintPass};
11-
use rustc_middle::hir::map::Map;
1211
use rustc_session::{declare_lint_pass, declare_tool_lint};
1312
use rustc_span::source_map::Span;
1413
use rustc_span::sym;
@@ -260,7 +259,7 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<String> {
260259
))
261260
})
262261
},
263-
ExprKind::MethodCall(path, _, args, _) if args.len() == 1 => {
262+
ExprKind::MethodCall(path, args, _) if args.len() == 1 => {
264263
let type_of_receiver = cx.typeck_results().expr_ty(&args[0]);
265264
if !is_type_diagnostic_item(cx, type_of_receiver, sym::Option)
266265
&& !is_type_diagnostic_item(cx, type_of_receiver, sym::Result)
@@ -452,8 +451,6 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
452451
}
453452

454453
impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
455-
type Map = Map<'tcx>;
456-
457454
fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
458455
if !e.span.from_expansion() {
459456
match &e.kind {
@@ -470,9 +467,6 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
470467
}
471468
walk_expr(self, e);
472469
}
473-
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
474-
NestedVisitorMap::None
475-
}
476470
}
477471

478472
fn implements_ord<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> bool {
@@ -485,8 +479,6 @@ struct NotSimplificationVisitor<'a, 'tcx> {
485479
}
486480

487481
impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> {
488-
type Map = Map<'tcx>;
489-
490482
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
491483
if let ExprKind::Unary(UnOp::Not, inner) = &expr.kind {
492484
if let Some(suggestion) = simplify_not(self.cx, inner) {
@@ -504,7 +496,4 @@ impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> {
504496

505497
walk_expr(self, expr);
506498
}
507-
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
508-
NestedVisitorMap::None
509-
}
510499
}

clippy_lints/src/borrow_as_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clippy_utils::{meets_msrv, msrvs};
55
use if_chain::if_chain;
66
use rustc_errors::Applicability;
77
use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, TyKind};
8-
use rustc_lint::{LateContext, LateLintPass, LintContext};
8+
use rustc_lint::{LateContext, LateLintPass};
99
use rustc_semver::RustcVersion;
1010
use rustc_session::{declare_tool_lint, impl_lint_pass};
1111

clippy_lints/src/bytecount.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ declare_lint_pass!(ByteCount => [NAIVE_BYTECOUNT]);
4141
impl<'tcx> LateLintPass<'tcx> for ByteCount {
4242
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
4343
if_chain! {
44-
if let ExprKind::MethodCall(count, _, [count_recv], _) = expr.kind;
44+
if let ExprKind::MethodCall(count, [count_recv], _) = expr.kind;
4545
if count.ident.name == sym::count;
46-
if let ExprKind::MethodCall(filter, _, [filter_recv, filter_arg], _) = count_recv.kind;
46+
if let ExprKind::MethodCall(filter, [filter_recv, filter_arg], _) = count_recv.kind;
4747
if filter.ident.name == sym!(filter);
4848
if let ExprKind::Closure(_, _, body_id, _, _) = filter_arg.kind;
4949
let body = cx.tcx.hir().body(body_id);
@@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
6868
if ty::Uint(UintTy::U8) == *cx.typeck_results().expr_ty(needle).peel_refs().kind();
6969
if !is_local_used(cx, needle, arg_id);
7070
then {
71-
let haystack = if let ExprKind::MethodCall(path, _, args, _) =
71+
let haystack = if let ExprKind::MethodCall(path, args, _) =
7272
filter_recv.kind {
7373
let p = path.ident.name;
7474
if (p == sym::iter || p == sym!(iter_mut)) && args.len() == 1 {

clippy_lints/src/case_sensitive_file_extension_comparisons.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ declare_lint_pass!(CaseSensitiveFileExtensionComparisons => [CASE_SENSITIVE_FILE
3737

3838
fn check_case_sensitive_file_extension_comparison(ctx: &LateContext<'_>, expr: &Expr<'_>) -> Option<Span> {
3939
if_chain! {
40-
if let ExprKind::MethodCall(PathSegment { ident, .. }, _, [obj, extension, ..], span) = expr.kind;
40+
if let ExprKind::MethodCall(PathSegment { ident, .. }, [obj, extension, ..], span) = expr.kind;
4141
if ident.as_str() == "ends_with";
4242
if let ExprKind::Lit(Spanned { node: LitKind::Str(ext_literal, ..), ..}) = extension.kind;
4343
if (2..=6).contains(&ext_literal.as_str().len());

clippy_lints/src/casts/cast_possible_truncation.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn apply_reductions(cx: &LateContext<'_>, nbits: u64, expr: &Expr<'_>, signed: b
4343
},
4444
_ => nbits,
4545
},
46-
ExprKind::MethodCall(method, _, [left, right], _) => {
46+
ExprKind::MethodCall(method, [left, right], _) => {
4747
if signed {
4848
return nbits;
4949
}
@@ -54,7 +54,7 @@ fn apply_reductions(cx: &LateContext<'_>, nbits: u64, expr: &Expr<'_>, signed: b
5454
};
5555
apply_reductions(cx, nbits, left, signed).min(max_bits.unwrap_or(u64::max_value()))
5656
},
57-
ExprKind::MethodCall(method, _, [_, lo, hi], _) => {
57+
ExprKind::MethodCall(method, [_, lo, hi], _) => {
5858
if method.ident.as_str() == "clamp" {
5959
//FIXME: make this a diagnostic item
6060
if let (Some(lo_bits), Some(hi_bits)) = (get_constant_bits(cx, lo), get_constant_bits(cx, hi)) {
@@ -63,7 +63,7 @@ fn apply_reductions(cx: &LateContext<'_>, nbits: u64, expr: &Expr<'_>, signed: b
6363
}
6464
nbits
6565
},
66-
ExprKind::MethodCall(method, _, [_value], _) => {
66+
ExprKind::MethodCall(method, [_value], _) => {
6767
if method.ident.name.as_str() == "signum" {
6868
0 // do not lint if cast comes from a `signum` function
6969
} else {

clippy_lints/src/casts/cast_ptr_alignment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
1919
cx.typeck_results().expr_ty(expr),
2020
);
2121
lint_cast_ptr_alignment(cx, expr, cast_from, cast_to);
22-
} else if let ExprKind::MethodCall(method_path, _, [self_arg, ..], _) = &expr.kind {
22+
} else if let ExprKind::MethodCall(method_path, [self_arg, ..], _) = &expr.kind {
2323
if_chain! {
2424
if method_path.ident.name == sym!(cast);
2525
if let Some(generic_args) = method_path.args;

clippy_lints/src/casts/cast_sign_loss.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ fn should_lint(cx: &LateContext<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast
4141
}
4242

4343
// Don't lint for the result of methods that always return non-negative values.
44-
if let ExprKind::MethodCall(path, _, _, _) = cast_op.kind {
44+
if let ExprKind::MethodCall(path, _, _) = cast_op.kind {
4545
let mut method_name = path.ident.name.as_str();
4646
let allowed_methods = ["abs", "checked_abs", "rem_euclid", "checked_rem_euclid"];
4747

4848
if_chain! {
4949
if method_name == "unwrap";
5050
if let Some(arglist) = method_chain_args(cast_op, &["unwrap"]);
51-
if let ExprKind::MethodCall(inner_path, _, _, _) = &arglist[0][0].kind;
51+
if let ExprKind::MethodCall(inner_path, _, _) = &arglist[0][0].kind;
5252
then {
5353
method_name = inner_path.ident.name.as_str();
5454
}

clippy_lints/src/cognitive_complexity.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ use clippy_utils::source::snippet_opt;
55
use clippy_utils::ty::is_type_diagnostic_item;
66
use clippy_utils::LimitStack;
77
use rustc_ast::ast::Attribute;
8-
use rustc_hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
8+
use rustc_hir::intravisit::{walk_expr, FnKind, Visitor};
99
use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId};
1010
use rustc_lint::{LateContext, LateLintPass, LintContext};
11-
use rustc_middle::hir::map::Map;
1211
use rustc_session::{declare_tool_lint, impl_lint_pass};
1312
use rustc_span::source_map::Span;
1413
use rustc_span::{sym, BytePos};
@@ -149,8 +148,6 @@ struct CcHelper {
149148
}
150149

151150
impl<'tcx> Visitor<'tcx> for CcHelper {
152-
type Map = Map<'tcx>;
153-
154151
fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
155152
walk_expr(self, e);
156153
match e.kind {
@@ -167,7 +164,4 @@ impl<'tcx> Visitor<'tcx> for CcHelper {
167164
_ => {},
168165
}
169166
}
170-
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
171-
NestedVisitorMap::None
172-
}
173167
}

clippy_lints/src/copies.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use clippy_utils::{
77
use if_chain::if_chain;
88
use rustc_data_structures::fx::FxHashSet;
99
use rustc_errors::{Applicability, DiagnosticBuilder};
10-
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
10+
use rustc_hir::intravisit::{self, Visitor};
1111
use rustc_hir::{Block, Expr, ExprKind, HirId};
1212
use rustc_lint::{LateContext, LateLintPass, LintContext};
13-
use rustc_middle::hir::map::Map;
13+
use rustc_middle::hir::nested_filter;
1414
use rustc_session::{declare_lint_pass, declare_tool_lint};
1515
use rustc_span::{source_map::Span, symbol::Symbol, BytePos};
1616
use std::borrow::Cow;
@@ -566,10 +566,10 @@ impl<'a, 'tcx> UsedValueFinderVisitor<'a, 'tcx> {
566566
}
567567

568568
impl<'a, 'tcx> Visitor<'tcx> for UsedValueFinderVisitor<'a, 'tcx> {
569-
type Map = Map<'tcx>;
569+
type NestedFilter = nested_filter::All;
570570

571-
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
572-
NestedVisitorMap::All(self.cx.tcx.hir())
571+
fn nested_visit_map(&mut self) -> Self::Map {
572+
self.cx.tcx.hir()
573573
}
574574

575575
fn visit_local(&mut self, l: &'tcx rustc_hir::Local<'tcx>) {

clippy_lints/src/default_numeric_fallback.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ use if_chain::if_chain;
55
use rustc_ast::ast::{LitFloatType, LitIntType, LitKind};
66
use rustc_errors::Applicability;
77
use rustc_hir::{
8-
intravisit::{walk_expr, walk_stmt, NestedVisitorMap, Visitor},
8+
intravisit::{walk_expr, walk_stmt, Visitor},
99
Body, Expr, ExprKind, HirId, Lit, Stmt, StmtKind,
1010
};
1111
use rustc_lint::{LateContext, LateLintPass, LintContext};
1212
use rustc_middle::{
13-
hir::map::Map,
1413
lint::in_external_macro,
1514
ty::{self, FloatTy, IntTy, PolyFnSig, Ty},
1615
};
@@ -117,8 +116,6 @@ impl<'a, 'tcx> NumericFallbackVisitor<'a, 'tcx> {
117116
}
118117

119118
impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
120-
type Map = Map<'tcx>;
121-
122119
#[allow(clippy::too_many_lines)]
123120
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
124121
match &expr.kind {
@@ -134,7 +131,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
134131
}
135132
},
136133

137-
ExprKind::MethodCall(_, _, args, _) => {
134+
ExprKind::MethodCall(_, args, _) => {
138135
if let Some(def_id) = self.cx.typeck_results().type_dependent_def_id(expr.hir_id) {
139136
let fn_sig = self.cx.tcx.fn_sig(def_id).skip_binder();
140137
for (expr, bound) in iter::zip(*args, fn_sig.inputs()) {
@@ -209,10 +206,6 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
209206
walk_stmt(self, stmt);
210207
self.ty_bounds.pop();
211208
}
212-
213-
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
214-
NestedVisitorMap::None
215-
}
216209
}
217210

218211
fn fn_sig_opt<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<PolyFnSig<'tcx>> {

clippy_lints/src/dereference.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ fn try_parse_ref_op<'tcx>(
420420
expr: &'tcx Expr<'_>,
421421
) -> Option<(RefOp, &'tcx Expr<'tcx>)> {
422422
let (def_id, arg) = match expr.kind {
423-
ExprKind::MethodCall(_, _, [arg], _) => (typeck.type_dependent_def_id(expr.hir_id)?, arg),
423+
ExprKind::MethodCall(_, [arg], _) => (typeck.type_dependent_def_id(expr.hir_id)?, arg),
424424
ExprKind::Call(
425425
Expr {
426426
kind: ExprKind::Path(path),
@@ -467,7 +467,7 @@ fn is_linted_explicit_deref_position(parent: Option<Node<'_>>, child_id: HirId,
467467
match parent.kind {
468468
// Leave deref calls in the middle of a method chain.
469469
// e.g. x.deref().foo()
470-
ExprKind::MethodCall(_, _, [self_arg, ..], _) if self_arg.hir_id == child_id => false,
470+
ExprKind::MethodCall(_, [self_arg, ..], _) if self_arg.hir_id == child_id => false,
471471

472472
// Leave deref calls resulting in a called function
473473
// e.g. (x.deref())()
@@ -508,7 +508,6 @@ fn is_linted_explicit_deref_position(parent: Option<Node<'_>>, child_id: HirId,
508508
| ExprKind::Continue(..)
509509
| ExprKind::Ret(..)
510510
| ExprKind::InlineAsm(..)
511-
| ExprKind::LlvmInlineAsm(..)
512511
| ExprKind::Struct(..)
513512
| ExprKind::Repeat(..)
514513
| ExprKind::Yield(..) => true,
@@ -529,7 +528,7 @@ fn is_auto_reborrow_position(parent: Option<Node<'_>>) -> bool {
529528
fn is_auto_borrow_position(parent: Option<Node<'_>>, child_id: HirId) -> bool {
530529
if let Some(Node::Expr(parent)) = parent {
531530
match parent.kind {
532-
ExprKind::MethodCall(_, _, [self_arg, ..], _) => self_arg.hir_id == child_id,
531+
ExprKind::MethodCall(_, [self_arg, ..], _) => self_arg.hir_id == child_id,
533532
ExprKind::Field(..) => true,
534533
ExprKind::Call(f, _) => f.hir_id == child_id,
535534
_ => false,

0 commit comments

Comments
 (0)