@@ -19,6 +19,9 @@ use std::fmt;
1919use std:: rc:: Rc ;
2020
2121use crate :: region_infer:: values:: RegionElement ;
22+ use crate :: session_diagnostics:: HigherRankedErrorCause ;
23+ use crate :: session_diagnostics:: HigherRankedLifetimeError ;
24+ use crate :: session_diagnostics:: HigherRankedSubtypeError ;
2225use crate :: MirBorrowckCtxt ;
2326
2427#[ derive( Clone ) ]
@@ -69,7 +72,7 @@ impl<'tcx> UniverseInfo<'tcx> {
6972 // up in the existing UI tests. Consider investigating this
7073 // some more.
7174 mbcx. buffer_error (
72- mbcx. infcx . tcx . sess . struct_span_err ( cause. span , "higher-ranked subtype error" ) ,
75+ mbcx. infcx . tcx . sess . create_err ( HigherRankedSubtypeError { span : cause. span } ) ,
7376 ) ;
7477 }
7578 }
@@ -216,9 +219,12 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
216219 tcx : TyCtxt < ' tcx > ,
217220 span : Span ,
218221 ) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
219- let mut err = tcx. sess . struct_span_err ( span, "higher-ranked lifetime error" ) ;
220- err. note ( & format ! ( "could not prove {}" , self . canonical_query. value. value. predicate) ) ;
221- err
222+ tcx. sess . create_err ( HigherRankedLifetimeError {
223+ cause : Some ( HigherRankedErrorCause :: CouldNotProve {
224+ predicate : self . canonical_query . value . value . predicate . to_string ( ) ,
225+ } ) ,
226+ span,
227+ } )
222228 }
223229
224230 fn base_universe ( & self ) -> ty:: UniverseIndex {
@@ -263,9 +269,12 @@ where
263269 tcx : TyCtxt < ' tcx > ,
264270 span : Span ,
265271 ) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
266- let mut err = tcx. sess . struct_span_err ( span, "higher-ranked lifetime error" ) ;
267- err. note ( & format ! ( "could not normalize `{}`" , self . canonical_query. value. value. value) ) ;
268- err
272+ tcx. sess . create_err ( HigherRankedLifetimeError {
273+ cause : Some ( HigherRankedErrorCause :: CouldNotNormalize {
274+ value : self . canonical_query . value . value . value . to_string ( ) ,
275+ } ) ,
276+ span,
277+ } )
269278 }
270279
271280 fn base_universe ( & self ) -> ty:: UniverseIndex {
@@ -326,7 +335,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
326335 ) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
327336 // FIXME: This error message isn't great, but it doesn't show up in the existing UI tests,
328337 // and is only the fallback when the nice error fails. Consider improving this some more.
329- tcx. sess . struct_span_err ( span , "higher-ranked lifetime error" )
338+ tcx. sess . create_err ( HigherRankedLifetimeError { cause : None , span } )
330339 }
331340
332341 fn base_universe ( & self ) -> ty:: UniverseIndex {
@@ -366,7 +375,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
366375 ) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
367376 // FIXME: This error message isn't great, but it doesn't show up in the existing UI tests,
368377 // and is only the fallback when the nice error fails. Consider improving this some more.
369- tcx. sess . struct_span_err ( span , "higher-ranked lifetime error for opaque type!" )
378+ tcx. sess . create_err ( HigherRankedLifetimeError { cause : None , span } )
370379 }
371380
372381 fn base_universe ( & self ) -> ty:: UniverseIndex {
0 commit comments