@@ -49,7 +49,7 @@ use super::lexical_region_resolve::RegionResolutionError;
49
49
use super :: region_constraints:: GenericKind ;
50
50
use super :: { InferCtxt , RegionVariableOrigin , SubregionOrigin , TypeTrace , ValuePairs } ;
51
51
52
- use crate :: errors:: { self , Error0308Subdiags , FailureCodeDiagnostics } ;
52
+ use crate :: errors:: { self , ObligationCauseFailureCode , TypeErrorAdditionalDiags } ;
53
53
use crate :: infer;
54
54
use crate :: infer:: error_reporting:: nice_region_error:: find_anon_type:: find_anon_type;
55
55
use crate :: infer:: ExpectedFound ;
@@ -1924,7 +1924,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1924
1924
& self ,
1925
1925
trace : & TypeTrace < ' tcx > ,
1926
1926
terr : TypeError < ' tcx > ,
1927
- ) -> Vec < Error0308Subdiags > {
1927
+ ) -> Vec < TypeErrorAdditionalDiags > {
1928
1928
use crate :: traits:: ObligationCauseCode :: MatchExpressionArm ;
1929
1929
let mut suggestions = Vec :: new ( ) ;
1930
1930
let span = trace. cause . span ( ) ;
@@ -1946,7 +1946,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1946
1946
&& !code. starts_with ( "\\ u" ) // forbid all Unicode escapes
1947
1947
&& code. chars ( ) . next ( ) . map_or ( false , |c| c. is_ascii ( ) ) // forbids literal Unicode characters beyond ASCII
1948
1948
{
1949
- suggestions. push ( Error0308Subdiags :: MeantByteLiteral { span, code : escape_literal ( code) } )
1949
+ suggestions. push ( TypeErrorAdditionalDiags :: MeantByteLiteral { span, code : escape_literal ( code) } )
1950
1950
}
1951
1951
}
1952
1952
// If a character was expected and the found expression is a string literal
@@ -1957,7 +1957,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1957
1957
&& let Some ( code) = code. strip_prefix ( '"' ) . and_then ( |s| s. strip_suffix ( '"' ) )
1958
1958
&& code. chars ( ) . count ( ) == 1
1959
1959
{
1960
- suggestions. push ( Error0308Subdiags :: MeantCharLiteral { span, code : escape_literal ( code) } )
1960
+ suggestions. push ( TypeErrorAdditionalDiags :: MeantCharLiteral { span, code : escape_literal ( code) } )
1961
1961
}
1962
1962
}
1963
1963
// If a string was expected and the found expression is a character literal,
@@ -1967,7 +1967,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1967
1967
if let Some ( code) =
1968
1968
code. strip_prefix ( '\'' ) . and_then ( |s| s. strip_suffix ( '\'' ) )
1969
1969
{
1970
- suggestions. push ( Error0308Subdiags :: MeantStrLiteral { span, code : escape_literal ( code) } )
1970
+ suggestions. push ( TypeErrorAdditionalDiags :: MeantStrLiteral { span, code : escape_literal ( code) } )
1971
1971
}
1972
1972
}
1973
1973
}
@@ -2032,7 +2032,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2032
2032
&& let hir:: ArrayLen :: Body ( hir:: AnonConst { hir_id, .. } ) = length
2033
2033
&& let Some ( span) = self . tcx . hir ( ) . opt_span ( * hir_id)
2034
2034
{
2035
- suggestions. push ( Error0308Subdiags :: ConsiderSpecifyingLength { span, length : sz. found } ) ;
2035
+ suggestions. push ( TypeErrorAdditionalDiags :: ConsiderSpecifyingLength { span, length : sz. found } ) ;
2036
2036
}
2037
2037
}
2038
2038
_ => { }
@@ -2043,7 +2043,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2043
2043
&& let hir:: MatchSource :: TryDesugar = source
2044
2044
&& let Some ( ( expected_ty, found_ty, _, _) ) = self . values_str ( trace. values )
2045
2045
{
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 ( ) } ) ;
2047
2047
}
2048
2048
suggestions
2049
2049
}
@@ -2071,7 +2071,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2071
2071
span : Span ,
2072
2072
found : Ty < ' tcx > ,
2073
2073
expected_fields : & List < Ty < ' tcx > > ,
2074
- ) -> Option < Error0308Subdiags > {
2074
+ ) -> Option < TypeErrorAdditionalDiags > {
2075
2075
let [ expected_tup_elem] = expected_fields[ ..] else { return None } ;
2076
2076
2077
2077
if !self . same_type_modulo_infer ( expected_tup_elem, found) {
@@ -2083,9 +2083,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2083
2083
2084
2084
let sugg = if code. starts_with ( '(' ) && code. ends_with ( ')' ) {
2085
2085
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
+ }
2087
2089
} else {
2088
- Error0308Subdiags :: TupleAlsoParentheses {
2090
+ TypeErrorAdditionalDiags :: TupleAlsoParentheses {
2089
2091
span_low : span. shrink_to_lo ( ) ,
2090
2092
span_high : span. shrink_to_hi ( ) ,
2091
2093
}
@@ -2806,8 +2808,8 @@ pub trait ObligationCauseExt<'tcx> {
2806
2808
& self ,
2807
2809
terr : TypeError < ' tcx > ,
2808
2810
span : Span ,
2809
- subdiags : Vec < Error0308Subdiags > ,
2810
- ) -> FailureCodeDiagnostics ;
2811
+ subdiags : Vec < TypeErrorAdditionalDiags > ,
2812
+ ) -> ObligationCauseFailureCode ;
2811
2813
fn as_requirement_str ( & self ) -> & ' static str ;
2812
2814
}
2813
2815
@@ -2840,42 +2842,44 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
2840
2842
& self ,
2841
2843
terr : TypeError < ' tcx > ,
2842
2844
span : Span ,
2843
- subdiags : Vec < Error0308Subdiags > ,
2844
- ) -> FailureCodeDiagnostics {
2845
+ subdiags : Vec < TypeErrorAdditionalDiags > ,
2846
+ ) -> ObligationCauseFailureCode {
2845
2847
use crate :: traits:: ObligationCauseCode :: * ;
2846
2848
match self . code ( ) {
2847
2849
CompareImplItemObligation { kind : ty:: AssocKind :: Fn , .. } => {
2848
- FailureCodeDiagnostics :: MethodCompat { span, subdiags }
2850
+ ObligationCauseFailureCode :: MethodCompat { span, subdiags }
2849
2851
}
2850
2852
CompareImplItemObligation { kind : ty:: AssocKind :: Type , .. } => {
2851
- FailureCodeDiagnostics :: TypeCompat { span, subdiags }
2853
+ ObligationCauseFailureCode :: TypeCompat { span, subdiags }
2852
2854
}
2853
2855
CompareImplItemObligation { kind : ty:: AssocKind :: Const , .. } => {
2854
- FailureCodeDiagnostics :: ConstCompat { span, subdiags }
2856
+ ObligationCauseFailureCode :: ConstCompat { span, subdiags }
2855
2857
}
2856
2858
MatchExpressionArm ( box MatchExpressionArmCause { source, .. } ) => match source {
2857
2859
hir:: MatchSource :: TryDesugar => {
2858
- FailureCodeDiagnostics :: TryCompat { span, subdiags }
2860
+ ObligationCauseFailureCode :: TryCompat { span, subdiags }
2859
2861
}
2860
- _ => FailureCodeDiagnostics :: MatchCompat { span, subdiags } ,
2862
+ _ => ObligationCauseFailureCode :: MatchCompat { span, subdiags } ,
2861
2863
} ,
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 } ,
2869
2871
2870
2872
// In the case where we have no more specific thing to
2871
2873
// say, also take a look at the error code, maybe we can
2872
2874
// tailor to that.
2873
2875
_ => match terr {
2874
2876
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 }
2876
2881
}
2877
- TypeError :: IntrinsicCast => FailureCodeDiagnostics :: CantCoerce { span, subdiags } ,
2878
- _ => FailureCodeDiagnostics :: Generic { span, subdiags } ,
2882
+ _ => ObligationCauseFailureCode :: Generic { span, subdiags } ,
2879
2883
} ,
2880
2884
}
2881
2885
}
0 commit comments