@@ -5,9 +5,7 @@ use crate::errors::{
55use crate :: fluent_generated as fluent;
66use crate :: infer:: error_reporting:: { note_and_explain_region, TypeErrCtxt } ;
77use crate :: infer:: { self , SubregionOrigin } ;
8- use rustc_errors:: {
9- AddToDiagnostic , Diagnostic , DiagnosticBuilder , ErrorGuaranteed , IntoDiagnostic ,
10- } ;
8+ use rustc_errors:: { AddToDiagnostic , Diagnostic , DiagnosticBuilder , ErrorGuaranteed } ;
119use rustc_hir:: def_id:: { DefId , LocalDefId } ;
1210use rustc_middle:: traits:: ObligationCauseCode ;
1311use rustc_middle:: ty:: error:: TypeError ;
@@ -136,11 +134,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
136134 note_and_explain:: PrefixKind :: ContentValidFor ,
137135 note_and_explain:: SuffixKind :: Empty ,
138136 ) ;
139- OutlivesContent {
137+ self . tcx . sess . dcx ( ) . create_err ( OutlivesContent {
140138 span,
141139 notes : reference_valid. into_iter ( ) . chain ( content_valid) . collect ( ) ,
142- }
143- . into_diagnostic ( self . tcx . sess . dcx ( ) )
140+ } )
144141 }
145142 infer:: RelateObjectBound ( span) => {
146143 let object_valid = note_and_explain:: RegionExplanation :: new (
@@ -157,11 +154,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
157154 note_and_explain:: PrefixKind :: SourcePointerValidFor ,
158155 note_and_explain:: SuffixKind :: Empty ,
159156 ) ;
160- OutlivesBound {
157+ self . tcx . sess . dcx ( ) . create_err ( OutlivesBound {
161158 span,
162159 notes : object_valid. into_iter ( ) . chain ( pointer_valid) . collect ( ) ,
163- }
164- . into_diagnostic ( self . tcx . sess . dcx ( ) )
160+ } )
165161 }
166162 infer:: RelateParamBound ( span, ty, opt_span) => {
167163 let prefix = match * sub {
@@ -176,8 +172,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
176172 let note = note_and_explain:: RegionExplanation :: new (
177173 self . tcx , sub, opt_span, prefix, suffix,
178174 ) ;
179- FulfillReqLifetime { span, ty : self . resolve_vars_if_possible ( ty) , note }
180- . into_diagnostic ( self . tcx . sess . dcx ( ) )
175+ self . tcx . sess . dcx ( ) . create_err ( FulfillReqLifetime {
176+ span,
177+ ty : self . resolve_vars_if_possible ( ty) ,
178+ note,
179+ } )
181180 }
182181 infer:: RelateRegionParamBound ( span) => {
183182 let param_instantiated = note_and_explain:: RegionExplanation :: new (
@@ -194,11 +193,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
194193 note_and_explain:: PrefixKind :: LfParamMustOutlive ,
195194 note_and_explain:: SuffixKind :: Empty ,
196195 ) ;
197- LfBoundNotSatisfied {
196+ self . tcx . sess . dcx ( ) . create_err ( LfBoundNotSatisfied {
198197 span,
199198 notes : param_instantiated. into_iter ( ) . chain ( param_must_outlive) . collect ( ) ,
200- }
201- . into_diagnostic ( self . tcx . sess . dcx ( ) )
199+ } )
202200 }
203201 infer:: ReferenceOutlivesReferent ( ty, span) => {
204202 let pointer_valid = note_and_explain:: RegionExplanation :: new (
@@ -215,12 +213,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
215213 note_and_explain:: PrefixKind :: DataValidFor ,
216214 note_and_explain:: SuffixKind :: Empty ,
217215 ) ;
218- RefLongerThanData {
216+ self . tcx . sess . dcx ( ) . create_err ( RefLongerThanData {
219217 span,
220218 ty : self . resolve_vars_if_possible ( ty) ,
221219 notes : pointer_valid. into_iter ( ) . chain ( data_valid) . collect ( ) ,
222- }
223- . into_diagnostic ( self . tcx . sess . dcx ( ) )
220+ } )
224221 }
225222 infer:: CompareImplItemObligation { span, impl_item_def_id, trait_item_def_id } => {
226223 let mut err = self . report_extra_impl_obligation (
@@ -277,11 +274,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
277274 note_and_explain:: PrefixKind :: LfMustOutlive ,
278275 note_and_explain:: SuffixKind :: Empty ,
279276 ) ;
280- LfBoundNotSatisfied {
277+ self . tcx . sess . dcx ( ) . create_err ( LfBoundNotSatisfied {
281278 span,
282279 notes : instantiated. into_iter ( ) . chain ( must_outlive) . collect ( ) ,
283- }
284- . into_diagnostic ( self . tcx . sess . dcx ( ) )
280+ } )
285281 }
286282 } ;
287283 if sub. is_error ( ) || sup. is_error ( ) {
0 commit comments