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};
(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| {
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
/// 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,
/// 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 {