]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillot
authorbors <bors@rust-lang.org>
Tue, 25 Jan 2022 18:53:45 +0000 (18:53 +0000)
committerbors <bors@rust-lang.org>
Tue, 25 Jan 2022 18:53:45 +0000 (18:53 +0000)
Store a `Symbol` instead of an `Ident` in `AssocItem`

This is the same idea as #92533, but for `AssocItem` instead
of `VariantDef`/`FieldDef`.

With this change, we no longer have any uses of
`#[stable_hasher(project(...))]`

115 files changed:
clippy_lints/src/approx_const.rs
clippy_lints/src/as_conversions.rs
clippy_lints/src/blocks_in_if_conditions.rs
clippy_lints/src/booleans.rs
clippy_lints/src/bytecount.rs
clippy_lints/src/case_sensitive_file_extension_comparisons.rs
clippy_lints/src/casts/cast_possible_truncation.rs
clippy_lints/src/casts/cast_ptr_alignment.rs
clippy_lints/src/casts/cast_sign_loss.rs
clippy_lints/src/default_numeric_fallback.rs
clippy_lints/src/dereference.rs
clippy_lints/src/disallowed_script_idents.rs
clippy_lints/src/duration_subsec.rs
clippy_lints/src/else_if_without_else.rs
clippy_lints/src/entry.rs
clippy_lints/src/eta_reduction.rs
clippy_lints/src/explicit_write.rs
clippy_lints/src/floating_point_arithmetic.rs
clippy_lints/src/format_args.rs
clippy_lints/src/formatting.rs
clippy_lints/src/from_over_into.rs
clippy_lints/src/functions/must_use.rs
clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs
clippy_lints/src/get_last_with_len.rs
clippy_lints/src/if_let_mutex.rs
clippy_lints/src/index_refutable_slice.rs
clippy_lints/src/infinite_iter.rs
clippy_lints/src/items_after_statements.rs
clippy_lints/src/len_zero.rs
clippy_lints/src/literal_representation.rs
clippy_lints/src/loops/manual_memcpy.rs
clippy_lints/src/loops/mod.rs
clippy_lints/src/loops/needless_collect.rs
clippy_lints/src/loops/needless_range_loop.rs
clippy_lints/src/loops/never_loop.rs
clippy_lints/src/loops/same_item_push.rs
clippy_lints/src/loops/single_element_loop.rs
clippy_lints/src/loops/while_let_on_iterator.rs
clippy_lints/src/manual_non_exhaustive.rs
clippy_lints/src/manual_ok_or.rs
clippy_lints/src/manual_strip.rs
clippy_lints/src/map_clone.rs
clippy_lints/src/map_err_ignore.rs
clippy_lints/src/map_unit_fn.rs
clippy_lints/src/match_result_ok.rs
clippy_lints/src/match_str_case_mismatch.rs
clippy_lints/src/matches.rs
clippy_lints/src/mem_replace.rs
clippy_lints/src/methods/bind_instead_of_map.rs
clippy_lints/src/methods/clone_on_copy.rs
clippy_lints/src/methods/expect_fun_call.rs
clippy_lints/src/methods/extend_with_drain.rs
clippy_lints/src/methods/filter_map.rs
clippy_lints/src/methods/mod.rs
clippy_lints/src/methods/option_as_ref_deref.rs
clippy_lints/src/methods/str_splitn.rs
clippy_lints/src/methods/unnecessary_iter_cloned.rs
clippy_lints/src/methods/unnecessary_to_owned.rs
clippy_lints/src/methods/useless_asref.rs
clippy_lints/src/methods/utils.rs
clippy_lints/src/minmax.rs
clippy_lints/src/misc.rs
clippy_lints/src/misc_early/mod.rs
clippy_lints/src/missing_const_for_fn.rs
clippy_lints/src/module_style.rs
clippy_lints/src/mut_mutex_lock.rs
clippy_lints/src/mut_reference.rs
clippy_lints/src/needless_for_each.rs
clippy_lints/src/needless_option_as_deref.rs
clippy_lints/src/non_expressive_names.rs
clippy_lints/src/non_octal_unix_permissions.rs
clippy_lints/src/octal_escapes.rs
clippy_lints/src/open_options.rs
clippy_lints/src/option_if_let_else.rs
clippy_lints/src/path_buf_push_overwrite.rs
clippy_lints/src/ptr_offset_with_cast.rs
clippy_lints/src/question_mark.rs
clippy_lints/src/ranges.rs
clippy_lints/src/redundant_closure_call.rs
clippy_lints/src/redundant_else.rs
clippy_lints/src/redundant_field_names.rs
clippy_lints/src/repeat_once.rs
clippy_lints/src/single_char_lifetime_names.rs
clippy_lints/src/single_component_path_imports.rs
clippy_lints/src/size_of_in_element_count.rs
clippy_lints/src/slow_vector_initialization.rs
clippy_lints/src/stable_sort_primitive.rs
clippy_lints/src/strings.rs
clippy_lints/src/strlen_on_c_strings.rs
clippy_lints/src/to_digit_is_some.rs
clippy_lints/src/to_string_in_display.rs
clippy_lints/src/uninit_vec.rs
clippy_lints/src/unit_hash.rs
clippy_lints/src/unit_return_expecting_ord.rs
clippy_lints/src/unit_types/unit_arg.rs
clippy_lints/src/unnecessary_sort_by.rs
clippy_lints/src/unused_io_amount.rs
clippy_lints/src/unwrap.rs
clippy_lints/src/use_self.rs
clippy_lints/src/utils/author.rs
clippy_lints/src/utils/inspector.rs
clippy_lints/src/utils/internal_lints.rs
clippy_lints/src/utils/internal_lints/metadata_collector.rs
clippy_lints/src/vec_init_then_push.rs
clippy_lints/src/vec_resize_to_zero.rs
clippy_lints/src/verbose_file_reads.rs
clippy_lints/src/write.rs
clippy_utils/src/eager_or_lazy.rs
clippy_utils/src/hir_utils.rs
clippy_utils/src/lib.rs
clippy_utils/src/ptr.rs
clippy_utils/src/sugg.rs
doc/common_tools_writing_lints.md
tests/ui/author/struct.stdout
tests/ui/to_string_in_display.stderr

index 5061c9d1eaf6f41a4a68b1c23a211b4ffb863c83..e109ee0009ee0f624e725acad27ca90dbfc36995 100644 (file)
@@ -2,7 +2,7 @@
 use clippy_utils::{meets_msrv, msrvs};
 use rustc_ast::ast::{FloatTy, LitFloatType, LitKind};
 use rustc_hir::{Expr, ExprKind};
-use rustc_lint::{LateContext, LateLintPass, LintContext};
+use rustc_lint::{LateContext, LateLintPass};
 use rustc_semver::RustcVersion;
 use rustc_session::{declare_tool_lint, impl_lint_pass};
 use rustc_span::symbol;
index 53704da1046bcf236a5a511c0b83a5557b6ba4ab..88b91d589074d85e300c79979bab0d89269e1b6a 100644 (file)
@@ -1,6 +1,6 @@
 use clippy_utils::diagnostics::span_lint_and_help;
 use rustc_ast::ast::{Expr, ExprKind};
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_middle::lint::in_external_macro;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 
@@ -48,7 +48,7 @@
 
 impl EarlyLintPass for AsConversions {
     fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
-        if in_external_macro(cx.sess, expr.span) {
+        if in_external_macro(cx.sess(), expr.span) {
             return;
         }
 
index b3f9c1b297679f8a8774ba2c54d34cece15f0c87..c4956bacf43617a3de0ed2a747e6d377af022430 100644 (file)
@@ -59,7 +59,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
             // do not lint if the closure is called using an iterator (see #1141)
             if_chain! {
                 if let Some(parent) = get_parent_expr(self.cx, expr);
-                if let ExprKind::MethodCall(_, _, [self_arg, ..], _) = &parent.kind;
+                if let ExprKind::MethodCall(_, [self_arg, ..], _) = &parent.kind;
                 let caller = self.cx.typeck_results().expr_ty(self_arg);
                 if let Some(iter_id) = self.cx.tcx.get_diagnostic_item(sym::Iterator);
                 if implements_trait(self.cx, caller, iter_id, &[]);
index 7ffc8ecd31e5d37348b107bbd7572d7f583a9ced..f7449c8dc72ed584a839c418bf2dd25de2c31d37 100644 (file)
@@ -259,7 +259,7 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<String> {
                 ))
             })
         },
