@@ -49,7 +49,7 @@ use super::lexical_region_resolve::RegionResolutionError;
4949use super :: region_constraints:: GenericKind ;
5050use super :: { InferCtxt , RegionVariableOrigin , SubregionOrigin , TypeTrace , ValuePairs } ;
5151
52- use crate :: errors:: { self , Error0308Subdiags , FailureCodeDiagnostics } ;
52+ use crate :: errors:: { self , ObligationCauseFailureCode , TypeErrorAdditionalDiags } ;
5353use crate :: infer;
5454use crate :: infer:: error_reporting:: nice_region_error:: find_anon_type:: find_anon_type;
5555use crate :: infer:: ExpectedFound ;
@@ -1924,7 +1924,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
19241924 & self ,
19251925 trace : & TypeTrace < ' tcx > ,
19261926 terr : TypeError < ' tcx > ,
1927- ) -> Vec < Error0308Subdiags > {
1927+ ) -> Vec < TypeErrorAdditionalDiags > {
19281928 use crate :: traits:: ObligationCauseCode :: MatchExpressionArm ;
19291929 let mut suggestions = Vec :: new ( ) ;
19301930 let span = trace. cause . span ( ) ;
@@ -1946,7 +1946,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
19461946 && !code. starts_with ( "\\ u" ) // forbid all Unicode escapes
19471947 && code. chars ( ) . next ( ) . map_or ( false , |c| c. is_ascii ( ) ) // forbids literal Unicode characters beyond ASCII
19481948 {
1949- suggestions. push ( Error0308Subdiags :: MeantByteLiteral { span, code : escape_literal ( code) } )
1949+ suggestions. push ( TypeErrorAdditionalDiags :: MeantByteLiteral { span, code : escape_literal ( code) } )
19501950 }
19511951 }
19521952 // If a character was expected and the found expression is a string literal
@@ -1957,7 +1957,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
19571957 && let Some ( code) = code. strip_prefix ( '"' ) . and_then ( |s| s. strip_suffix ( '"' ) )
19581958 && code. chars ( ) . count ( ) == 1
19591959 {
1960- suggestions. push ( Error0308Subdiags :: MeantCharLiteral { span, code : escape_literal ( code) } )
1960+ suggestions. push ( TypeErrorAdditionalDiags :: MeantCharLiteral { span, code : escape_literal ( code) } )
19611961 }
19621962 }
19631963 // If a string was expected and the found expression is a character literal,
@@ -1967,7 +1967,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
19671967 if let Some ( code) =
19681968 code. strip_prefix ( '\'' ) . and_then ( |s| s. strip_suffix ( '\'' ) )
19691969 {
1970- suggestions. push ( Error0308Subdiags :: MeantStrLiteral { span, code : escape_literal ( code) } )
1970+ suggestions. push ( TypeErrorAdditionalDiags :: MeantStrLiteral { span, code : escape_literal ( code) } )
19711971 }
19721972 }
19731973 }
@@ -2032,7 +2032,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20322032 && let hir:: ArrayLen :: Body ( hir:: AnonConst { hir_id, .. } ) = length
20332033 && let Some ( span) = self . tcx . hir ( ) . opt_span ( * hir_id)
20342034 {
2035- suggestions. push ( Error0308Subdiags :: ConsiderSpecifyingLength { span, length : sz. found } ) ;
2035+ suggestions. push ( TypeErrorAdditionalDiags :: ConsiderSpecifyingLength { span, length : sz. found } ) ;
20362036 }
20372037 }
20382038 _ => { }
@@ -2043,7 +2043,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20432043 && let hir:: MatchSource :: TryDesugar = source
20442044 && let Some ( ( expected_ty, found_ty, _, _) ) = self . values_str ( trace. values )
20452045 {
2046- suggestions. push ( Error0308Subdiags :: TryCannotConvert { found : found_ty. content ( ) , expected : expected_ty. content ( ) } ) ;
2046+ suggestions. push ( TypeErrorAdditionalDiags :: TryCannotConvert { found : found_ty. content ( ) , expected : expected_ty. content ( ) } ) ;
20472047 }
20482048 suggestions
20492049 }
@@ -2071,7 +2071,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20712071 span : Span ,
20722072 found : Ty < ' tcx > ,
20732073 expected_fields : & List < Ty < ' tcx > > ,
2074- ) -> Option < Error0308Subdiags > {
2074+ ) -> Option < TypeErrorAdditionalDiags > {
20752075 let [ expected_tup_elem] = expected_fields[ ..] else { return None } ;
20762076
20772077 if !self . same_type_modulo_infer ( expected_tup_elem, found) {
@@ -2083,9 +2083,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20832083
20842084 let sugg = if code. starts_with ( '(' ) && code. ends_with ( ')' ) {
20852085 let before_close = span. hi ( ) - BytePos :: from_u32 ( 1 ) ;
2086- Error0308Subdiags :: TupleOnlyComma { span : span. with_hi ( before_close) . shrink_to_hi ( ) }
2086+ TypeErrorAdditionalDiags :: TupleOnlyComma {
2087+ span : span. with_hi ( before_close) . shrink_to_hi ( ) ,
2088+ }
20872089 } else {
2088- Error0308Subdiags :: TupleAlsoParentheses {
2090+ TypeErrorAdditionalDiags :: TupleAlsoParentheses {
20892091 span_low : span. shrink_to_lo ( ) ,
20902092 span_high : span. shrink_to_hi ( ) ,
20912093 }
@@ -2806,8 +2808,8 @@ pub trait ObligationCauseExt<'tcx> {
28062808 & self ,
28072809 terr : TypeError < ' tcx > ,
28082810 span : Span ,
2809- subdiags : Vec < Error0308Subdiags > ,
2810- ) -> FailureCodeDiagnostics ;
2811+ subdiags : Vec < TypeErrorAdditionalDiags > ,
2812+ ) -> ObligationCauseFailureCode ;
28112813 fn as_requirement_str ( & self ) -> & ' static str ;
28122814}
28132815
@@ -2840,42 +2842,44 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
28402842 & self ,
28412843 terr : TypeError < ' tcx > ,
28422844 span : Span ,
2843- subdiags : Vec < Error0308Subdiags > ,
2844- ) -> FailureCodeDiagnostics {
2845+ subdiags : Vec < TypeErrorAdditionalDiags > ,
2846+ ) -> ObligationCauseFailureCode {
28452847 use crate :: traits:: ObligationCauseCode :: * ;
28462848 match self . code ( ) {
28472849 CompareImplItemObligation { kind : ty:: AssocKind :: Fn , .. } => {
2848- FailureCodeDiagnostics :: MethodCompat { span, subdiags }
2850+ ObligationCauseFailureCode :: MethodCompat { span, subdiags }
28492851 }
28502852 CompareImplItemObligation { kind : ty:: AssocKind :: Type , .. } => {
2851- FailureCodeDiagnostics :: TypeCompat { span, subdiags }
2853+ ObligationCauseFailureCode :: TypeCompat { span, subdiags }
28522854 }
28532855 CompareImplItemObligation { kind : ty:: AssocKind :: Const , .. } => {
2854- FailureCodeDiagnostics :: ConstCompat { span, subdiags }
2856+ ObligationCauseFailureCode :: ConstCompat { span, subdiags }
28552857 }
28562858 MatchExpressionArm ( box MatchExpressionArmCause { source, .. } ) => match source {
28572859 hir:: MatchSource :: TryDesugar => {
2858- FailureCodeDiagnostics :: TryCompat { span, subdiags }
2860+ ObligationCauseFailureCode :: TryCompat { span, subdiags }
28592861 }
2860- _ => FailureCodeDiagnostics :: MatchCompat { span, subdiags } ,
2862+ _ => ObligationCauseFailureCode :: MatchCompat { span, subdiags } ,
28612863 } ,
2862- IfExpression { .. } => FailureCodeDiagnostics :: IfElseDifferent { span, subdiags } ,
2863- IfExpressionWithNoElse => FailureCodeDiagnostics :: NoElse { span } ,
2864- LetElse => FailureCodeDiagnostics :: NoDiverge { span, subdiags } ,
2865- MainFunctionType => FailureCodeDiagnostics :: FnMainCorrectType { span } ,
2866- StartFunctionType => FailureCodeDiagnostics :: FnStartCorrectType { span, subdiags } ,
2867- IntrinsicType => FailureCodeDiagnostics :: IntristicCorrectType { span, subdiags } ,
2868- MethodReceiver => FailureCodeDiagnostics :: MethodCorrectType { span, subdiags } ,
2864+ IfExpression { .. } => ObligationCauseFailureCode :: IfElseDifferent { span, subdiags } ,
2865+ IfExpressionWithNoElse => ObligationCauseFailureCode :: NoElse { span } ,
2866+ LetElse => ObligationCauseFailureCode :: NoDiverge { span, subdiags } ,
2867+ MainFunctionType => ObligationCauseFailureCode :: FnMainCorrectType { span } ,
2868+ StartFunctionType => ObligationCauseFailureCode :: FnStartCorrectType { span, subdiags } ,
2869+ IntrinsicType => ObligationCauseFailureCode :: IntristicCorrectType { span, subdiags } ,
2870+ MethodReceiver => ObligationCauseFailureCode :: MethodCorrectType { span, subdiags } ,
28692871
28702872 // In the case where we have no more specific thing to
28712873 // say, also take a look at the error code, maybe we can
28722874 // tailor to that.
28732875 _ => match terr {
28742876 TypeError :: CyclicTy ( ty) if ty. is_closure ( ) || ty. is_generator ( ) => {
2875- FailureCodeDiagnostics :: ClosureSelfref { span }
2877+ ObligationCauseFailureCode :: ClosureSelfref { span }
2878+ }
2879+ TypeError :: IntrinsicCast => {
2880+ ObligationCauseFailureCode :: CantCoerce { span, subdiags }
28762881 }
2877- TypeError :: IntrinsicCast => FailureCodeDiagnostics :: CantCoerce { span, subdiags } ,
2878- _ => FailureCodeDiagnostics :: Generic { span, subdiags } ,
2882+ _ => ObligationCauseFailureCode :: Generic { span, subdiags } ,
28792883 } ,
28802884 }
28812885 }
0 commit comments