@@ -1883,7 +1883,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1883
1883
exp_span, exp_found. expected, exp_found. found,
1884
1884
) ;
1885
1885
1886
- if let ObligationCauseCode :: CompareImplMethodObligation { .. } = cause. code ( ) {
1886
+ if let ObligationCauseCode :: CompareImplItemObligation { .. } = cause. code ( ) {
1887
1887
return ;
1888
1888
}
1889
1889
@@ -2351,24 +2351,18 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
2351
2351
GenericKind :: Projection ( ref p) => format ! ( "the associated type `{}`" , p) ,
2352
2352
} ;
2353
2353
2354
- match origin {
2355
- Some ( SubregionOrigin :: CompareImplMethodObligation {
2356
- span,
2357
- impl_item_def_id,
2358
- trait_item_def_id,
2359
- } | SubregionOrigin :: CompareImplTypeObligation {
2354
+ if let Some ( SubregionOrigin :: CompareImplItemObligation {
2355
+ span,
2356
+ impl_item_def_id,
2357
+ trait_item_def_id,
2358
+ } ) = origin
2359
+ {
2360
+ return self . report_extra_impl_obligation (
2360
2361
span,
2361
2362
impl_item_def_id,
2362
2363
trait_item_def_id,
2363
- } ) => {
2364
- return self . report_extra_impl_obligation (
2365
- span,
2366
- impl_item_def_id,
2367
- trait_item_def_id,
2368
- & format ! ( "`{}: {}`" , bound_kind, sub) ,
2369
- ) ;
2370
- }
2371
- _ => { }
2364
+ & format ! ( "`{}: {}`" , bound_kind, sub) ,
2365
+ ) ;
2372
2366
}
2373
2367
2374
2368
fn binding_suggestion < ' tcx , S : fmt:: Display > (
@@ -2794,8 +2788,15 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
2794
2788
use self :: FailureCode :: * ;
2795
2789
use crate :: traits:: ObligationCauseCode :: * ;
2796
2790
match self . code ( ) {
2797
- CompareImplMethodObligation { .. } => Error0308 ( "method not compatible with trait" ) ,
2798
- CompareImplTypeObligation { .. } => Error0308 ( "type not compatible with trait" ) ,
2791
+ CompareImplItemObligation { kind : ty:: AssocKind :: Fn , .. } => {
2792
+ Error0308 ( "method not compatible with trait" )
2793
+ }
2794
+ CompareImplItemObligation { kind : ty:: AssocKind :: Type , .. } => {
2795
+ Error0308 ( "type not compatible with trait" )
2796
+ }
2797
+ CompareImplItemObligation { kind : ty:: AssocKind :: Const , .. } => {
2798
+ Error0308 ( "const not compatible with trait" )
2799
+ }
2799
2800
MatchExpressionArm ( box MatchExpressionArmCause { source, .. } ) => {
2800
2801
Error0308 ( match source {
2801
2802
hir:: MatchSource :: TryDesugar => "`?` operator has incompatible types" ,
@@ -2829,8 +2830,15 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
2829
2830
fn as_requirement_str ( & self ) -> & ' static str {
2830
2831
use crate :: traits:: ObligationCauseCode :: * ;
2831
2832
match self . code ( ) {
2832
- CompareImplMethodObligation { .. } => "method type is compatible with trait" ,
2833
- CompareImplTypeObligation { .. } => "associated type is compatible with trait" ,
2833
+ CompareImplItemObligation { kind : ty:: AssocKind :: Fn , .. } => {
2834
+ "method type is compatible with trait"
2835
+ }
2836
+ CompareImplItemObligation { kind : ty:: AssocKind :: Type , .. } => {
2837
+ "associated type is compatible with trait"
2838
+ }
2839
+ CompareImplItemObligation { kind : ty:: AssocKind :: Const , .. } => {
2840
+ "const is compatible with trait"
2841
+ }
2834
2842
ExprAssignable => "expression is assignable" ,
2835
2843
IfExpression { .. } => "`if` and `else` have incompatible types" ,
2836
2844
IfExpressionWithNoElse => "`if` missing an `else` returns `()`" ,
0 commit comments