-        ExprKind::MethodCall(path, _, args, _) if args.len() == 1 => {
+        ExprKind::MethodCall(path, args, _) if args.len() == 1 => {
             let type_of_receiver = cx.typeck_results().expr_ty(&args[0]);
             if !is_type_diagnostic_item(cx, type_of_receiver, sym::Option)
                 && !is_type_diagnostic_item(cx, type_of_receiver, sym::Result)
index 92336a54e27ee2ec3f0e1fb2522c36d2f22513d4..02d97bf43df83d50587d50b9669ee205230766a4 100644 (file)
@@ -41,9 +41,9 @@
 impl<'tcx> LateLintPass<'tcx> for ByteCount {
     fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
         if_chain! {
-            if let ExprKind::MethodCall(count, _, [count_recv], _) = expr.kind;
+            if let ExprKind::MethodCall(count, [count_recv], _) = expr.kind;
             if count.ident.name == sym::count;
-            if let ExprKind::MethodCall(filter, _, [filter_recv, filter_arg], _) = count_recv.kind;
+            if let ExprKind::MethodCall(filter, [filter_recv, filter_arg], _) = count_recv.kind;
             if filter.ident.name == sym!(filter);
             if let ExprKind::Closure(_, _, body_id, _, _) = filter_arg.kind;
             let body = cx.tcx.hir().body(body_id);
@@ -68,7 +68,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
             if ty::Uint(UintTy::U8) == *cx.typeck_results().expr_ty(needle).peel_refs().kind();
             if !is_local_used(cx, needle, arg_id);
             then {
-                let haystack = if let ExprKind::MethodCall(path, _, args, _) =
+                let haystack = if let ExprKind::MethodCall(path, args, _) =
                         filter_recv.kind {
                     let p = path.ident.name;
                     if (p == sym::iter || p == sym!(iter_mut)) && args.len() == 1 {
index e8f39cd37090d2f14fd64fedb0ae629ae19eb942..e71f110820c0b83111e7ce23824e9f3fd98c4430 100644 (file)
@@ -37,7 +37,7 @@
 
 fn check_case_sensitive_file_extension_comparison(ctx: &LateContext<'_>, expr: &Expr<'_>) -> Option<Span> {
     if_chain! {
-        if let ExprKind::MethodCall(PathSegment { ident, .. }, _, [obj, extension, ..], span) = expr.kind;
+        if let ExprKind::MethodCall(PathSegment { ident, .. }, [obj, extension, ..], span) = expr.kind;
         if ident.as_str() == "ends_with";
         if let ExprKind::Lit(Spanned { node: LitKind::Str(ext_literal, ..), ..}) = extension.kind;
         if (2..=6).contains(&ext_literal.as_str().len());
index 4af412ccaf35d7d0946429c5b997f9ae7081792e..ea74d5acbda0528ade62cc8b1d0aca92cf2fc7f4 100644 (file)
@@ -43,7 +43,7 @@ fn apply_reductions(cx: &LateContext<'_>, nbits: u64, expr: &Expr<'_>, signed: b
             },
             _ => nbits,
         },
-        ExprKind::MethodCall(method, _, [left, right], _) => {
+        ExprKind::MethodCall(method, [left, right], _) => {
             if signed {
                 return nbits;
             }
@@ -54,7 +54,7 @@ fn apply_reductions(cx: &LateContext<'_>, nbits: u64, expr: &Expr<'_>, signed: b
             };
             apply_reductions(cx, nbits, left, signed).min(max_bits.unwrap_or(u64::max_value()))
         },
-        ExprKind::MethodCall(method, _, [_, lo, hi], _) => {
+        ExprKind::MethodCall(method, [_, lo, hi], _) => {
             if method.ident.as_str() == "clamp" {
                 //FIXME: make this a diagnostic item
                 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
             }
             nbits
         },
-        ExprKind::MethodCall(method, _, [_value], _) => {
+        ExprKind::MethodCall(method, [_value], _) => {
             if method.ident.name.as_str() == "signum" {
                 0 // do not lint if cast comes from a `signum` function
             } else {
index b9de5510455b9e7bdb3351b8e61c7bf27514d990..079b7ff0675b4b34ad1b8d96e7a5e7810a2bf811 100644 (file)
@@ -19,7 +19,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
             cx.typeck_results().expr_ty(expr),
         );
         lint_cast_ptr_alignment(cx, expr, cast_from, cast_to);
-    } else if let ExprKind::MethodCall(method_path, _, [self_arg, ..], _) = &expr.kind {
+    } else if let ExprKind::MethodCall(method_path, [self_arg, ..], _) = &expr.kind {
         if_chain! {
             if method_path.ident.name == sym!(cast);
             if let Some(generic_args) = method_path.args;
index c9c111a2847af31f2d568b65b7ff30d7f36e92a0..75f70b77ed4e7d34a07a52467ab4c7f61e563053 100644 (file)
@@ -41,14 +41,14 @@ fn should_lint(cx: &LateContext<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast
             }
 
             // Don't lint for the result of methods that always return non-negative values.
-            if let ExprKind::MethodCall(path, _, _, _) = cast_op.kind {
+            if let ExprKind::MethodCall(path, _, _) = cast_op.kind {
                 let mut method_name = path.ident.name.as_str();
                 let allowed_methods = ["abs", "checked_abs", "rem_euclid", "checked_rem_euclid"];
 
                 if_chain! {
                     if method_name == "unwrap";
                     if let Some(arglist) = method_chain_args(cast_op, &["unwrap"]);
-                    if let ExprKind::MethodCall(inner_path, _, _, _) = &arglist[0][0].kind;
+                    if let ExprKind::MethodCall(inner_path, _, _) = &arglist[0][0].kind;
                     then {
                         method_name = inner_path.ident.name.as_str();
                     }
index 78acdb5dfd580bd7906c298a28ca05f3bf51e76d..fb201d2c012b19f9927a8f371ad91cabaa886c96 100644 (file)
@@ -131,7 +131,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
                 }
             },
 
-            ExprKind::MethodCall(_, _, args, _) => {
+            ExprKind::MethodCall(_, args, _) => {
                 if let Some(def_id) = self.cx.typeck_results().type_dependent_def_id(expr.hir_id) {
                     let fn_sig = self.cx.tcx.fn_sig(def_id).skip_binder();
                     for (expr, bound) in iter::zip(*args, fn_sig.inputs()) {
index af46e99c6446ef9c487328eb28f77aff18a7f329..feb5f100de5d5871904bfb47cb469d7b93b2fb82 100644 (file)
@@ -361,7 +361,7 @@ fn try_parse_ref_op<'tcx>(
     expr: &'tcx Expr<'_>,
 ) -> Option<(RefOp, &'tcx Expr<'tcx>)> {
     let (def_id, arg) = match expr.kind {
-        ExprKind::MethodCall(_, _, [arg], _) => (typeck.type_dependent_def_id(expr.hir_id)?, arg),
+        ExprKind::MethodCall(_, [arg], _) => (typeck.type_dependent_def_id(expr.hir_id)?, arg),
         ExprKind::Call(
             Expr {
                 kind: ExprKind::Path(path),
@@ -408,7 +408,7 @@ fn is_linted_explicit_deref_position(parent: Option<Node<'_>>, child_id: HirId,
     match parent.kind {
         // Leave deref calls in the middle of a method chain.
         // e.g. x.deref().foo()
-        ExprKind::MethodCall(_, _, [self_arg, ..], _) if self_arg.hir_id == child_id => false,
+        ExprKind::MethodCall(_, [self_arg, ..], _) if self_arg.hir_id == child_id => false,
 
         // Leave deref calls resulting in a called function
         // e.g. (x.deref())()
index 3c3f3631849e58dc1b44a8da92edf70d84dff02d..0c27c3f9255f28585175bf42c52833860a1d5760 100644 (file)
@@ -1,7 +1,7 @@
 use clippy_utils::diagnostics::span_lint;
 use rustc_ast::ast;
 use rustc_data_structures::fx::FxHashSet;
-use rustc_lint::{EarlyContext, EarlyLintPass, Level};
+use rustc_lint::{EarlyContext, EarlyLintPass, Level, LintContext};
 use rustc_session::{declare_tool_lint, impl_lint_pass};
 use unicode_script::{Script, UnicodeScript};
 
@@ -72,7 +72,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
             return;
         }
 
-        let symbols = cx.sess.parse_sess.symbol_gallery.symbols.lock();
+        let symbols = cx.sess().parse_sess.symbol_gallery.symbols.lock();
         // Sort by `Span` so that error messages make sense with respect to the
         // order of identifier locations in the code.
         let mut symbols: Vec<_> = symbols.iter().collect();
index 50dd0d84fda518f0d3d4663c694187f8e0d55128..24e32c09f44b3252d158653ef366eb8bb66a8e28 100644 (file)
@@ -45,7 +45,7 @@ impl<'tcx> LateLintPass<'tcx> for DurationSubsec {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         if_chain! {
             if let ExprKind::Binary(Spanned { node: BinOpKind::Div, .. }, left, right) = expr.kind;
-            if let ExprKind::MethodCall(method_path, _ , args, _) = left.kind;
+            if let ExprKind::MethodCall(method_path, args, _) = left.kind;
             if match_type(cx, cx.typeck_results().expr_ty(&args[0]).peel_refs(), &paths::DURATION);
             if let Some((Constant::Int(divisor), _)) = constant(cx, cx.typeck_results(), right);
             then {
index 92c56c762aad61624155680f632f127a5f1c683d..0b9f54231c59bc8566e06b8599ec04e9242893ac 100644 (file)
@@ -2,7 +2,7 @@
 
 use clippy_utils::diagnostics::span_lint_and_help;
 use rustc_ast::ast::{Expr, ExprKind};
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_middle::lint::in_external_macro;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 
@@ -50,7 +50,7 @@
 
 impl EarlyLintPass for ElseIfWithoutElse {
     fn check_expr(&mut self, cx: &EarlyContext<'_>, mut item: &Expr) {
-        if in_external_macro(cx.sess, item.span) {
+        if in_external_macro(cx.sess(), item.span) {
             return;
         }
 
index 9c0a966b0beef16b68bf8e8ab80d7f566cce5a39..1ae2e20c1e060e78aa206ee20a25f31c05f59c65 100644 (file)
@@ -244,7 +244,6 @@ fn try_parse_contains<'tcx>(cx: &LateContext<'_>, expr: &'tcx Expr<'_>) -> Optio
     });
     match expr.kind {
         ExprKind::MethodCall(
-            _,
             _,
             [
                 map,
@@ -281,7 +280,7 @@ struct InsertExpr<'tcx> {
     value: &'tcx Expr<'tcx>,
 }
 fn try_parse_insert<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<InsertExpr<'tcx>> {
-    if let ExprKind::MethodCall(_, _, [map, key, value], _) = expr.kind {
+    if let ExprKind::MethodCall(_, [map, key, value], _) = expr.kind {
         let id = cx.typeck_results().type_dependent_def_id(expr.hir_id)?;
         if match_def_path(cx, id, &paths::BTREEMAP_INSERT) || match_def_path(cx, id, &paths::HASHMAP_INSERT) {
             Some(InsertExpr { map, key, value })
index b22515a39079a2518ece04f75e10d3601e235fc2..263bff4873caf4cb45af2f3efdd8bb95dd31bbf1 100644 (file)
@@ -144,7 +144,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         );
 
         if_chain!(
-            if let ExprKind::MethodCall(path, _, args, _) = body.value.kind;
+            if let ExprKind::MethodCall(path, args, _) = body.value.kind;
             if check_inputs(cx, body.params, args);
             let method_def_id = cx.typeck_results().type_dependent_def_id(body.value.hir_id).unwrap();
             let substs = cx.typeck_results().node_substs(body.value.hir_id);
index 98e5234e0aa94640a928d5eff4814b8c9a465307..f326fd83d18e70a16c17de0a8ca5681f5562ee58 100644 (file)
@@ -35,10 +35,10 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         if_chain! {
             // match call to unwrap
-            if let ExprKind::MethodCall(unwrap_fun, _, [write_call], _) = expr.kind;
+            if let ExprKind::MethodCall(unwrap_fun, [write_call], _) = expr.kind;
             if unwrap_fun.ident.name == sym::unwrap;
             // match call to write_fmt
-            if let ExprKind::MethodCall(write_fun, _, [write_recv, write_arg], _) = write_call.kind;
+            if let ExprKind::MethodCall(write_fun, [write_recv, write_arg], _) = write_call.kind;
             if write_fun.ident.name == sym!(write_fmt);
             // match calls to std::io::stdout() / std::io::stderr ()
             if let Some(dest_name) = if match_function_call(cx, write_recv, &paths::STDOUT).is_some() {
index 6dcbaf68dfdbcb3787087603e2cba3bb00a94fef..79ce53f7a5f23f2cd3f3f0f64f36541b28bb453b 100644 (file)
@@ -303,7 +303,7 @@ fn check_powi(cx: &LateContext<'_>, expr: &Expr<'_>, args: &[Expr<'_>]) {
         if value == Int(2) {
             if let Some(parent) = get_parent_expr(cx, expr) {
                 if let Some(grandparent) = get_parent_expr(cx, parent) {
-                    if let ExprKind::MethodCall(PathSegment { ident: method_name, .. }, _, args, _) = grandparent.kind {
+                    if let ExprKind::MethodCall(PathSegment { ident: method_name, .. }, args, _) = grandparent.kind {
                         if method_name.as_str() == "sqrt" && detect_hypot(cx, args).is_some() {
                             return;
                         }
@@ -364,13 +364,11 @@ fn detect_hypot(cx: &LateContext<'_>, args: &[Expr<'_>]) -> Option<String> {
         if_chain! {
             if let ExprKind::MethodCall(
                 PathSegment { ident: lmethod_name, .. },
-                _lspan,
                 [largs_0, largs_1, ..],
                 _
             ) = &add_lhs.kind;
             if let ExprKind::MethodCall(
                 PathSegment { ident: rmethod_name, .. },
-                _rspan,
                 [rargs_0, rargs_1, ..],
                 _
             ) = &add_rhs.kind;
@@ -409,7 +407,7 @@ fn check_expm1(cx: &LateContext<'_>, expr: &Expr<'_>) {
         if cx.typeck_results().expr_ty(lhs).is_floating_point();
         if let Some((value, _)) = constant(cx, cx.typeck_results(), rhs);
         if F32(1.0) == value || F64(1.0) == value;
-        if let ExprKind::MethodCall(path, _, [self_arg, ..], _) = &lhs.kind;
+        if let ExprKind::MethodCall(path, [self_arg, ..], _) = &lhs.kind;
         if cx.typeck_results().expr_ty(self_arg).is_floating_point();
         if path.ident.name.as_str() == "exp";
         then {
@@ -453,7 +451,7 @@ fn check_mul_add(cx: &LateContext<'_>, expr: &Expr<'_>) {
     ) = &expr.kind
     {
         if let Some(parent) = get_parent_expr(cx, expr) {
-            if let ExprKind::MethodCall(PathSegment { ident: method_name, .. }, _, args, _) = parent.kind {
+            if let ExprKind::MethodCall(PathSegment { ident: method_name, .. }, args, _) = parent.kind {
                 if method_name.as_str() == "sqrt" && detect_hypot(cx, args).is_some() {
                     return;
                 }
@@ -589,8 +587,8 @@ fn check_custom_abs(cx: &LateContext<'_>, expr: &Expr<'_>) {
 
 fn are_same_base_logs(cx: &LateContext<'_>, expr_a: &Expr<'_>, expr_b: &Expr<'_>) -> bool {
     if_chain! {
-        if let ExprKind::MethodCall(PathSegment { ident: method_name_a, .. }, _, args_a, _) = expr_a.kind;
-        if let ExprKind::MethodCall(PathSegment { ident: method_name_b, .. }, _, args_b, _) = expr_b.kind;
+        if let ExprKind::MethodCall(PathSegment { ident: method_name_a, .. }, args_a, _) = expr_a.kind;
+        if let ExprKind::MethodCall(PathSegment { ident: method_name_b, .. }, args_b, _) = expr_b.kind;
         then {
             return method_name_a.as_str() == method_name_b.as_str() &&
                 args_a.len() == args_b.len() &&
@@ -615,8 +613,8 @@ fn check_log_division(cx: &LateContext<'_>, expr: &Expr<'_>) {
             rhs,
         ) = &expr.kind;
         if are_same_base_logs(cx, lhs, rhs);
-        if let ExprKind::MethodCall(_, _, [largs_self, ..], _) = &lhs.kind;
-        if let ExprKind::MethodCall(_, _, [rargs_self, ..], _) = &rhs.kind;
+        if let ExprKind::MethodCall(_, [largs_self, ..], _) = &lhs.kind;
+        if let ExprKind::MethodCall(_, [rargs_self, ..], _) = &rhs.kind;
         then {
             span_lint_and_sugg(
                 cx,
@@ -714,7 +712,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
             return;
         }
 
-        if let ExprKind::MethodCall(path, _, args, _) = &expr.kind {
+        if let ExprKind::MethodCall(path, args, _) = &expr.kind {
             let recv_ty = cx.typeck_results().expr_ty(&args[0]);
 
             if recv_ty.is_floating_point() {
index ae423d799d71a3defb511ef01a02e13c1ea84241..17b0749a4a990f91594d704f325ec5e25f16fcde 100644 (file)
@@ -149,7 +149,7 @@ fn check_format_in_format_args(cx: &LateContext<'_>, call_site: Span, name: Symb
 fn check_to_string_in_format_args(cx: &LateContext<'_>, name: Symbol, value: &Expr<'_>) {
     if_chain! {
         if !value.span.from_expansion();
-        if let ExprKind::MethodCall(_, _, [receiver], _) = value.kind;
+        if let ExprKind::MethodCall(_, [receiver], _) = value.kind;
         if let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(value.hir_id);
         if is_diag_trait_item(cx, method_def_id, sym::ToString);
         let receiver_ty = cx.typeck_results().expr_ty(receiver);
index 3e85c8a9c8071a91bc65f45dbc847207e743e1ff..ae18f8081bcc870d2b90f8a6e0f27a16f68176c5 100644 (file)
@@ -3,7 +3,7 @@
 use clippy_utils::source::snippet_opt;
 use if_chain::if_chain;
 use rustc_ast::ast::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp};
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_middle::lint::in_external_macro;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 use rustc_span::source_map::Span;
@@ -207,7 +207,7 @@ fn check_else(cx: &EarlyContext<'_>, expr: &Expr) {
         if let ExprKind::If(_, then, Some(else_)) = &expr.kind;
         if is_block(else_) || is_if(else_);
         if !differing_macro_contexts(then.span, else_.span);
-        if !then.span.from_expansion() && !in_external_macro(cx.sess, expr.span);
+        if !then.span.from_expansion() && !in_external_macro(cx.sess(), expr.span);
 
         // workaround for rust-lang/rust#43081
         if expr.span.lo().0 != 0 && expr.span.hi().0 != 0;
@@ -259,7 +259,7 @@ fn has_unary_equivalent(bin_op: BinOpKind) -> bool {
 }
 
 fn indentation(cx: &EarlyContext<'_>, span: Span) -> usize {
-    cx.sess.source_map().lookup_char_pos(span.lo()).col.0
+    cx.sess().source_map().lookup_char_pos(span.lo()).col.0
 }
 
 /// Implementation of the `POSSIBLE_MISSING_COMMA` lint for array
index 5ece2cc5ac4f7dd3b509a1dc262b5b1df53f5eae..c2f52605151ed2e0f750a050695d57c87efe6122 100644 (file)
@@ -2,7 +2,7 @@
 use clippy_utils::{meets_msrv, msrvs};
 use if_chain::if_chain;
 use rustc_hir as hir;
-use rustc_lint::{LateContext, LateLintPass, LintContext};
+use rustc_lint::{LateContext, LateLintPass};
 use rustc_semver::RustcVersion;
 use rustc_session::{declare_tool_lint, impl_lint_pass};
 use rustc_span::symbol::sym;
index 2610f0ff384eb25575cc75e52ec6f729fb2018f1..3e3718b9445f7a0e645f2e1a96084953c061e774 100644 (file)
@@ -217,7 +217,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
             return;
         }
         match expr.kind {
-            Call(_, args) | MethodCall(_, _, args, _) => {
+            Call(_, args) | MethodCall(_, args, _) => {
                 let mut tys = DefIdSet::default();
                 for arg in args {
                     if self.cx.tcx.has_typeck_results(arg.hir_id.owner.to_def_id())
index ab3dae4b67f9a54e271702f0ebcb8880488e6749..830e3b32cfa2fac80d26726df67d353a835ea145 100644 (file)
@@ -88,7 +88,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
                     }
                 }
             },
-            hir::ExprKind::MethodCall(_, _, args, _) => {
+            hir::ExprKind::MethodCall(_, args, _) => {
                 let def_id = self.typeck_results.type_dependent_def_id(expr.hir_id).unwrap();
                 let base_type = self.cx.tcx.type_of(def_id);
 
index edca701869e0fc2eb89dd14574a9700957f414df..df29d9308e7124da07b112998729023abbba7e17 100644 (file)
@@ -51,7 +51,7 @@ impl<'tcx> LateLintPass<'tcx> for GetLastWithLen {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         if_chain! {
             // Is a method call
-            if let ExprKind::MethodCall(path, _, args, _) = expr.kind;
+            if let ExprKind::MethodCall(path, args, _) = expr.kind;
 
             // Method name is "get"
             if path.ident.name == sym!(get);
@@ -73,7 +73,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
             ) = &get_index_arg.kind;
 
             // LHS of subtraction is "x.len()"
-            if let ExprKind::MethodCall(arg_lhs_path, _, lhs_args, _) = &lhs.kind;
+            if let ExprKind::MethodCall(arg_lhs_path, lhs_args, _) = &lhs.kind;
             if arg_lhs_path.ident.name == sym::len;
             if let Some(arg_lhs_struct) = lhs_args.get(0);
 
index 0cc697d8425517495e2aac59b7e0cb7f28a59759..e9501700784931c25ac97277fafa0b825ceac596 100644 (file)
@@ -127,7 +127,7 @@ fn same_mutex(&self, cx: &LateContext<'_>, op_mutex: &Expr<'_>) -> bool {
 
 fn is_mutex_lock_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<&'tcx Expr<'tcx>> {
     if_chain! {
-        if let ExprKind::MethodCall(path, _span, [self_arg, ..], _) = &expr.kind;
+        if let ExprKind::MethodCall(path, [self_arg, ..], _) = &expr.kind;
         if path.ident.as_str() == "lock";
         let ty = cx.typeck_results().expr_ty(self_arg);
         if is_type_diagnostic_item(cx, ty, sym::Mutex);
index 4615122bbf9e51cef7b6c3087b2e9a1eefabc945..667652106987a6bff185c95d32c0334f2ed1c90e 100644 (file)
@@ -8,7 +8,7 @@
 use rustc_errors::Applicability;
 use rustc_hir as hir;
 use rustc_hir::intravisit::{self, Visitor};
-use rustc_lint::{LateContext, LateLintPass, LintContext};
+use rustc_lint::{LateContext, LateLintPass};
 use rustc_middle::hir::nested_filter;
 use rustc_middle::ty;
 use rustc_semver::RustcVersion;
index c7db47a552b2cef43093f7af8e4094b3b91025dc..3008e86ef8b296da25d2a4e5adc78c614ceed059 100644 (file)
@@ -145,7 +145,7 @@ enum Heuristic {
 
 fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
     match expr.kind {
-        ExprKind::MethodCall(method, _, args, _) => {
+        ExprKind::MethodCall(method, args, _) => {
             for &(name, len, heuristic, cap) in &HEURISTICS {
                 if method.ident.name.as_str() == name && args.len() == len {
                     return (match heuristic {
@@ -221,7 +221,7 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
 
 fn complete_infinite_iter(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
     match expr.kind {
-        ExprKind::MethodCall(method, _, args, _) => {
+        ExprKind::MethodCall(method, args, _) => {
             for &(name, len) in &COMPLETING_METHODS {
                 if method.ident.name.as_str() == name && args.len() == len {
                     return is_infinite(cx, &args[0]);
index b118d3c8b8727242427c85d4383eb381458e3ddb..cdefe627efdaad877d2c95150a8ddc6ad036f984 100644 (file)
@@ -2,7 +2,7 @@
 
 use clippy_utils::diagnostics::span_lint;
 use rustc_ast::ast::{Block, ItemKind, StmtKind};
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_middle::lint::in_external_macro;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 
@@ -55,7 +55,7 @@
 
 impl EarlyLintPass for ItemsAfterStatements {
     fn check_block(&mut self, cx: &EarlyContext<'_>, item: &Block) {
-        if in_external_macro(cx.sess, item.span) {
+        if in_external_macro(cx.sess(), item.span) {
             return;
         }
 
@@ -69,7 +69,7 @@ fn check_block(&mut self, cx: &EarlyContext<'_>, item: &Block) {
         // lint on all further items
         for stmt in stmts {
             if let StmtKind::Item(ref it) = *stmt {
-                if in_external_macro(cx.sess, it.span) {
+                if in_external_macro(cx.sess(), it.span) {
                     return;
                 }
                 if let ItemKind::MacroDef(..) = it.kind {
index e1168c3f6022ef381fc2eb576b44fb47ea8c3e41..530b0a90ebd8a8245fb129d1317dd06f64cd71fd 100644 (file)
@@ -370,7 +370,7 @@ fn check_for_is_empty(
 }
 
 fn check_cmp(cx: &LateContext<'_>, span: Span, method: &Expr<'_>, lit: &Expr<'_>, op: &str, compare_to: u32) {
-    if let (&ExprKind::MethodCall(method_path, _, args, _), &ExprKind::Lit(ref lit)) = (&method.kind, &lit.kind) {
+    if let (&ExprKind::MethodCall(method_path, args, _), &ExprKind::Lit(ref lit)) = (&method.kind, &lit.kind) {
         // check if we are in an is_empty() method
         if let Some(name) = get_item_name(cx, method) {
             if name.as_str() == "is_empty" {
index 130543bbbee80ef229aa818188f9bab24e191c2f..b7430f49229ae6e673a98fd596f717b3324418c0 100644 (file)
@@ -7,7 +7,7 @@
 use if_chain::if_chain;
 use rustc_ast::ast::{Expr, ExprKind, Lit, LitKind};
 use rustc_errors::Applicability;
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_middle::lint::in_external_macro;
 use rustc_session::{declare_tool_lint, impl_lint_pass};
 use std::iter;
@@ -225,7 +225,7 @@ pub struct LiteralDigitGrouping {
 
 impl EarlyLintPass for LiteralDigitGrouping {
     fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
-        if in_external_macro(cx.sess, expr.span) {
+        if in_external_macro(cx.sess(), expr.span) {
             return;
         }
 
@@ -418,7 +418,7 @@ pub struct DecimalLiteralRepresentation {
 
 impl EarlyLintPass for DecimalLiteralRepresentation {
     fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
-        if in_external_macro(cx.sess, expr.span) {
+        if in_external_macro(cx.sess(), expr.span) {
             return;
         }
 
index 48c4015e07b6d308abd6aeae6932d159344a206b..ef0221639aa940414ea29f146b3c53f9511d8067 100644 (file)
@@ -119,7 +119,7 @@ fn print_offset(offset: MinifyingSugg<'static>) -> MinifyingSugg<'static> {
 
     let print_limit = |end: &Expr<'_>, end_str: &str, base: &Expr<'_>, sugg: MinifyingSugg<'static>| {
         if_chain! {
-            if let ExprKind::MethodCall(method, _, len_args, _) = end.kind;
+            if let ExprKind::MethodCall(method, len_args, _) = end.kind;
             if method.ident.name == sym::len;
             if len_args.len() == 1;
             if let Some(arg) = len_args.get(0);
@@ -343,7 +343,7 @@ fn get_slice_like_element_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Opti
 
 fn fetch_cloned_expr<'tcx>(expr: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> {
     if_chain! {
-        if let ExprKind::MethodCall(method, _, args, _) = expr.kind;
+        if let ExprKind::MethodCall(method, args, _) = expr.kind;
         if method.ident.name == sym::clone;
         if args.len() == 1;
         if let Some(arg) = args.get(0);
index b03445b8cd6b08df5008424ec994f9e15a46266f..5bc32acf56eccd1a22a64fb19011b5946b68e045 100644 (file)
@@ -658,7 +658,7 @@ fn check_for_loop<'tcx>(
 fn check_for_loop_arg(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>) {
     let mut next_loop_linted = false; // whether or not ITER_NEXT_LOOP lint was used
 
-    if let ExprKind::MethodCall(method, _, [self_arg], _) = arg.kind {
+    if let ExprKind::MethodCall(method, [self_arg], _) = arg.kind {
         let method_name = method.ident.as_str();
         // check for looping over x.iter() or x.iter_mut(), could use &x or &mut x
         match method_name {
index f7d3227af01745a0ae532005ef8cf771cf98a960..f57dcc2f5c453ead3d76b1d2f31e23678bb36dad 100644 (file)
@@ -24,8 +24,8 @@ pub(super) fn check<'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'tcx>) {
 }
 fn check_needless_collect_direct_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'tcx>) {
     if_chain! {
-        if let ExprKind::MethodCall(method, _, args, _) = expr.kind;
-        if let ExprKind::MethodCall(chain_method, method0_span, _, _) = args[0].kind;
+        if let ExprKind::MethodCall(method, args, _) = expr.kind;
+        if let ExprKind::MethodCall(chain_method, _, _) = args[0].kind;
         if chain_method.ident.name == sym!(collect) && is_trait_method(cx, &args[0], sym::Iterator);
         then {
             let ty = cx.typeck_results().expr_ty(&args[0]);
@@ -62,7 +62,7 @@ fn check_needless_collect_direct_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCont
             span_lint_and_sugg(
                 cx,
                 NEEDLESS_COLLECT,
-                method0_span.with_hi(expr.span.hi()),
+                chain_method.ident.span.with_hi(expr.span.hi()),
                 NEEDLESS_COLLECT_MSG,
                 "replace with",
                 sugg,
@@ -79,7 +79,7 @@ fn check_needless_collect_indirect_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCo
                 if let StmtKind::Local(local) = stmt.kind;
                 if let PatKind::Binding(_, id, ..) = local.pat.kind;
                 if let Some(init_expr) = local.init;
-                if let ExprKind::MethodCall(method_name, collect_span, &[ref iter_source], ..) = init_expr.kind;
+                if let ExprKind::MethodCall(method_name, &[ref iter_source], ..) = init_expr.kind;
                 if method_name.ident.name == sym!(collect) && is_trait_method(cx, init_expr, sym::Iterator);
                 let ty = cx.typeck_results().expr_ty(init_expr);
                 if is_type_diagnostic_item(cx, ty, sym::Vec) ||
@@ -101,7 +101,7 @@ fn check_needless_collect_indirect_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCo
                     }
 
                     // Suggest replacing iter_call with iter_replacement, and removing stmt
-                    let mut span = MultiSpan::from_span(collect_span);
+                    let mut span = MultiSpan::from_span(method_name.ident.span);
                     span.push_span_label(iter_call.span, "the iterator could be used here instead".into());
                     span_lint_hir_and_then(
                         cx,
@@ -193,7 +193,7 @@ fn visit_block(&mut self, block: &'tcx Block<'tcx>) {
 
     fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
         // Check function calls on our collection
-        if let ExprKind::MethodCall(method_name, _, [recv, args @ ..], _) = &expr.kind {
+        if let ExprKind::MethodCall(method_name, [recv, args @ ..], _) = &expr.kind {
             if method_name.ident.name == sym!(collect) && is_trait_method(self.cx, expr, sym::Iterator) {
                 self.current_mutably_captured_ids = get_captured_ids(self.cx, self.cx.typeck_results().expr_ty(recv));
                 self.visit_expr(recv);
index 22da21bc6bc40597f815c86f6f29822052bb39db..9d335073e4fb2c524999ad6ec75ceba81b76b6dd 100644 (file)
@@ -186,7 +186,7 @@ pub(super) fn check<'tcx>(
 
 fn is_len_call(expr: &Expr<'_>, var: Symbol) -> bool {
     if_chain! {
-        if let ExprKind::MethodCall(method, _, len_args, _) = expr.kind;
+        if let ExprKind::MethodCall(method, len_args, _) = expr.kind;
         if len_args.len() == 1;
         if method.ident.name == sym::len;
         if let ExprKind::Path(QPath::Resolved(_, path)) = len_args[0].kind;
@@ -296,7 +296,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
     fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
         if_chain! {
             // a range index op
-            if let ExprKind::MethodCall(meth, _, [args_0, args_1, ..], _) = &expr.kind;
+            if let ExprKind::MethodCall(meth, [args_0, args_1, ..], _) = &expr.kind;
             if (meth.ident.name == sym::index && match_trait_method(self.cx, expr, &paths::INDEX))
                 || (meth.ident.name == sym::index_mut && match_trait_method(self.cx, expr, &paths::INDEX_MUT));
             if !self.check(args_1, args_0, expr);
@@ -351,7 +351,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
                     self.visit_expr(expr);
                 }
             },
-            ExprKind::MethodCall(_, _, args, _) => {
+            ExprKind::MethodCall(_, args, _) => {
                 let def_id = self.cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap();
                 for (ty, expr) in iter::zip(self.cx.tcx.fn_sig(def_id).inputs().skip_binder(), args) {
                     self.prefer_mutable = false;
index 3bfc62b19ef2af85f5a1409e6b0ef3945293e7e1..a0b2302662e64b8b6bf6a476fc4439338c6bd95d 100644 (file)
@@ -121,7 +121,7 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
         | ExprKind::Repeat(e, _)
         | ExprKind::DropTemps(e) => never_loop_expr(e, main_loop_id),
         ExprKind::Let(let_expr) => never_loop_expr(let_expr.init, main_loop_id),
-        ExprKind::Array(es) | ExprKind::MethodCall(_, _, es, _) | ExprKind::Tup(es) => {
+        ExprKind::Array(es) | ExprKind::MethodCall(_, es, _) | ExprKind::Tup(es) => {
             never_loop_expr_all(&mut es.iter(), main_loop_id)
         },
         ExprKind::Call(e, es) => never_loop_expr_all(&mut once(e).chain(es.iter()), main_loop_id),
index c61b411708c2a932be82b960d21c0146d0d88c37..e048d744fc3ba89714466632729338dd06670d59 100644 (file)
@@ -180,7 +180,7 @@ fn get_vec_push<'tcx>(cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) -> Option<(&
     if_chain! {
             // Extract method being called
             if let StmtKind::Semi(semi_stmt) = &stmt.kind;
-            if let ExprKind::MethodCall(path, _, args, _) = &semi_stmt.kind;
+            if let ExprKind::MethodCall(path, args, _) = &semi_stmt.kind;
             // Figure out the parameters for the method call
             if let Some(self_expr) = args.get(0);
             if let Some(pushed_item) = args.get(1);
index e39605f3e7d621d79ede824a4c62b37603e1b8b7..15f419e4410ca86ccdf83c2843c58b63625122bb 100644 (file)
@@ -16,7 +16,7 @@ pub(super) fn check<'tcx>(
 ) {
     let arg_expr = match arg.kind {
         ExprKind::AddrOf(BorrowKind::Ref, _, ref_arg) => ref_arg,
-        ExprKind::MethodCall(method, _, args, _) if args.len() == 1 && method.ident.name == rustc_span::sym::iter => {
+        ExprKind::MethodCall(method, args, _) if args.len() == 1 && method.ident.name == rustc_span::sym::iter => {
             &args[0]
         },
         _ => return,
index e0b235c355980e444ee8367a422cc32adb497791..20a8294a0d1acf0132adf4222149a3baec66ddf4 100644 (file)
@@ -21,7 +21,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         if let Res::Def(_, pat_did) = pat_path.res;
         if match_def_path(cx, pat_did, &paths::OPTION_SOME);
         // check for call to `Iterator::next`
-        if let ExprKind::MethodCall(method_name, _, [iter_expr], _) = let_expr.kind;
+        if let ExprKind::MethodCall(method_name, [iter_expr], _) = let_expr.kind;
         if method_name.ident.name == sym::next;
         if is_trait_method(cx, let_expr, sym::Iterator);
         if let Some(iter_expr_struct) = try_parse_iter_expr(cx, iter_expr);
index 63a72d4fddeb0b4d30a74d0b394fdde062c509b1..33d1bb2985f43fdcd4dcd525abf8d0fb16082c78 100644 (file)
@@ -5,7 +5,7 @@
 use if_chain::if_chain;
 use rustc_ast::ast::{FieldDef, Item, ItemKind, Variant, VariantData, VisibilityKind};
 use rustc_errors::Applicability;
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_semver::RustcVersion;
 use rustc_session::{declare_tool_lint, impl_lint_pass};
 use rustc_span::{sym, Span};
@@ -116,7 +116,7 @@ fn is_non_exhaustive_marker(variant: &Variant) -> bool {
                 |diag| {
                     if_chain! {
                         if !item.attrs.iter().any(|attr| attr.has_name(sym::non_exhaustive));
-                        let header_span = cx.sess.source_map().span_until_char(item.span, '{');
+                        let header_span = cx.sess().source_map().span_until_char(item.span, '{');
                         if let Some(snippet) = snippet_opt(cx, header_span);
                         then {
                             diag.span_suggestion(
@@ -149,7 +149,7 @@ fn find_header_span(cx: &EarlyContext<'_>, item: &Item, data: &VariantData) -> S
             VariantData::Unit(_) => unreachable!("`VariantData::Unit` is already handled above"),
         };
 
-        cx.sess.source_map().span_until_char(item.span, delimiter)
+        cx.sess().source_map().span_until_char(item.span, delimiter)
     }
 
     let fields = data.fields();
index bd083e3e9e2012d8a766aae6e46e67cf8dfaca65..bf4ab29d90876aa66c393904942f6ff87983dde1 100644 (file)
@@ -47,7 +47,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, scrutinee: &'tcx Expr<'tcx>) {
         }
 
         if_chain! {
-            if let ExprKind::MethodCall(method_segment, _, args, _) = scrutinee.kind;
+            if let ExprKind::MethodCall(method_segment, args, _) = scrutinee.kind;
             if method_segment.ident.name == sym!(map_or);
             if args.len() == 3;
             let method_receiver = &args[0];
index 039cb3aafdb780eca45eaeadd8c71626e6f84ac8..aacabf303a7025dd6f7c841ee9acb1589ecb495f 100644 (file)
@@ -9,7 +9,7 @@
 use rustc_hir::intravisit::{walk_expr, Visitor};
 use rustc_hir::BinOpKind;
 use rustc_hir::{BorrowKind, Expr, ExprKind};
-use rustc_lint::{LateContext, LateLintPass, LintContext};
+use rustc_lint::{LateContext, LateLintPass};
 use rustc_middle::ty;
 use rustc_semver::RustcVersion;
 use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -74,7 +74,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 
         if_chain! {
             if let Some(higher::If { cond, then, .. }) = higher::If::hir(expr);
-            if let ExprKind::MethodCall(_, _, [target_arg, pattern], _) = cond.kind;
+            if let ExprKind::MethodCall(_, [target_arg, pattern], _) = cond.kind;
             if let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(cond.hir_id);
             if let ExprKind::Path(target_path) = &target_arg.kind;
             then {
@@ -132,7 +132,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 // Returns `Some(arg)` if `expr` matches `arg.len()` and `None` otherwise.
 fn len_arg<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<&'tcx Expr<'tcx>> {
     if_chain! {
-        if let ExprKind::MethodCall(_, _, [arg], _) = expr.kind;
+        if let ExprKind::MethodCall(_, [arg], _) = expr.kind;
         if let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
         if match_def_path(cx, method_def_id, &paths::STR_LEN);
         then {
index 174c7da28d3ec1f246deac0c3dd52274aed9e1f9..22a2552b283a5940c4c54c6e4dff90c1468fb293 100644 (file)
@@ -51,7 +51,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, e: &hir::Expr<'_>) {
         }
 
         if_chain! {
-            if let hir::ExprKind::MethodCall(method, _, args, _) = e.kind;
+            if let hir::ExprKind::MethodCall(method, args, _) = e.kind;
             if args.len() == 2;
             if method.ident.name == sym::map;
             let ty = cx.typeck_results().expr_ty(&args[0]);
@@ -77,7 +77,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, e: &hir::Expr<'_>) {
                                     }
                                 }
                             },
-                            hir::ExprKind::MethodCall(method, _, [obj], _) => if_chain! {
+                            hir::ExprKind::MethodCall(method, [obj], _) => if_chain! {
                                 if ident_eq(name, obj) && method.ident.name == sym::clone;
                                 if let Some(fn_id) = cx.typeck_results().type_dependent_def_id(closure_expr.hir_id);
                                 if let Some(trait_id) = cx.tcx.trait_of_item(fn_id);
index 61f21d532c5016ffc3b09a6f7b4705f291c4ab7f..e3a42de0b7c10c183299aaa5b18de8efc6b1c6ab 100644 (file)
@@ -113,7 +113,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, e: &Expr<'_>) {
         }
 
         // check if this is a method call (e.g. x.foo())
-        if let ExprKind::MethodCall(method, _t_span, args, _) = e.kind {
+        if let ExprKind::MethodCall(method, args, _) = e.kind {
             // only work if the method name is `map_err` and there are only 2 arguments (e.g. x.map_err(|_|[1]
             // Enum::Variant[2]))
             if method.ident.as_str() == "map_err" && args.len() == 2 {
index 58c686d95b3f91caed5e57466b807e33ca9ab8a7..0f6ac47843241d9cc3718d8548eea50ecb746b9b 100644 (file)
@@ -129,7 +129,7 @@ fn reduce_unit_expression<'a>(cx: &LateContext<'_>, expr: &'a hir::Expr<'_>) ->
     }
 
     match expr.kind {
-        hir::ExprKind::Call(_, _) | hir::ExprKind::MethodCall(_, _, _, _) => {
+        hir::ExprKind::Call(_, _) | hir::ExprKind::MethodCall(..) => {
             // Calls can't be reduced any more
             Some(expr.span)
         },
index b1839f00aaee95d1922eea1eaf9c68e3c9a584c2..77a4917ec58f0a80afd66d1d8e4e8841a94ad96b 100644 (file)
@@ -58,7 +58,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
             };
 
         if_chain! {
-            if let ExprKind::MethodCall(_, ok_span, [ref result_types_0, ..], _) = let_expr.kind; //check is expr.ok() has type Result<T,E>.ok(, _)
+            if let ExprKind::MethodCall(ok_path, [ref result_types_0, ..], _) = let_expr.kind; //check is expr.ok() has type Result<T,E>.ok(, _)
             if let PatKind::TupleStruct(QPath::Resolved(_, x), y, _)  = let_pat.kind; //get operation
             if method_chain_args(let_expr, &["ok"]).is_some(); //test to see if using ok() methoduse std::marker::Sized;
             if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(result_types_0), sym::Result);
@@ -68,7 +68,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 
                 let mut applicability = Applicability::MachineApplicable;
                 let some_expr_string = snippet_with_applicability(cx, y[0].span, "", &mut applicability);
-                let trimmed_ok = snippet_with_applicability(cx, let_expr.span.until(ok_span), "", &mut applicability);
+                let trimmed_ok = snippet_with_applicability(cx, let_expr.span.until(ok_path.ident.span), "", &mut applicability);
                 let sugg = format!(
                     "{} let Ok({}) = {}",
                     ifwhile,
index b0eebf35e274df6694fef2524b96aaafcf0f90a1..85aec93670b95642ef3f2f51883fc185984ad2b1 100644 (file)
@@ -87,8 +87,7 @@ struct MatchExprVisitor<'a, 'tcx> {
 impl<'a, 'tcx> Visitor<'tcx> for MatchExprVisitor<'a, 'tcx> {
     fn visit_expr(&mut self, ex: &'tcx Expr<'_>) {
         match ex.kind {
-            ExprKind::MethodCall(segment, _, [receiver], _) if self.case_altered(segment.ident.as_str(), receiver) => {
-            },
+            ExprKind::MethodCall(segment, [receiver], _) if self.case_altered(segment.ident.as_str(), receiver) => {},
             _ => walk_expr(self, ex),
         }
     }
index 33d022c73a5e7c007aa286918e8a78e6db392321..dfb450c8848adcd4aa4b7fca2663e15a5c088810 100644 (file)
@@ -25,7 +25,7 @@
     Mutability, Node, Pat, PatKind, PathSegment, QPath, RangeEnd, TyKind,
 };
 use rustc_hir::{HirIdMap, HirIdSet};
-use rustc_lint::{LateContext, LateLintPass, LintContext};
+use rustc_lint::{LateContext, LateLintPass};
 use rustc_middle::ty::{self, Ty, TyS, VariantDef};
 use rustc_semver::RustcVersion;
 use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -1909,7 +1909,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
                     },
                     // Method calls can take self by reference.
                     // e.g. In `String::new().len()` the string is a temporary value.
-                    ExprKind::MethodCall(_, _, [self_arg, args @ ..], _) => {
+                    ExprKind::MethodCall(_, [self_arg, args @ ..], _) => {
                         if !matches!(self_arg.kind, ExprKind::Path(_)) {
                             let self_by_ref = self
                                 .cx
@@ -2020,7 +2020,7 @@ fn find_sugg_for_if_let<'tcx>(
         // check that `while_let_on_iterator` lint does not trigger
         if_chain! {
             if keyword == "while";
-            if let ExprKind::MethodCall(method_path, _, _, _) = let_expr.kind;
+            if let ExprKind::MethodCall(method_path, _, _) = let_expr.kind;
             if method_path.ident.name == sym::next;
             if is_trait_method(cx, let_expr, sym::Iterator);
             then {
index 7fc39f17232fd41050e000e3eead23503d34bea9..a184806d021bcfcf86617c9fff35eaba84cff16a 100644 (file)
@@ -6,7 +6,7 @@
 use rustc_errors::Applicability;
 use rustc_hir::LangItem::OptionNone;
 use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, QPath};
-use rustc_lint::{LateContext, LateLintPass, LintContext};
+use rustc_lint::{LateContext, LateLintPass};
 use rustc_middle::lint::in_external_macro;
 use rustc_semver::RustcVersion;
 use rustc_session::{declare_tool_lint, impl_lint_pass};
index 150bafc0f5db228f216127d3382c0be03e8ec353..ce958b8ac9f5991a82de380f4ce71575ac60381c 100644 (file)
@@ -121,9 +121,9 @@ fn lint_closure(cx: &LateContext<'_>, expr: &hir::Expr<'_>, closure_expr: &hir::
         });
         let (span, msg) = if_chain! {
             if can_sugg;
-            if let hir::ExprKind::MethodCall(_, span, ..) = expr.kind;
+            if let hir::ExprKind::MethodCall(segment, ..) = expr.kind;
             if let Some(msg) = Self::lint_msg(cx);
-            then { (span, msg) } else { return false; }
+            then { (segment.ident.span, msg) } else { return false; }
         };
         span_lint_and_then(cx, BIND_INSTEAD_OF_MAP, expr.span, &msg, |diag| {
             multispan_sugg_with_applicability(
index b4dacb2580c313fbc366aae7b251facfbdda215e..0b38a07204e86cec08a825a3d00b5e7b3dc09c46 100644 (file)
@@ -81,12 +81,12 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, method_name: Symbol,
                 // &*x is a nop, &x.clone() is not
                 ExprKind::AddrOf(..) => return,
                 // (*x).func() is useless, x.clone().func() can work in case func borrows self
-                ExprKind::MethodCall(_, _, [self_arg, ..], _)
+                ExprKind::MethodCall(_, [self_arg, ..], _)
                     if expr.hir_id == self_arg.hir_id && ty != cx.typeck_results().expr_ty_adjusted(expr) =>
                 {
                     return;
                 },
-                ExprKind::MethodCall(_, _, [self_arg, ..], _) if expr.hir_id == self_arg.hir_id => true,
+                ExprKind::MethodCall(_, [self_arg, ..], _) if expr.hir_id == self_arg.hir_id => true,
                 ExprKind::Match(_, _, MatchSource::TryDesugar | MatchSource::AwaitDesugar)
                 | ExprKind::Field(..)
                 | ExprKind::Index(..) => true,
index 0f39470f34262d2fc95718ea5f143b21e3ea7628..e7d2d550a3032e58af49db5ddf99cc970ab2d4fb 100644 (file)
@@ -28,7 +28,7 @@ fn get_arg_root<'a>(cx: &LateContext<'_>, arg: &'a hir::Expr<'a>) -> &'a hir::Ex
         loop {
             arg_root = match &arg_root.kind {
                 hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, expr) => expr,
-                hir::ExprKind::MethodCall(method_name, _, call_args, _) => {
+                hir::ExprKind::MethodCall(method_name, call_args, _) => {
                     if call_args.len() == 1
                         && (method_name.ident.name == sym::as_str || method_name.ident.name == sym!(as_ref))
                         && {
index 687636f8237fb64fb87399d80bfe96ff5d957cbc..a15fe609402251db53e17ba0ba32c8c3fee7d45b 100644 (file)
@@ -14,7 +14,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, arg:
     if_chain! {
         if is_type_diagnostic_item(cx, ty, sym::Vec);
         //check source object
-        if let ExprKind::MethodCall(src_method, _, [drain_vec, drain_arg], _) = &arg.kind;
+        if let ExprKind::MethodCall(src_method, [drain_vec, drain_arg], _) = &arg.kind;
         if src_method.ident.as_str() == "drain";
         let src_ty = cx.typeck_results().expr_ty(drain_vec);
         //check if actual src type is mutable for code suggestion
index 6d8733c08b43012b5870de5e382410baa783cbfb..ba1af9f3d62be9a38934c24790f9bbb7b4bdc98c 100644 (file)
@@ -28,7 +28,7 @@ fn is_method<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, method_name: Sy
             let closure_expr = peel_blocks(&body.value);
             let arg_id = body.params[0].pat.hir_id;
             match closure_expr.kind {
-                hir::ExprKind::MethodCall(hir::PathSegment { ident, .. }, _, args, _) => {
+                hir::ExprKind::MethodCall(hir::PathSegment { ident, .. }, args, _) => {
                     if_chain! {
                     if ident.name == method_name;
                     if let hir::ExprKind::Path(path) = &args[0].kind;
@@ -118,7 +118,7 @@ pub(super) fn check<'tcx>(
             };
             // closure ends with is_some() or is_ok()
             if let PatKind::Binding(_, filter_param_id, _, None) = filter_pat.kind;
-            if let ExprKind::MethodCall(path, _, [filter_arg], _) = filter_body.value.kind;
+            if let ExprKind::MethodCall(path, [filter_arg], _) = filter_body.value.kind;
             if let Some(opt_ty) = cx.typeck_results().expr_ty(filter_arg).ty_adt_def();
             if let Some(is_result) = if cx.tcx.is_diagnostic_item(sym::Option, opt_ty.did) {
                 Some(false)
@@ -135,7 +135,7 @@ pub(super) fn check<'tcx>(
             if let [map_param] = map_body.params;
             if let PatKind::Binding(_, map_param_id, map_param_ident, None) = map_param.pat.kind;
             // closure ends with expect() or unwrap()
-            if let ExprKind::MethodCall(seg, _, [map_arg, ..], _) = map_body.value.kind;
+            if let ExprKind::MethodCall(seg, [map_arg, ..], _) = map_body.value.kind;
             if matches!(seg.ident.name, sym::expect | sym::unwrap | sym::unwrap_or);
 
             let eq_fallback = |a: &Expr<'_>, b: &Expr<'_>| {
index a9a06c3db75545703a387dd16d86efa763841408..137c9628eb45c930c230abc341f0f7efe2e8d1fa 100644 (file)
@@ -2039,10 +2039,10 @@ pub fn new(avoid_breaking_exported_api: bool, msrv: Option<RustcVersion>) -> Sel
 
 /// Extracts a method call name, args, and `Span` of the method name.
 fn method_call<'tcx>(recv: &'tcx hir::Expr<'tcx>) -> Option<(&'tcx str, &'tcx [hir::Expr<'tcx>], Span)> {
-    if let ExprKind::MethodCall(path, span, args, _) = recv.kind {
+    if let ExprKind::MethodCall(path, args, _) = recv.kind {
         if !args.iter().any(|e| e.span.from_expansion()) {
             let name = path.ident.name.as_str();
-            return Some((name, args, span));
+            return Some((name, args, path.ident.span));
         }
     }
     None
@@ -2060,14 +2060,15 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
             hir::ExprKind::Call(func, args) => {
                 from_iter_instead_of_collect::check(cx, expr, args, func);
             },
-            hir::ExprKind::MethodCall(method_call, ref method_span, args, _) => {
-                or_fun_call::check(cx, expr, *method_span, method_call.ident.as_str(), args);
-                expect_fun_call::check(cx, expr, *method_span, method_call.ident.as_str(), args);
+            hir::ExprKind::MethodCall(method_call, args, _) => {
+                let method_span = method_call.ident.span;
+                or_fun_call::check(cx, expr, method_span, method_call.ident.as_str(), args);
+                expect_fun_call::check(cx, expr, method_span, method_call.ident.as_str(), args);
                 clone_on_copy::check(cx, expr, method_call.ident.name, args);
                 clone_on_ref_ptr::check(cx, expr, method_call.ident.name, args);
                 inefficient_to_string::check(cx, expr, method_call.ident.name, args);
                 single_char_add_str::check(cx, expr, args);
-                into_iter_on_ref::check(cx, expr, *method_span, method_call.ident.name, args);
+                into_iter_on_ref::check(cx, expr, method_span, method_call.ident.name, args);
                 single_char_pattern::check(cx, expr, method_call.ident.name, args);
                 unnecessary_to_owned::check(cx, expr, method_call.ident.name, args);
             },
index fa74a8f3dc363b8a7df525d59c5df03650153f4f..ba2d2914315f9d0be879665f1d55d0b81e41f6ef 100644 (file)
@@ -56,7 +56,7 @@ pub(super) fn check<'tcx>(
             let closure_expr = peel_blocks(&closure_body.value);
 
             match &closure_expr.kind {
-                hir::ExprKind::MethodCall(_, _, args, _) => {
+                hir::ExprKind::MethodCall(_, args, _) => {
                     if_chain! {
                         if args.len() == 1;
                         if path_to_local_id(&args[0], closure_body.params[0].pat.hir_id);
index 514bdadc442e3ac33263bf9bd202102216f4619e..b2f624ed480e4cc903fcbebc08722105a9449037 100644 (file)
@@ -132,7 +132,7 @@ fn parse_iter_usage<'tcx>(
 ) -> Option<IterUsage> {
     let (kind, span) = match iter.next() {
         Some((_, Node::Expr(e))) if e.span.ctxt() == ctxt => {
-            let (name, args) = if let ExprKind::MethodCall(name, _, [_, args @ ..], _) = e.kind {
+            let (name, args) = if let ExprKind::MethodCall(name, [_, args @ ..], _) = e.kind {
                 (name, args)
             } else {
                 return None;
@@ -173,7 +173,7 @@ fn parse_iter_usage<'tcx>(
                         } else {
                             if_chain! {
                                 if let Some((_, Node::Expr(next_expr))) = iter.next();
-                                if let ExprKind::MethodCall(next_name, _, [_], _) = next_expr.kind;
+                                if let ExprKind::MethodCall(next_name, [_], _) = next_expr.kind;
                                 if next_name.ident.name == sym::next;
                                 if next_expr.span.ctxt() == ctxt;
                                 if let Some(next_id) = cx.typeck_results().type_dependent_def_id(next_expr.hir_id);
@@ -217,7 +217,7 @@ fn parse_iter_usage<'tcx>(
                 }
             },
             _ if e.span.ctxt() != ctxt => (None, span),
-            ExprKind::MethodCall(name, _, [_], _)
+            ExprKind::MethodCall(name, [_], _)
                 if name.ident.name == sym::unwrap
                     && cx
                         .typeck_results()
@@ -289,7 +289,7 @@ fn check_iter<'tcx>(
 ) -> bool {
     match iter.next() {
         Some((_, Node::Expr(e))) if e.span.ctxt() == ctxt => {
-            let (name, args) = if let ExprKind::MethodCall(name, _, [_, args @ ..], _) = e.kind {
+            let (name, args) = if let ExprKind::MethodCall(name, [_, args @ ..], _) = e.kind {
                 (name, args)
             } else {
                 return false;
index 5fee18c5129a90d9cc4ae690aa47c7c33bea30cc..65e94c5f44a9f0ae35a0023251bb3cfbf12f88f4 100644 (file)
@@ -45,7 +45,7 @@ pub fn check_for_loop_iter(
         if let Some(receiver_snippet) = snippet_opt(cx, receiver.span);
         then {
             let snippet = if_chain! {
-                if let ExprKind::MethodCall(maybe_iter_method_name, _, [collection], _) = receiver.kind;
+                if let ExprKind::MethodCall(maybe_iter_method_name, [collection], _) = receiver.kind;
                 if maybe_iter_method_name.ident.name == sym::iter;
 
                 if let Some(iterator_trait_id) = cx.tcx.get_diagnostic_item(sym::Iterator);
@@ -155,7 +155,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
                         self.addr_of_exprs.push(parent);
                         return;
                     },
-                    ExprKind::MethodCall(_, _, args, _) => {
+                    ExprKind::MethodCall(_, args, _) => {
                         if_chain! {
                             if args.iter().skip(1).all(|arg| !self.is_binding(arg));
                             if let Some(method_def_id) = self.cx.typeck_results().type_dependent_def_id(parent.hir_id);
index 9162de3cceafa3b377c67020154ece42f4c170cd..b67bfb6597b0489d243987669f3fab4600390e0c 100644 (file)
@@ -313,7 +313,7 @@ fn get_callee_substs_and_args<'tcx>(
         }
     }
     if_chain! {
-        if let ExprKind::MethodCall(_, _, args, _) = expr.kind;
+        if let ExprKind::MethodCall(_, args, _) = expr.kind;
         if let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
         then {
             let substs = cx.typeck_results().node_substs(expr.hir_id);
index e0b1de68b37d359b85c8e7d41eed620338b0c54f..ca5d33ee8b07fc8043560f042fff75932830a528 100644 (file)
@@ -23,8 +23,8 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, call_name: &str,
             // allow the `as_ref` or `as_mut` if it is followed by another method call
             if_chain! {
                 if let Some(parent) = get_parent_expr(cx, expr);
-                if let hir::ExprKind::MethodCall(_, ref span, _, _) = parent.kind;
-                if span != &expr.span;
+                if let hir::ExprKind::MethodCall(segment, ..) = parent.kind;
+                if segment.ident.span != expr.span;
                 then {
                     return;
                 }
index 24b44f819f41997df804161082b5e7e5a7887ac0..c4cf994aacaa9f8aba2d595ed50a4aa2e5b3dbca 100644 (file)
@@ -24,7 +24,7 @@ fn may_slice<'a>(cx: &LateContext<'a>, ty: Ty<'a>) -> bool {
         }
     }
 
-    if let hir::ExprKind::MethodCall(path, _, [self_arg, ..], _) = &expr.kind {
+    if let hir::ExprKind::MethodCall(path, [self_arg, ..], _) = &expr.kind {
         if path.ident.name == sym::iter && may_slice(cx, cx.typeck_results().expr_ty(self_arg)) {
             Some(self_arg)
         } else {
index a6450aec4f7d46f4e108fbafa953058c741f17f8..cf9770f5c1fd320af91b3d297424fd33bb20388b 100644 (file)
@@ -86,7 +86,7 @@ fn min_max<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<(MinMax, Cons
                 None
             }
         },
-        ExprKind::MethodCall(path, _, args, _) => {
+        ExprKind::MethodCall(path, args, _) => {
             if_chain! {
                 if let [obj, _] = args;
                 if cx.typeck_results().expr_ty(obj).is_floating_point() || match_trait_method(cx, expr, &paths::ORD);
index 8db71d1e967620ca73267880368df8dafc609090..3918bdbdf4387cc7e5bc926df8d5519bfdd684b8 100644 (file)
@@ -523,7 +523,7 @@ fn is_signum(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
     }
 
     if_chain! {
-        if let ExprKind::MethodCall(method_name, _, [ref self_arg, ..], _) = expr.kind;
+        if let ExprKind::MethodCall(method_name, [ref self_arg, ..], _) = expr.kind;
         if sym!(signum) == method_name.ident.name;
         // Check that the receiver of the signum() is a float (expressions[0] is the receiver of
         // the method call)
index 6e09e25109fbb31e72fc77d87e5ad488c2fde580..d955fad7d41a2fb12295dc352f901dfa19c883bf 100644 (file)
@@ -12,7 +12,7 @@
 use rustc_ast::ast::{Expr, ExprKind, Generics, Lit, LitFloatType, LitIntType, LitKind, NodeId, Pat, PatKind};
 use rustc_ast::visit::FnKind;
 use rustc_data_structures::fx::FxHashMap;
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_middle::lint::in_external_macro;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 use rustc_span::source_map::Span;
@@ -342,7 +342,7 @@ fn check_fn(&mut self, cx: &EarlyContext<'_>, fn_kind: FnKind<'_>, _: Span, _: N
     }
 
     fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
-        if in_external_macro(cx.sess, expr.span) {
+        if in_external_macro(cx.sess(), expr.span) {
             return;
         }
 
index 77849e1800f6bf9f22aff0d916f55592d55fc42e..bad9e0be82e61e026a25b715d2b20e50d18c960a 100644 (file)
@@ -5,7 +5,7 @@
 use rustc_hir as hir;
 use rustc_hir::intravisit::FnKind;
 use rustc_hir::{Body, Constness, FnDecl, GenericParamKind, HirId};
-use rustc_lint::{LateContext, LateLintPass, LintContext};
+use rustc_lint::{LateContext, LateLintPass};
 use rustc_middle::lint::in_external_macro;
 use rustc_semver::RustcVersion;
 use rustc_session::{declare_tool_lint, impl_lint_pass};
index 3b65f80cba20aeb057459af04949401b6069d318..b8dfe996880661e118ec06aa357a4606a4d1815b 100644 (file)
@@ -80,9 +80,9 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
             return;
         }
 
-        let files = cx.sess.source_map().files();
+        let files = cx.sess().source_map().files();
 
-        let trim_to_src = if let RealFileName::LocalPath(p) = &cx.sess.opts.working_dir {
+        let trim_to_src = if let RealFileName::LocalPath(p) = &cx.sess().opts.working_dir {
             p.to_string_lossy()
         } else {
             return;
index b1e6308d2e1a006ff7d33a7e2ce27c607cf67454..7871be41d62946b94dbf2cb3c43a731f6be555b4 100644 (file)
@@ -49,7 +49,7 @@
 impl<'tcx> LateLintPass<'tcx> for MutMutexLock {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, ex: &'tcx Expr<'tcx>) {
         if_chain! {
-            if let ExprKind::MethodCall(path, method_span, [self_arg, ..], _) = &ex.kind;
+            if let ExprKind::MethodCall(path, [self_arg, ..], _) = &ex.kind;
             if path.ident.name == sym!(lock);
             let ty = cx.typeck_results().expr_ty(self_arg);
             if let ty::Ref(_, inner_ty, Mutability::Mut) = ty.kind();
@@ -58,7 +58,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, ex: &'tcx Expr<'tcx>) {
                 span_lint_and_sugg(
                     cx,
                     MUT_MUTEX_LOCK,
-                    *method_span,
+                    path.ident.span,
                     "calling `&mut Mutex::lock` unnecessarily locks an exclusive (mutable) reference",
                     "change this to",
                     "get_mut".to_owned(),
index 22834cf61ee038224db9e08d897bd65d67a7e14d..5c3e505c06c47821976f3377b1606a4d71c5d83e 100644 (file)
@@ -45,7 +45,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
                     );
                 }
             },
-            ExprKind::MethodCall(path, _, arguments, _) => {
+            ExprKind::MethodCall(path, arguments, _) => {
                 let def_id = cx.typeck_results().type_dependent_def_id(e.hir_id).unwrap();
                 let substs = cx.typeck_results().node_substs(e.hir_id);
                 let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs);
index 44c4b70524d9371353f42858188077cc4ac9cbad..6cf513b214e6dd14559216f4e49aefb4cd0c2992 100644 (file)
@@ -56,12 +56,12 @@ fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
 
         if_chain! {
             // Check the method name is `for_each`.
-            if let ExprKind::MethodCall(method_name, _, [for_each_recv, for_each_arg], _) = expr.kind;
+            if let ExprKind::MethodCall(method_name, [for_each_recv, for_each_arg], _) = expr.kind;
             if method_name.ident.name == Symbol::intern("for_each");
             // Check `for_each` is an associated function of `Iterator`.
             if is_trait_method(cx, expr, sym::Iterator);
             // Checks the receiver of `for_each` is also a method call.
-            if let ExprKind::MethodCall(_, _, [iter_recv], _) = for_each_recv.kind;
+            if let ExprKind::MethodCall(_, [iter_recv], _) = for_each_recv.kind;
             // Skip the lint if the call chain is too long. e.g. `v.field.iter().for_each()` or
             // `v.foo().iter().for_each()` must be skipped.
             if matches!(
index 0931fec149ebfe557ec6edef687b93671e981cc0..21d8263390af3c813d2ae842d8bfa5f167fa0698 100644 (file)
@@ -46,7 +46,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 
         if_chain! {
             if is_type_diagnostic_item(cx,outer_ty,sym::Option);
-            if let ExprKind::MethodCall(path, _, [sub_expr], _) = expr.kind;
+            if let ExprKind::MethodCall(path, [sub_expr], _) = expr.kind;
             let symbol = path.ident.as_str();
             if symbol == "as_deref" || symbol == "as_deref_mut";
             if TyS::same_type( outer_ty, typeck.expr_ty(sub_expr) );
index 39a37e3e378ed4002b483d4b4800250e55e34e48..0d0c88b02c78b6d5adabe7ed4a6b8bc41b599507 100644 (file)
@@ -3,7 +3,7 @@
     self, Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, Item, ItemKind, Local, Pat, PatKind,
 };
 use rustc_ast::visit::{walk_block, walk_expr, walk_pat, Visitor};
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_middle::lint::in_external_macro;
 use rustc_session::{declare_tool_lint, impl_lint_pass};
 use rustc_span::source_map::Span;
@@ -356,7 +356,7 @@ fn visit_item(&mut self, _: &Item) {
 
 impl EarlyLintPass for NonExpressiveNames {
     fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
-        if in_external_macro(cx.sess, item.span) {
+        if in_external_macro(cx.sess(), item.span) {
             return;
         }
 
@@ -371,7 +371,7 @@ fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
     }
 
     fn check_impl_item(&mut self, cx: &EarlyContext<'_>, item: &AssocItem) {
-        if in_external_macro(cx.sess, item.span) {
+        if in_external_macro(cx.sess(), item.span) {
             return;
         }
 
index e46fee4cac5eefd90aeabbe06886950848938107..ed022b9d5291cbf3ad6cdf3df582a6ced7b25440 100644 (file)
@@ -43,7 +43,7 @@
 impl<'tcx> LateLintPass<'tcx> for NonOctalUnixPermissions {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
         match &expr.kind {
-            ExprKind::MethodCall(path, _, [func, param], _) => {
+            ExprKind::MethodCall(path, [func, param], _) => {
                 let obj_ty = cx.typeck_results().expr_ty(func).peel_refs();
 
                 if_chain! {
index e0da12f77fcc79693641f7b08ffe05bbd9bae7c7..d81481ade044d255d843fab0262669ca48c19ea1 100644 (file)
@@ -2,7 +2,7 @@
 use rustc_ast::ast::{Expr, ExprKind};
 use rustc_ast::token::{Lit, LitKind};
 use rustc_errors::Applicability;
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_middle::lint::in_external_macro;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 use rustc_span::Span;
@@ -51,7 +51,7 @@
 
 impl EarlyLintPass for OctalEscapes {
     fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
-        if in_external_macro(cx.sess, expr.span) {
+        if in_external_macro(cx.sess(), expr.span) {
             return;
         }
 
index 1b9285c2298df7f48e5ae9f9fe1da0a942a1c7df..5a0b5042018ba6c68fecc751faa8fac11087f341 100644 (file)
@@ -32,7 +32,7 @@
 
 impl<'tcx> LateLintPass<'tcx> for OpenOptions {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
-        if let ExprKind::MethodCall(path, _, [self_arg, ..], _) = &e.kind {
+        if let ExprKind::MethodCall(path, [self_arg, ..], _) = &e.kind {
             let obj_ty = cx.typeck_results().expr_ty(self_arg).peel_refs();
             if path.ident.name == sym!(open) && match_type(cx, obj_ty, &paths::OPEN_OPTIONS) {
                 let mut options = Vec::new();
@@ -60,7 +60,7 @@ enum OpenOption {
 }
 
 fn get_open_options(cx: &LateContext<'_>, argument: &Expr<'_>, options: &mut Vec<(OpenOption, Argument)>) {
-    if let ExprKind::MethodCall(path, _, arguments, _) = argument.kind {
+    if let ExprKind::MethodCall(path, arguments, _) = argument.kind {
         let obj_ty = cx.typeck_results().expr_ty(&arguments[0]).peel_refs();
 
         // Only proceed if this is a call on some object of type std::fs::OpenOptions
index 953de0f72a86bbdd7d8ec75c8d73d63b3e8d061c..c9f807f2aa3aadfe756369ac9e889dc8cafaf182 100644 (file)
@@ -68,7 +68,7 @@
 
 /// Returns true iff the given expression is the result of calling `Result::ok`
 fn is_result_ok(cx: &LateContext<'_>, expr: &'_ Expr<'_>) -> bool {
-    if let ExprKind::MethodCall(path, _, &[ref receiver], _) = &expr.kind {
+    if let ExprKind::MethodCall(path, &[ref receiver], _) = &expr.kind {
         path.ident.name.as_str() == "ok"
             && is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(receiver), sym::Result)
     } else {
index e58ca95fa042000639a305af32ea1aa8999b2f7b..3f940ce61c03e2c935d9870745384caa79aaa208 100644 (file)
@@ -46,7 +46,7 @@
 impl<'tcx> LateLintPass<'tcx> for PathBufPushOverwrite {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         if_chain! {
-            if let ExprKind::MethodCall(path, _, args, _) = expr.kind;
+            if let ExprKind::MethodCall(path, args, _) = expr.kind;
             if path.ident.name == sym!(push);
             if args.len() == 2;
             if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&args[0]).peel_refs(), sym::PathBuf);
index 964564b57946b5784536ab86e62013fe073b869d..b907f38afbb92f96dfb27efe3659872e239bac34 100644 (file)
@@ -93,7 +93,7 @@ fn expr_as_ptr_offset_call<'tcx>(
     cx: &LateContext<'tcx>,
     expr: &'tcx Expr<'_>,
 ) -> Option<(&'tcx Expr<'tcx>, &'tcx Expr<'tcx>, Method)> {
-    if let ExprKind::MethodCall(path_segment, _, [arg_0, arg_1, ..], _) = &expr.kind {
+    if let ExprKind::MethodCall(path_segment, [arg_0, arg_1, ..], _) = &expr.kind {
         if is_expr_ty_raw_ptr(cx, arg_0) {
             if path_segment.ident.name == sym::offset {
                 return Some((arg_0, arg_1, Method::Offset));
index c765c8962cf70ee8ac533fe58940f38cbd74061a..6f634ded5fef700ffcc8a08ce79fe92be7156f34 100644 (file)
@@ -58,7 +58,7 @@ impl QuestionMark {
     fn check_is_none_or_err_and_early_return(cx: &LateContext<'_>, expr: &Expr<'_>) {
         if_chain! {
             if let Some(higher::If { cond, then, r#else }) = higher::If::hir(expr);
-            if let ExprKind::MethodCall(segment, _, args, _) = &cond.kind;
+            if let ExprKind::MethodCall(segment, args, _) = &cond.kind;
             if let Some(subject) = args.get(0);
             if (Self::option_check_and_early_return(cx, subject, then) && segment.ident.name == sym!(is_none)) ||
                 (Self::result_check_and_early_return(cx, subject, then) && segment.ident.name == sym!(is_err));
index c8cbfefb63d65059b3b65c4d0ff6e875e97e334c..027ab70014fc0c2ca51ced2aa25f329cfcb87028 100644 (file)
@@ -8,7 +8,7 @@
 use rustc_ast::ast::RangeLimits;
 use rustc_errors::Applicability;
 use rustc_hir::{BinOpKind, Expr, ExprKind, PathSegment, QPath};
-use rustc_lint::{LateContext, LateLintPass, LintContext};
+use rustc_lint::{LateContext, LateLintPass};
 use rustc_middle::ty;
 use rustc_semver::RustcVersion;
 use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -190,7 +190,7 @@ pub fn new(msrv: Option<RustcVersion>) -> Self {
 impl<'tcx> LateLintPass<'tcx> for Ranges {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         match expr.kind {
-            ExprKind::MethodCall(path, _, args, _) => {
+            ExprKind::MethodCall(path, args, _) => {
                 check_range_zip_with_len(cx, path, args, expr.span);
             },
             ExprKind::Binary(ref op, l, r) => {
@@ -331,13 +331,13 @@ fn check_range_zip_with_len(cx: &LateContext<'_>, path: &PathSegment<'_>, args:
         if path.ident.as_str() == "zip";
         if let [iter, zip_arg] = args;
         // `.iter()` call
-        if let ExprKind::MethodCall(iter_path, _, iter_args, _) = iter.kind;
+        if let ExprKind::MethodCall(iter_path, iter_args, _) = iter.kind;
         if iter_path.ident.name == sym::iter;
         // range expression in `.zip()` call: `0..x.len()`
         if let Some(higher::Range { start: Some(start), end: Some(end), .. }) = higher::Range::hir(zip_arg);
         if is_integer_const(cx, start, 0);
         // `.len()` call
-        if let ExprKind::MethodCall(len_path, _, len_args, _) = end.kind;
+        if let ExprKind::MethodCall(len_path, len_args, _) = end.kind;
         if len_path.ident.name == sym::len && len_args.len() == 1;
         // `.iter()` and `.len()` called on same `Path`
         if let ExprKind::Path(QPath::Resolved(_, iter_path)) = iter_args[0].kind;
index 0c77cf5e77dd28232f97e0e80c5adcb8209eaeb5..5a25008e95e5bceae5bc16f9311c8b9bc87b78f4 100644 (file)
@@ -8,7 +8,7 @@
 use rustc_hir as hir;
 use rustc_hir::intravisit as hir_visit;
 use rustc_hir::intravisit::Visitor as HirVisitor;
-use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
 use rustc_middle::hir::nested_filter;
 use rustc_middle::lint::in_external_macro;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -62,7 +62,7 @@ fn visit_expr(&mut self, ex: &'ast ast::Expr) {
 
 impl EarlyLintPass for RedundantClosureCall {
     fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
-        if in_external_macro(cx.sess, expr.span) {
+        if in_external_macro(cx.sess(), expr.span) {
             return;
         }
         if_chain! {
index 93dbe936d5841b2e9b9b289ea3e445c5a1857c4c..73088ce1a87e74effa4a4b256e2e2f13b27c5993 100644 (file)
@@ -1,7 +1,7 @@
 use clippy_utils::diagnostics::span_lint_and_help;
 use rustc_ast::ast::{Block, Expr, ExprKind, Stmt, StmtKind};
 use rustc_ast::visit::{walk_expr, Visitor};
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_middle::lint::in_external_macro;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 
@@ -46,7 +46,7 @@
 
 impl EarlyLintPass for RedundantElse {
     fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &Stmt) {
-        if in_external_macro(cx.sess, stmt.span) {
+        if in_external_macro(cx.sess(), stmt.span) {
             return;
         }
         // Only look at expressions that are a whole statement
index 0dea4a784b2170829f7f1a7be2c825f4dca7f2fd..40a62fd6d20133382f1cfc40d4b12d7658f0c02c 100644 (file)
@@ -2,7 +2,7 @@
 use clippy_utils::{meets_msrv, msrvs};
 use rustc_ast::ast::{Expr, ExprKind};
 use rustc_errors::Applicability;
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_middle::lint::in_external_macro;
 use rustc_semver::RustcVersion;
 use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -55,7 +55,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
             return;
         }
 
-        if in_external_macro(cx.sess, expr.span) {
+        if in_external_macro(cx.sess(), expr.span) {
             return;
         }
         if let ExprKind::Struct(ref se) = expr.kind {
index b5dd2de633742813a9b72347cf1fbc2e09724a44..898c70ace66f35776c42c3b6a866022af81c7751 100644 (file)
@@ -46,7 +46,7 @@
 impl<'tcx> LateLintPass<'tcx> for RepeatOnce {
     fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'tcx Expr<'_>) {
         if_chain! {
-            if let ExprKind::MethodCall(path, _, [receiver, count], _) = &expr.kind;
+            if let ExprKind::MethodCall(path, [receiver, count], _) = &expr.kind;
             if path.ident.name == sym!(repeat);
             if constant_context(cx, cx.typeck_results()).expr(count) == Some(Constant::Int(1));
             if !receiver.span.from_expansion();
index ee82666b5affea88b54526cee4c203a405e25c9c..aa306a630c467fea479790e580ba57389298da36 100644 (file)
@@ -1,6 +1,6 @@
 use clippy_utils::diagnostics::span_lint_and_help;
 use rustc_ast::ast::{GenericParam, GenericParamKind};
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_middle::lint::in_external_macro;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 
@@ -43,7 +43,7 @@
 
 impl EarlyLintPass for SingleCharLifetimeNames {
     fn check_generic_param(&mut self, ctx: &EarlyContext<'_>, param: &GenericParam) {
-        if in_external_macro(ctx.sess, param.ident.span) {
+        if in_external_macro(ctx.sess(), param.ident.span) {
             return;
         }
 
index 28d32203da9d73136f7b0c0a69a75af8690e8b21..961cdb317e76cd0abd0c26a240567533869f72c5 100644 (file)
@@ -1,7 +1,7 @@
 use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg};
 use rustc_ast::{ptr::P, Crate, Item, ItemKind, MacroDef, ModKind, UseTreeKind, VisibilityKind};
 use rustc_errors::Applicability;
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 use rustc_span::{edition::Edition, symbol::kw, Span, Symbol};
 
@@ -37,7 +37,7 @@
 
 impl EarlyLintPass for SingleComponentPathImports {
     fn check_crate(&mut self, cx: &EarlyContext<'_>, krate: &Crate) {
-        if cx.sess.opts.edition < Edition::Edition2018 {
+        if cx.sess().opts.edition < Edition::Edition2018 {
             return;
         }
         check_mod(cx, &krate.items);
index 9b195f3c0a228d1edefd01abad488e6347f6b334..c7c57ab426d9d8f82072f4010345deac8d98787d 100644 (file)
@@ -108,7 +108,7 @@ fn get_pointee_ty_and_count_expr<'tcx>(
     };
     if_chain! {
         // Find calls to copy_{from,to}{,_nonoverlapping} and write_bytes methods
-        if let ExprKind::MethodCall(method_path, _, [ptr_self, .., count], _) = expr.kind;
+        if let ExprKind::MethodCall(method_path, [ptr_self, .., count], _) = expr.kind;
         let method_ident = method_path.ident.as_str();
         if METHODS.iter().any(|m| *m == &*method_ident);
 
index 607fa847dae5f61959f8dd69c5f902f88bc376bf..b4ad5dcbe3e9a265feaace30158ae5a227a7e2d3 100644 (file)
@@ -197,7 +197,7 @@ impl<'a, 'tcx> VectorInitializationVisitor<'a, 'tcx> {
     fn search_slow_extend_filling(&mut self, expr: &'tcx Expr<'_>) {
         if_chain! {
             if self.initialization_found;
-            if let ExprKind::MethodCall(path, _, [self_arg, extend_arg], _) = expr.kind;
+            if let ExprKind::MethodCall(path, [self_arg, extend_arg], _) = expr.kind;
             if path_to_local_id(self_arg, self.vec_alloc.local_id);
             if path.ident.name == sym!(extend);
             if self.is_repeat_take(extend_arg);
@@ -212,7 +212,7 @@ fn search_slow_extend_filling(&mut self, expr: &'tcx Expr<'_>) {
     fn search_slow_resize_filling(&mut self, expr: &'tcx Expr<'_>) {
         if_chain! {
             if self.initialization_found;
-            if let ExprKind::MethodCall(path, _, [self_arg, len_arg, fill_arg], _) = expr.kind;
+            if let ExprKind::MethodCall(path, [self_arg, len_arg, fill_arg], _) = expr.kind;
             if path_to_local_id(self_arg, self.vec_alloc.local_id);
             if path.ident.name == sym!(resize);
 
@@ -232,7 +232,7 @@ fn search_slow_resize_filling(&mut self, expr: &'tcx Expr<'_>) {
     /// Returns `true` if give expression is `repeat(0).take(...)`
     fn is_repeat_take(&self, expr: &Expr<'_>) -> bool {
         if_chain! {
-            if let ExprKind::MethodCall(take_path, _, take_args, _) = expr.kind;
+            if let ExprKind::MethodCall(take_path, take_args, _) = expr.kind;
             if take_path.ident.name == sym!(take);
 
             // Check that take is applied to `repeat(0)`
index 20e38dc564eb4138e197cbe05c2e8975fb58fdeb..bcd28b429784a488520f6107255ab106f23b7ecf 100644 (file)
@@ -87,7 +87,7 @@ struct LintDetection {
 
 fn detect_stable_sort_primitive(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<LintDetection> {
     if_chain! {
-        if let ExprKind::MethodCall(method_name, _, args, _) = &expr.kind;
+        if let ExprKind::MethodCall(method_name, args, _) = &expr.kind;
         if let Some(slice) = &args.get(0);
         if let Some(method) = SortingKind::from_stable_name(method_name.ident.name.as_str());
         if let Some(slice_type) = is_slice_of_primitives(cx, slice);
index b4a71aefd437ff7b6c1a186467242b7cf3c0fa08..3573f632a3671e6adde5cd641030f8beb9d85e6e 100644 (file)
@@ -282,7 +282,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
         }
 
         if_chain! {
-            if let ExprKind::MethodCall(path, _, args, _) = &e.kind;
+            if let ExprKind::MethodCall(path, args, _) = &e.kind;
             if path.ident.name == sym!(as_bytes);
             if let ExprKind::Lit(lit) = &args[0].kind;
             if let LitKind::Str(lit_content, _) = &lit.node;
@@ -324,9 +324,9 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
         }
 
         if_chain! {
-            if let ExprKind::MethodCall(path, _, [recv], _) = &e.kind;
+            if let ExprKind::MethodCall(path, [recv], _) = &e.kind;
             if path.ident.name == sym!(into_bytes);
-            if let ExprKind::MethodCall(path, _, [recv], _) = &recv.kind;
+            if let ExprKind::MethodCall(path, [recv], _) = &recv.kind;
             if matches!(path.ident.name.as_str(), "to_owned" | "to_string");
             if let ExprKind::Lit(lit) = &recv.kind;
             if let LitKind::Str(lit_content, _) = &lit.node;
@@ -384,7 +384,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
 impl<'tcx> LateLintPass<'tcx> for StrToString {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
         if_chain! {
-            if let ExprKind::MethodCall(path, _, [self_arg, ..], _) = &expr.kind;
+            if let ExprKind::MethodCall(path, [self_arg, ..], _) = &expr.kind;
             if path.ident.name == sym!(to_string);
             let ty = cx.typeck_results().expr_ty(self_arg);
             if let ty::Ref(_, ty, ..) = ty.kind();
@@ -434,7 +434,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
 impl<'tcx> LateLintPass<'tcx> for StringToString {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
         if_chain! {
-            if let ExprKind::MethodCall(path, _, [self_arg, ..], _) = &expr.kind;
+            if let ExprKind::MethodCall(path, [self_arg, ..], _) = &expr.kind;
             if path.ident.name == sym!(to_string);
             let ty = cx.typeck_results().expr_ty(self_arg);
             if is_type_diagnostic_item(cx, ty, sym::String);
index d6e948a75607bff1bfcb4da6ab50708febce40db..7bc9cf742e6549e7dbbcffa91b499da3766d61bb 100644 (file)
@@ -47,7 +47,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
             if let ExprKind::Path(path) = &func.kind;
             if let Some(did) = cx.qpath_res(path, func.hir_id).opt_def_id();
             if match_libc_symbol(cx, did, "strlen");
-            if let ExprKind::MethodCall(path, _, [self_arg], _) = recv.kind;
+            if let ExprKind::MethodCall(path, [self_arg], _) = recv.kind;
             if !recv.span.from_expansion();
             if path.ident.name == sym::as_ptr;
             then {
index 5eb58b47838298d493c0c4c88def60ec2e0182c0..aa6c01b3a7cd935a3a9835ab79088a8c2cdaf6bc 100644 (file)
 impl<'tcx> LateLintPass<'tcx> for ToDigitIsSome {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
         if_chain! {
-            if let hir::ExprKind::MethodCall(is_some_path, _, is_some_args, _) = &expr.kind;
+            if let hir::ExprKind::MethodCall(is_some_path, is_some_args, _) = &expr.kind;
             if is_some_path.ident.name.as_str() == "is_some";
             if let [to_digit_expr] = &**is_some_args;
             then {
                 let match_result = match &to_digit_expr.kind {
-                    hir::ExprKind::MethodCall(to_digits_path, _, to_digit_args, _) => {
+                    hir::ExprKind::MethodCall(to_digits_path, to_digit_args, _) => {
                         if_chain! {
                             if let [char_arg, radix_arg] = &**to_digit_args;
                             if to_digits_path.ident.name.as_str() == "to_digit";
index f8b6bdcd3e15ed413e98e9530045fa5bc5e6fc2a..03060d78fc5af39d325068a721a991b9e96a7e83 100644 (file)
@@ -93,7 +93,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
         if_chain! {
             if self.in_display_impl;
             if let Some(self_hir_id) = self.self_hir_id;
-            if let ExprKind::MethodCall(path, _, [ref self_arg, ..], _) = expr.kind;
+            if let ExprKind::MethodCall(path, [ref self_arg, ..], _) = expr.kind;
             if path.ident.name == sym!(to_string);
             if let Some(expr_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
             if is_diag_trait_item(cx, expr_def_id, sym::ToString);
index 2ffaf24f942ae705dbd72cf3098b15c73030c6ee..6d909c34690d4f54148210eb0c1aea0b59551837 100644 (file)
@@ -177,7 +177,7 @@ fn extract_init_or_reserve_target<'tcx>(cx: &LateContext<'tcx>, stmt: &'tcx Stmt
                     });
                 }
             },
-            ExprKind::MethodCall(path, _, [self_expr, _], _) if is_reserve(cx, path, self_expr) => {
+            ExprKind::MethodCall(path, [self_expr, _], _) if is_reserve(cx, path, self_expr) => {
                 return Some(TargetVec {
                     location: VecLocation::Expr(self_expr),
                     init_kind: None,
@@ -211,7 +211,7 @@ fn extract_set_len_self<'tcx>(cx: &LateContext<'_>, expr: &'tcx Expr<'_>) -> Opt
         }
     });
     match expr.kind {
-        ExprKind::MethodCall(path, _, [self_expr, _], _) => {
+        ExprKind::MethodCall(path, [self_expr, _], _) => {
             let self_type = cx.typeck_results().expr_ty(self_expr).peel_refs();
             if is_type_diagnostic_item(cx, self_type, sym::Vec) && path.ident.name.as_str() == "set_len" {
                 Some((self_expr, expr.span))
index dcf8a9d7c84d39416926d2e4f7f30dd4aa1bb3b3..88ca0cb20a12c59dc66bf903e31dd9962932f8c5 100644 (file)
@@ -49,7 +49,7 @@
 impl<'tcx> LateLintPass<'tcx> for UnitHash {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
         if_chain! {
-            if let ExprKind::MethodCall(name_ident, _, args, _) = &expr.kind;
+            if let ExprKind::MethodCall(name_ident, args, _) = &expr.kind;
             if name_ident.ident.name == sym::hash;
             if let [recv, state_param] = args;
             if cx.typeck_results().expr_ty(recv).is_unit();
index 68156df2ecea879c1067e9c184131cbd53579d28..141f260487264026182e39eb2b24ea227cf33364 100644 (file)
@@ -142,7 +142,7 @@ fn check_arg<'tcx>(cx: &LateContext<'tcx>, arg: &'tcx Expr<'tcx>) -> Option<(Spa
 
 impl<'tcx> LateLintPass<'tcx> for UnitReturnExpectingOrd {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
-        if let ExprKind::MethodCall(_, _, args, _) = expr.kind {
+        if let ExprKind::MethodCall(_, args, _) = expr.kind {
             let arg_indices = get_args_to_check(cx, expr);
             for (i, trait_name) in arg_indices {
                 if i < args.len() {
index 57be2d2f674cfdc2fa25bbb0fb826b2173fa2759..97d92f10e1cb2b039e13b6b646be14c4370e1343 100644 (file)
@@ -30,7 +30,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
     }
 
     match expr.kind {
-        ExprKind::Call(_, args) | ExprKind::MethodCall(_, _, args, _) => {
+        ExprKind::Call(_, args) | ExprKind::MethodCall(_, args, _) => {
             let args_to_recover = args
                 .iter()
                 .filter(|arg| {
index 7d75ff36e971ab3dc01230c6c533d1dcb861be1e..e6c260ed96a98837d231692a893898d69f66cd71 100644 (file)
@@ -93,10 +93,7 @@ fn mirrored_exprs(
         // The two exprs are method calls.
         // Check to see that the function is the same and the arguments are mirrored
         // This is enough because the receiver of the method is listed in the arguments
-        (
-            ExprKind::MethodCall(left_segment, _, left_args, _),
-            ExprKind::MethodCall(right_segment, _, right_args, _),
-        ) => {
+        (ExprKind::MethodCall(left_segment, left_args, _), ExprKind::MethodCall(right_segment, right_args, _)) => {
             left_segment.ident == right_segment.ident
                 && iter::zip(*left_args, *right_args)
                     .all(|(left, right)| mirrored_exprs(cx, left, a_ident, right, b_ident))
@@ -165,7 +162,7 @@ fn mirrored_exprs(
 
 fn detect_lint(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<LintTrigger> {
     if_chain! {
-        if let ExprKind::MethodCall(name_ident, _, args, _) = &expr.kind;
+        if let ExprKind::MethodCall(name_ident, args, _) = &expr.kind;
         if let name = name_ident.ident.name.to_ident_string();
         if name == "sort_by" || name == "sort_unstable_by";
         if let [vec, Expr { kind: ExprKind::Closure(_, _, closure_body_id, _, _), .. }] = args;
@@ -175,7 +172,7 @@ fn detect_lint(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<LintTrigger> {
             Param { pat: Pat { kind: PatKind::Binding(_, _, left_ident, _), .. }, ..},
             Param { pat: Pat { kind: PatKind::Binding(_, _, right_ident, _), .. }, .. }
         ] = &closure_body.params;
-        if let ExprKind::MethodCall(method_path, _, [ref left_expr, ref right_expr], _) = &closure_body.value.kind;
+        if let ExprKind::MethodCall(method_path, [ref left_expr, ref right_expr], _) = &closure_body.value.kind;
         if method_path.ident.name == sym::cmp;
         then {
             let (closure_body, closure_arg, reverse) = if mirrored_exprs(
index 287ac5b4a90835d162e12b4c9407e29f563e5578..323cf83ffcffae0410f5ba0ec668055a70679ebe 100644 (file)
@@ -64,7 +64,7 @@ fn check_stmt(&mut self, cx: &LateContext<'_>, s: &hir::Stmt<'_>) {
                     check_map_error(cx, res, expr);
                 }
             },
-            hir::ExprKind::MethodCall(path, _, [ref arg_0, ..], _) => match path.ident.as_str() {
+            hir::ExprKind::MethodCall(path, [ref arg_0, ..], _) => match path.ident.as_str() {
                 "expect" | "unwrap" | "unwrap_or" | "unwrap_or_else" => {
                     check_map_error(cx, arg_0, expr);
                 },
@@ -94,7 +94,7 @@ fn try_remove_await<'a>(expr: &'a hir::Expr<'a>) -> Option<&hir::Expr<'a>> {
 
 fn check_map_error(cx: &LateContext<'_>, call: &hir::Expr<'_>, expr: &hir::Expr<'_>) {
     let mut call = call;
-    while let hir::ExprKind::MethodCall(path, _, args, _) = call.kind {
+    while let hir::ExprKind::MethodCall(path, args, _) = call.kind {
         if matches!(path.ident.as_str(), "or" | "or_else" | "ok") {
             call = &args[0];
         } else {
@@ -110,7 +110,7 @@ fn check_map_error(cx: &LateContext<'_>, call: &hir::Expr<'_>, expr: &hir::Expr<
 }
 
 fn check_method_call(cx: &LateContext<'_>, call: &hir::Expr<'_>, expr: &hir::Expr<'_>, is_await: bool) {
-    if let hir::ExprKind::MethodCall(path, _, _, _) = call.kind {
+    if let hir::ExprKind::MethodCall(path, _, _) = call.kind {
         let symbol = path.ident.as_str();
         let read_trait = if is_await {
             match_trait_method(cx, call, &paths::FUTURES_IO_ASYNCREADEXT)
index 0a728d7700b3073ee6b00435fdec36d8f77f10ee..e984048701341099acc25ba8b70b5981f2bb14ae 100644 (file)
@@ -154,7 +154,7 @@ fn is_relevant_result_call(cx: &LateContext<'_>, ty: Ty<'_>, method_name: &str)
         return collect_unwrap_info(cx, if_expr, expr, branch, !invert, false);
     } else {
         if_chain! {
-            if let ExprKind::MethodCall(method_name, _, args, _) = &expr.kind;
+            if let ExprKind::MethodCall(method_name, args, _) = &expr.kind;
             if let Some(local_id) = path_to_local(&args[0]);
             let ty = cx.typeck_results().expr_ty(&args[0]);
             let name = method_name.ident.as_str();
@@ -231,7 +231,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
         } else {
             // find `unwrap[_err]()` calls:
             if_chain! {
-                if let ExprKind::MethodCall(method_name, _, [self_arg, ..], _) = expr.kind;
+                if let ExprKind::MethodCall(method_name, [self_arg, ..], _) = expr.kind;
                 if let Some(id) = path_to_local(self_arg);
                 if [sym::unwrap, sym::expect, sym!(unwrap_err)].contains(&method_name.ident.name);
                 let call_to_unwrap = [sym::unwrap, sym::expect].contains(&method_name.ident.name);
index 6c5a5fe1434f8885ed8686eefee5378d1e78c66e..be20282b3b88c53547571a7ec2f2a28443e3ab14 100644 (file)
@@ -11,7 +11,7 @@
     intravisit::{walk_inf, walk_ty, Visitor},
     Expr, ExprKind, FnRetTy, FnSig, GenericArg, HirId, Impl, ImplItemKind, Item, ItemKind, Path, QPath, TyKind,
 };
-use rustc_lint::{LateContext, LateLintPass, LintContext};
+use rustc_lint::{LateContext, LateLintPass};
 use rustc_semver::RustcVersion;
 use rustc_session::{declare_tool_lint, impl_lint_pass};
 use rustc_span::Span;
index 1d7bb24302606aab731c945d6e32b2bee4ab35f8..d23c85c033b2f7e63ce1809f30443d055e6eb605 100644 (file)
@@ -402,9 +402,9 @@ macro_rules! kind {
                 self.expr(func);
                 self.slice(args, |e| self.expr(e));
             },
-            ExprKind::MethodCall(method_name, _, args, _) => {
+            ExprKind::MethodCall(method_name, args, _) => {
                 bind!(self, method_name, args);
-                kind!("MethodCall({method_name}, _, {args}, _)");
+                kind!("MethodCall({method_name}, {args}, _)");
                 self.ident(field!(method_name.ident));
                 self.slice(args, |e| self.expr(e));
             },
index 89eae06fef79b04a65ca76f986ced2efcc3b4534..b58325ac73ee964770ce951ffb6a25400932c234 100644 (file)
@@ -149,7 +149,7 @@ fn print_expr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, indent: usize) {
             }
             print_expr(cx, init, indent + 1);
         },
-        hir::ExprKind::MethodCall(path, _, args, _) => {
+        hir::ExprKind::MethodCall(path, args, _) => {
             println!("{}MethodCall", ind);
             println!("{}method name: {}", ind, path.ident.name);
             for arg in args {
index 02fa866db5235586530d45b04d4b7cb61696d03b..ec1b5a499d472a401b6677fbf163f40614812e33 100644 (file)
@@ -583,7 +583,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         }
 
         if_chain! {
-            if let ExprKind::MethodCall(path, _, [self_arg, ..], _) = &expr.kind;
+            if let ExprKind::MethodCall(path, [self_arg, ..], _) = &expr.kind;
             let fn_name = path.ident;
             if let Some(sugg) = self.map.get(&*fn_name.as_str());
             let ty = cx.typeck_results().expr_ty(self_arg).peel_refs();
@@ -665,7 +665,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
             if let ExprKind::Closure(_, _, body_id, _, _) = &and_then_args[4].kind;
             let body = cx.tcx.hir().body(*body_id);
             let only_expr = peel_blocks_with_stmt(&body.value);
-            if let ExprKind::MethodCall(ps, _, span_call_args, _) = &only_expr.kind;
+            if let ExprKind::MethodCall(ps, span_call_args, _) = &only_expr.kind;
             then {
                 let and_then_snippets = get_and_then_snippets(cx, and_then_args);
                 let mut sle = SpanlessEq::new(cx).deny_side_effects();
@@ -1097,7 +1097,7 @@ fn symbol_str_expr<'tcx>(&self, expr: &'tcx Expr<'tcx>, cx: &LateContext<'tcx>)
         };
         if_chain! {
             // is a method call
-            if let ExprKind::MethodCall(_, _, [item], _) = call.kind;
+            if let ExprKind::MethodCall(_, [item], _) = call.kind;
             if let Some(did) = cx.typeck_results().type_dependent_def_id(call.hir_id);
             let ty = cx.typeck_results().expr_ty(item);
             // ...on either an Ident or a Symbol
index 8485c14bfe72a5ea338a2af8003b3201fe13fddb..512c39389c1bd8fbf8d68b12bceda8563e541e31 100644 (file)
@@ -580,7 +580,7 @@ fn get_lint_group_and_level_or_lint(
 ) -> Option<(String, &'static str)> {
     let result = cx
         .lint_store
-        .check_lint_name(cx.sess(), lint_name, Some(sym::clippy), &[]);
+        .check_lint_name(lint_name, Some(sym::clippy), &[]);
     if let CheckLintNameResult::Tool(Ok(lint_lst)) = result {
         if let Some(group) = get_lint_group(cx, lint_lst[0]) {
             if EXCLUDED_LINT_GROUPS.contains(&group.as_str()) {
@@ -896,7 +896,7 @@ fn visit_expr(&mut self, expr: &'hir hir::Expr<'hir>) {
                     self.add_single_span_suggestion();
                 }
             },
-            ExprKind::MethodCall(path, _path_span, arg, _arg_span) => {
+            ExprKind::MethodCall(path, arg, _arg_span) => {
                 let (self_ty, _) = walk_ptrs_ty_depth(self.cx.typeck_results().expr_ty(&arg[0]));
                 if match_type(self.cx, self_ty, &paths::DIAGNOSTIC_BUILDER) {
                     let called_method = path.ident.name.as_str().to_string();
index 43474da3450e2bd1e7641ed96d743c73f28439db..fbf2b3e081b823220e0c1fbc792de34b1daaeba1 100644 (file)
@@ -125,7 +125,7 @@ fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
         if let Some(searcher) = self.searcher.take() {
             if_chain! {
                 if let StmtKind::Expr(expr) | StmtKind::Semi(expr) = stmt.kind;
-                if let ExprKind::MethodCall(path, _, [self_arg, _], _) = expr.kind;
+                if let ExprKind::MethodCall(path, [self_arg, _], _) = expr.kind;
                 if path_to_local_id(self_arg, searcher.local_id);
                 if path.ident.name.as_str() == "push";
                 then {
index 3441d9ccdfa25db333ee7a22456b3eb952ddcb4e..4d86abd0fa123660a564d309bbc08c4d7a37c706 100644 (file)
@@ -31,7 +31,7 @@
 impl<'tcx> LateLintPass<'tcx> for VecResizeToZero {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         if_chain! {
-            if let hir::ExprKind::MethodCall(path_segment, _, args, _) = expr.kind;
+            if let hir::ExprKind::MethodCall(path_segment, args, _) = expr.kind;
             if let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
             if match_def_path(cx, method_def_id, &paths::VEC_RESIZE) && args.len() == 3;
             if let ExprKind::Lit(Spanned { node: LitKind::Int(0, _), .. }) = args[1].kind;
index ebdaff1e676b7e187511536f6dca84bc38f58804..8e2ddd225fdb3bd239c2e73288e6a5a794be0bca 100644 (file)
@@ -61,7 +61,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
 
 fn is_file_read_to_end<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> bool {
     if_chain! {
-        if let ExprKind::MethodCall(method_name, _, exprs, _) = expr.kind;
+        if let ExprKind::MethodCall(method_name, exprs, _) = expr.kind;
         if method_name.ident.as_str() == "read_to_end";
         if let ExprKind::Path(QPath::Resolved(None, _)) = &exprs[0].kind;
         let ty = cx.typeck_results().expr_ty(&exprs[0]);
@@ -75,7 +75,7 @@ fn is_file_read_to_end<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) ->
 
 fn is_file_read_to_string<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> bool {
     if_chain! {
-        if let ExprKind::MethodCall(method_name, _, exprs, _) = expr.kind;
+        if let ExprKind::MethodCall(method_name, exprs, _) = expr.kind;
         if method_name.ident.as_str() == "read_to_string";
         if let ExprKind::Path(QPath::Resolved(None, _)) = &exprs[0].kind;
         let ty = cx.typeck_results().expr_ty(&exprs[0]);
index f9add927b49b86d7c3b993750b91993decb6fba8..b0044695ea8a88388da9a655e3336873c4252a8f 100644 (file)
@@ -9,7 +9,7 @@
 use rustc_ast::tokenstream::TokenStream;
 use rustc_errors::Applicability;
 use rustc_lexer::unescape::{self, EscapeError};
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_parse::parser;
 use rustc_session::{declare_tool_lint, impl_lint_pass};
 use rustc_span::symbol::{kw, Symbol};
@@ -290,7 +290,7 @@ fn check_item_post(&mut self, _: &EarlyContext<'_>, _: &Item) {
     fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &MacCall) {
         fn is_build_script(cx: &EarlyContext<'_>) -> bool {
             // Cargo sets the crate name for build scripts to `build_script_build`
-            cx.sess
+            cx.sess()
                 .opts
                 .crate_name
                 .as_ref()
@@ -529,7 +529,7 @@ fn parse_fmt_string(&self, cx: &EarlyContext<'_>, str_lit: &StrLit) -> Option<Si
     /// ```
     #[allow(clippy::too_many_lines)]
     fn check_tts<'a>(&self, cx: &EarlyContext<'a>, tts: TokenStream, is_write: bool) -> (Option<StrLit>, Option<Expr>) {
-        let mut parser = parser::Parser::new(&cx.sess.parse_sess, tts, false, None);
+        let mut parser = parser::Parser::new(&cx.sess().parse_sess, tts, false, None);
         let expr = if is_write {
             match parser
                 .parse_expr()
index 8bdc59a7175b2eb987499e9aa7ad6ba58eb80562..eb9efec3f1612a8f7af66888ba3b3534e726f400 100644 (file)
@@ -141,7 +141,7 @@ fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
                     self.eagerness |= NoChange;
                     return;
                 },
-                ExprKind::MethodCall(name, _, args, _) => {
+                ExprKind::MethodCall(name, args, _) => {
                     self.eagerness |= self
                         .cx
                         .typeck_results()
index b0fee46f82474a9d893391ffc0dd6246d6060bac..ed573ad9056195c650c77e9fadfdab68856a4bbb 100644 (file)
@@ -258,7 +258,7 @@ pub fn eq_expr(&mut self, left: &Expr<'_>, right: &Expr<'_>) -> bool {
                             && self.eq_expr(l.body, r.body)
                     })
             },
-            (&ExprKind::MethodCall(l_path, _, l_args, _), &ExprKind::MethodCall(r_path, _, r_args, _)) => {
+            (&ExprKind::MethodCall(l_path, l_args, _), &ExprKind::MethodCall(r_path, r_args, _)) => {
                 self.inner.allow_side_effects && self.eq_path_segment(l_path, r_path) && self.eq_exprs(l_args, r_args)
             },
             (&ExprKind::Repeat(le, ll), &ExprKind::Repeat(re, rl)) => {
@@ -713,7 +713,7 @@ pub fn hash_expr(&mut self, e: &Expr<'_>) {
 
                 s.hash(&mut self.s);
             },
-            ExprKind::MethodCall(path, ref _tys, args, ref _fn_span) => {
+            ExprKind::MethodCall(path, args, ref _fn_span) => {
                 self.hash_name(path.ident.name);
                 self.hash_exprs(args);
             },
index 5c0800d2f038f8f5c0a55968c7358d764ec48015..9233903e98a0068c6ee1d1170101da2f22f12053 100644 (file)
@@ -117,25 +117,15 @@ pub fn meets_msrv(msrv: Option<&RustcVersion>, lint_msrv: &RustcVersion) -> bool
 
 #[macro_export]
 macro_rules! extract_msrv_attr {
-    (LateContext) => {
-        extract_msrv_attr!(@LateContext, ());
-    };
-    (EarlyContext) => {
-        extract_msrv_attr!(@EarlyContext);
-    };
-    (@$context:ident$(, $call:tt)?) => {
+    ($context:ident) => {
         fn enter_lint_attrs(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
-            use $crate::get_unique_inner_attr;
-            match get_unique_inner_attr(cx.sess$($call)?, attrs, "msrv") {
+            let sess = rustc_lint::LintContext::sess(cx);
+            match $crate::get_unique_inner_attr(sess, attrs, "msrv") {
                 Some(msrv_attr) => {
                     if let Some(msrv) = msrv_attr.value_str() {
-                        self.msrv = $crate::parse_msrv(
-                            &msrv.to_string(),
-                            Some(cx.sess$($call)?),
-                            Some(msrv_attr.span),
-                        );
+                        self.msrv = $crate::parse_msrv(&msrv.to_string(), Some(sess), Some(msrv_attr.span));
                     } else {
-                        cx.sess$($call)?.span_err(msrv_attr.span, "bad clippy attribute");
+                        sess.span_err(msrv_attr.span, "bad clippy attribute");
                     }
                 },
                 _ => (),
@@ -1059,13 +1049,13 @@ pub fn method_calls<'tcx>(
 
     let mut current = expr;
     for _ in 0..max_depth {
-        if let ExprKind::MethodCall(path, span, args, _) = &current.kind {
+        if let ExprKind::MethodCall(path, args, _) = &current.kind {
             if args.iter().any(|e| e.span.from_expansion()) {
                 break;
             }
             method_names.push(path.ident.name);
             arg_lists.push(&**args);
-            spans.push(*span);
+            spans.push(path.ident.span);
             current = &args[0];
         } else {
             break;
@@ -1086,7 +1076,7 @@ pub fn method_chain_args<'a>(expr: &'a Expr<'_>, methods: &[&str]) -> Option<Vec
     let mut matched = Vec::with_capacity(methods.len());
     for method_name in methods.iter().rev() {
         // method chains are stored last -> first
-        if let ExprKind::MethodCall(path, _, args, _) = current.kind {
+        if let ExprKind::MethodCall(path, args, _) = current.kind {
             if path.ident.name.as_str() == *method_name {
                 if args.iter().any(|e| e.span.from_expansion()) {
                     return None;
@@ -1780,7 +1770,7 @@ pub fn is_must_use_func_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
                 None
             }
         },
-        ExprKind::MethodCall(_, _, _, _) => cx.typeck_results().type_dependent_def_id(expr.hir_id),
+        ExprKind::MethodCall(..) => cx.typeck_results().type_dependent_def_id(expr.hir_id),
         _ => None,
     };
 
index 17d9a505bc9df7a601c81cd8639b3bcb701ae2ac..649b7b9940af3b067ab74f34a67a2cdb35cb762e 100644 (file)
@@ -36,7 +36,7 @@ fn extract_clone_suggestions<'tcx>(
         if abort {
             return false;
         }
-        if let ExprKind::MethodCall(seg, _, [recv], _) = expr.kind {
+        if let ExprKind::MethodCall(seg, [recv], _) = expr.kind {
             if path_to_local_id(recv, id) {
                 if seg.ident.name.as_str() == "capacity" {
                     abort = true;
index 563edd32d25185fb3918e344cfe7680760a64a4d..48525f9a5725e3c6f070572023e4efb5bd105517 100644 (file)
@@ -863,7 +863,7 @@ pub fn finish(&mut self) -> String {
     /// indicates whether the function from `parent_expr` takes its args by double reference
     fn func_takes_arg_by_double_ref(&self, parent_expr: &'tcx hir::Expr<'_>, cmt_hir_id: HirId) -> bool {
         let (call_args, inputs) = match parent_expr.kind {
-            ExprKind::MethodCall(_, _, call_args, _) => {
+            ExprKind::MethodCall(_, call_args, _) => {
                 if let Some(method_did) = self.cx.typeck_results().type_dependent_def_id(parent_expr.hir_id) {
                     (call_args, self.cx.tcx.fn_sig(method_did).skip_binder().inputs())
                 } else {
@@ -915,7 +915,7 @@ fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {
                     match &parent_expr.kind {
                         // given expression is the self argument and will be handled completely by the compiler
                         // i.e.: `|x| x.is_something()`
-                        ExprKind::MethodCall(_, _, [self_expr, ..], _) if self_expr.hir_id == cmt.hir_id => {
+                        ExprKind::MethodCall(_, [self_expr, ..], _) if self_expr.hir_id == cmt.hir_id => {
                             self.suggestion_start
                                 .push_str(&format!("{}{}", start_snip, ident_str_with_proj));
                             self.next_pos = span.hi();
@@ -923,7 +923,7 @@ fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {
                         },
                         // item is used in a call
                         // i.e.: `Call`: `|x| please(x)` or `MethodCall`: `|x| [1, 2, 3].contains(x)`
-                        ExprKind::Call(_, [call_args @ ..]) | ExprKind::MethodCall(_, _, [_, call_args @ ..], _) => {
+                        ExprKind::Call(_, [call_args @ ..]) | ExprKind::MethodCall(_, [_, call_args @ ..], _) => {
                             let expr = self.cx.tcx.hir().expect_expr(cmt.hir_id);
                             let arg_ty_kind = self.cx.typeck_results().expr_ty(expr).kind();
 
index 207b0be15488561da7a76d9f1ad4933dc9fde58f..6c8a3dc418b1517f4156a7c58a0146f4b9ca2a0a 100644 (file)
@@ -64,7 +64,7 @@ impl<'tcx> LateLintPass<'tcx> for MyStructLint {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
         if_chain! {
             // Check our expr is calling a method
-            if let hir::ExprKind::MethodCall(path, _, [_self_arg, ..], _) = &expr.kind;
+            if let hir::ExprKind::MethodCall(path, _, [_self_arg, ..]) = &expr.kind;
             // Check the name of this method is `some_method`
             if path.ident.name == sym!(some_method);
             // Optionally, check the type of the self argument.
index ded5abd8d334a13066d8bf514aa0d0e6f47857d1..5e78b7c9de7e3990b3e415899ccb1ae096185cd4 100644 (file)
@@ -53,7 +53,7 @@ if_chain! {
     }
 }
 if_chain! {
-    if let ExprKind::MethodCall(method_name, _, args, _) = expr.kind;
+    if let ExprKind::MethodCall(method_name, args, _) = expr.kind;
     if method_name.ident.as_str() == "test";
     if args.len() == 1;
     if let ExprKind::Path(ref qpath) = args[0].kind;
index 5f26ef413e239f331c60305fcab910173752b5ee..80189ca1f0aeeedc70fb70c0ffe4b75d509f12c3 100644 (file)
@@ -6,5 +6,14 @@ LL |         write!(f, "{}", self.to_string())
    |
    = note: `-D clippy::to-string-in-display` implied by `-D warnings`
 
-error: aborting due to previous error
+error: unnecessary use of `to_string`
+  --> $DIR/to_string_in_display.rs:55:50
+   |
+LL |             Self::E(string) => write!(f, "E {}", string.to_string()),
+   |                                                  ^^^^^^^^^^^^^^^^^^
+   |
+   = note: `-D clippy::unnecessary-to-owned` implied by `-D warnings`
+   = note: this error originates in the macro `$crate::format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 2 previous errors