@@ -1883,7 +1883,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
18831883 exp_span, exp_found. expected, exp_found. found,
18841884 ) ;
18851885
1886- if let ObligationCauseCode :: CompareImplMethodObligation { .. } = cause. code ( ) {
1886+ if let ObligationCauseCode :: CompareImplItemObligation { .. } = cause. code ( ) {
18871887 return ;
18881888 }
18891889
@@ -2351,24 +2351,18 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
23512351 GenericKind :: Projection ( ref p) => format ! ( "the associated type `{}`" , p) ,
23522352 } ;
23532353
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 (
23602361 span,
23612362 impl_item_def_id,
23622363 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+ ) ;
23722366 }
23732367
23742368 fn binding_suggestion < ' tcx , S : fmt:: Display > (
@@ -2794,8 +2788,15 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
27942788 use self :: FailureCode :: * ;
27952789 use crate :: traits:: ObligationCauseCode :: * ;
27962790 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+ }
27992800 MatchExpressionArm ( box MatchExpressionArmCause { source, .. } ) => {
28002801 Error0308 ( match source {
28012802 hir:: MatchSource :: TryDesugar => "`?` operator has incompatible types" ,
@@ -2829,8 +2830,15 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
28292830 fn as_requirement_str ( & self ) -> & ' static str {
28302831 use crate :: traits:: ObligationCauseCode :: * ;
28312832 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+ }
28342842 ExprAssignable => "expression is assignable" ,
28352843 IfExpression { .. } => "`if` and `else` have incompatible types" ,
28362844 IfExpressionWithNoElse => "`if` missing an `else` returns `()`" ,
0 commit comments