@@ -5,8 +5,8 @@ use crate::errors::{
55use crate :: infer:: error_reporting:: { note_and_explain_region, TypeErrCtxt } ;
66use crate :: infer:: { self , SubregionOrigin } ;
77use rustc_errors:: {
8- fluent, struct_span_err , AddToDiagnostic , Applicability , Diagnostic , DiagnosticBuilder ,
9- ErrorGuaranteed , IntoDiagnostic ,
8+ fluent, AddToDiagnostic , Applicability , Diagnostic , DiagnosticBuilder , ErrorGuaranteed ,
9+ IntoDiagnostic ,
1010} ;
1111use rustc_hir:: def_id:: { DefId , LocalDefId } ;
1212use rustc_middle:: traits:: ObligationCauseCode ;
@@ -184,14 +184,14 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
184184 self . tcx ,
185185 sup,
186186 None ,
187- note_and_explain:: PrefixKind :: LfInstantiatedWith ,
187+ note_and_explain:: PrefixKind :: LfParamInstantiatedWith ,
188188 note_and_explain:: SuffixKind :: Empty ,
189189 ) ;
190190 let param_must_outlive = note_and_explain:: RegionExplanation :: new (
191191 self . tcx ,
192192 sub,
193193 None ,
194- note_and_explain:: PrefixKind :: LfMustOutlive ,
194+ note_and_explain:: PrefixKind :: LfParamMustOutlive ,
195195 note_and_explain:: SuffixKind :: Empty ,
196196 ) ;
197197 LfBoundNotSatisfied {
@@ -279,25 +279,25 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
279279 err
280280 }
281281 infer:: AscribeUserTypeProvePredicate ( span) => {
282- let mut err =
283- struct_span_err ! ( self . tcx. sess, span, E0478 , "lifetime bound not satisfied" ) ;
284- note_and_explain_region (
282+ let instantiated = note_and_explain:: RegionExplanation :: new (
285283 self . tcx ,
286- & mut err,
287- "lifetime instantiated with " ,
288284 sup,
289- "" ,
290285 None ,
286+ note_and_explain:: PrefixKind :: LfInstantiatedWith ,
287+ note_and_explain:: SuffixKind :: Empty ,
291288 ) ;
292- note_and_explain_region (
289+ let must_outlive = note_and_explain :: RegionExplanation :: new (
293290 self . tcx ,
294- & mut err,
295- "but lifetime must outlive " ,
296291 sub,
297- "" ,
298292 None ,
293+ note_and_explain:: PrefixKind :: LfMustOutlive ,
294+ note_and_explain:: SuffixKind :: Empty ,
299295 ) ;
300- err
296+ LfBoundNotSatisfied {
297+ span,
298+ notes : instantiated. into_iter ( ) . chain ( must_outlive) . collect ( ) ,
299+ }
300+ . into_diagnostic ( & self . tcx . sess . parse_sess . span_diagnostic )
301301 }
302302 } ;
303303 if sub. is_error ( ) || sup. is_error ( ) {
0 commit comments