X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_hir_typeck%2Fsrc%2Fcallee.rs;h=25b6cf4ef2e3ec62ce92f207946a8780ee75752f;hb=84ff4ab5a238558a009e1cc6f375b0922053b95b;hp=302d512c71d13229bf0c97f2b97d4be60d1435a7;hpb=a065e97bdc599406f4cea8dad90cc5f215a4e61a;p=rust.git diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 302d512c71d..25b6cf4ef2e 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -6,7 +6,7 @@ use rustc_ast::util::parser::PREC_POSTFIX; use rustc_errors::{struct_span_err, Applicability, Diagnostic, StashKey}; use rustc_hir as hir; -use rustc_hir::def::{self, Namespace, Res}; +use rustc_hir::def::{self, CtorKind, Namespace, Res}; use rustc_hir::def_id::DefId; use rustc_infer::{ infer, @@ -30,7 +30,7 @@ use rustc_trait_selection::traits::error_reporting::DefIdOrName; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; -use std::iter; +use std::{iter, slice}; /// Checks that it is legal to call methods of the trait corresponding /// to `trait_id` (this only cares about the trait, not the specific @@ -227,22 +227,21 @@ fn try_overloaded_call_traits( ] { let Some(trait_def_id) = opt_trait_def_id else { continue }; - let opt_input_types = opt_arg_exprs.map(|arg_exprs| { - [self.tcx.mk_tup(arg_exprs.iter().map(|e| { + let opt_input_type = opt_arg_exprs.map(|arg_exprs| { + self.tcx.mk_tup(arg_exprs.iter().map(|e| { self.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span: e.span, }) - }))] + })) }); - let opt_input_types = opt_input_types.as_ref().map(AsRef::as_ref); if let Some(ok) = self.lookup_method_in_trait( call_expr.span, method_name, trait_def_id, adjusted_ty, - opt_input_types, + opt_input_type.as_ref().map(slice::from_ref), ) { let method = self.register_infer_ok_obligations(ok); let mut autoref = None; @@ -595,7 +594,7 @@ fn report_invalid_callee( ) { let mut unit_variant = None; if let hir::ExprKind::Path(qpath) = &callee_expr.kind - && let Res::Def(def::DefKind::Ctor(kind, def::CtorKind::Const), _) + && let Res::Def(def::DefKind::Ctor(kind, CtorKind::Const), _) = self.typeck_results.borrow().qpath_res(qpath, callee_expr.hir_id) // Only suggest removing parens if there are no arguments && arg_exprs.is_empty()