diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs index 2ff2d1926a2..a5e5f953856 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -333,7 +333,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> { leading_ellipsis, ); - let diag = TraitPlaceholderMismatch { + self.tcx().sess.create_err(TraitPlaceholderMismatch { span, satisfy_span, where_span, @@ -341,9 +341,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> { def_id, trait_def_id: self.tcx().def_path_str(trait_def_id), actual_impl_expl_notes, - }; - - self.tcx().sess.create_err(diag) + }) } /// Add notes with details about the expected and actual trait refs, with attention to cases diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index fbc71bd7e01..ae3f174c72e 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -63,7 +63,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { AssocItemContainer::ImplContainer => (false, String::new()), }; - let diag = ButCallingIntroduces { + let mut err = self.tcx().sess.create_err(ButCallingIntroduces { param_ty_span: param.param_ty_span, cause_span: cause.span, has_param_name: simple_ident.is_some(), @@ -73,8 +73,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { assoc_item: ctxt.assoc_item.name, has_impl_path, impl_path, - }; - let mut err = self.tcx().sess.create_err(diag); + }); if self.find_impl_on_dyn_trait(&mut err, param.param_ty, &ctxt) { let reported = err.emit(); return Some(reported);