]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_typeck/src/check/callee.rs
Rollup merge of #89793 - ibraheemdev:from_ptr_range, r=m-ou-se
[rust.git] / compiler / rustc_typeck / src / check / callee.rs
index f64a90ed10e22a3ea2a8137967c3d855cdf6ecb6..d5187c109e33d9f9166c2626a05d854ce735134a 100644 (file)
@@ -2,7 +2,7 @@
 use super::{Expectation, FnCtxt, TupleArgumentsFlag};
 use crate::type_error_struct;
 
-use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
+use rustc_errors::{struct_span_err, Applicability, Diagnostic};
 use rustc_hir as hir;
 use rustc_hir::def::{Namespace, Res};
 use rustc_hir::def_id::{DefId, LOCAL_CRATE};
@@ -219,10 +219,7 @@ fn try_overloaded_call_traits(
             (self.tcx.lang_items().fn_mut_trait(), Ident::with_dummy_span(sym::call_mut), true),
             (self.tcx.lang_items().fn_once_trait(), Ident::with_dummy_span(sym::call_once), false),
         ] {
-            let trait_def_id = match opt_trait_def_id {
-                Some(def_id) => def_id,
-                None => continue,
-            };
+            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| {
@@ -246,11 +243,7 @@ fn try_overloaded_call_traits(
                 if borrow {
                     // Check for &self vs &mut self in the method signature. Since this is either
                     // the Fn or FnMut trait, it should be one of those.
-                    let (region, mutbl) = if let ty::Ref(r, _, mutbl) =
-                        method.sig.inputs()[0].kind()
-                    {
-                        (r, mutbl)
-                    } else {
+                    let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].kind() else {
                         // The `fn`/`fn_mut` lang item is ill-formed, which should have
                         // caused an error elsewhere.
                         self.tcx
@@ -284,7 +277,7 @@ fn try_overloaded_call_traits(
     /// likely intention is to call the closure, suggest `(||{})()`. (#55851)
     fn identify_bad_closure_def_and_call(
         &self,
-        err: &mut DiagnosticBuilder<'a>,
+        err: &mut Diagnostic,
         hir_id: hir::HirId,
         callee_node: &hir::ExprKind<'_>,
         callee_span: Span,
@@ -311,7 +304,7 @@ fn identify_bad_closure_def_and_call(
     /// likely intention is to create an array containing tuples.
     fn maybe_suggest_bad_array_definition(
         &self,
-        err: &mut DiagnosticBuilder<'a>,
+        err: &mut Diagnostic,
         call_expr: &'tcx hir::Expr<'tcx>,
         callee_expr: &'tcx hir::Expr<'tcx>,
     ) -> bool {