@@ -753,18 +753,13 @@ impl<'a> Parser<'a> {
753753 }
754754 let kind = if self . eat ( exp ! ( Colon ) ) {
755755 AssocItemConstraintKind :: Bound { bounds : self . parse_generic_bounds ( ) ? }
756- } else if self . eat ( exp ! ( Eq ) ) {
757- self . parse_assoc_equality_term (
758- ident,
759- gen_args. as_ref ( ) ,
760- self . prev_token . span ,
761- ) ?
756+ } else if self . check ( exp ! ( Eq ) ) {
757+ self . parse_assoc_equality_term ( ident, gen_args. as_ref ( ) ) ?
762758 } else {
763759 unreachable ! ( ) ;
764760 } ;
765761
766762 let span = lo. to ( self . prev_token . span ) ;
767-
768763 let constraint =
769764 AssocItemConstraint { id : ast:: DUMMY_NODE_ID , ident, gen_args, kind, span } ;
770765 Ok ( Some ( AngleBracketedArg :: Constraint ( constraint) ) )
@@ -792,8 +787,10 @@ impl<'a> Parser<'a> {
792787 & mut self ,
793788 ident : Ident ,
794789 gen_args : Option < & GenericArgs > ,
795- eq : Span ,
796790 ) -> PResult < ' a , AssocItemConstraintKind > {
791+ let prev_token_span = self . prev_token . span ;
792+ let eq_span = self . token . span ;
793+ self . expect ( exp ! ( Eq ) ) ?;
797794 let arg = self . parse_generic_arg ( None ) ?;
798795 let span = ident. span . to ( self . prev_token . span ) ;
799796 let term = match arg {
@@ -814,20 +811,20 @@ impl<'a> Parser<'a> {
814811 self . mk_ty ( lt. ident . span , ast:: TyKind :: Err ( guar) ) . into ( )
815812 }
816813 None => {
817- let after_eq = eq . shrink_to_hi ( ) ;
814+ let after_eq = eq_span . shrink_to_hi ( ) ;
818815 let before_next = self . token . span . shrink_to_lo ( ) ;
819816 let mut err = self
820817 . dcx ( )
821818 . struct_span_err ( after_eq. to ( before_next) , "missing type to the right of `=`" ) ;
822819 if matches ! ( self . token. kind, token:: Comma | token:: Gt ) {
823820 err. span_suggestion (
824- self . psess . source_map ( ) . next_point ( eq ) . to ( before_next) ,
821+ self . psess . source_map ( ) . next_point ( eq_span ) . to ( before_next) ,
825822 "to constrain the associated type, add a type after `=`" ,
826823 " TheType" ,
827824 Applicability :: HasPlaceholders ,
828825 ) ;
829826 err. span_suggestion (
830- eq . to ( before_next) ,
827+ prev_token_span . shrink_to_hi ( ) . to ( before_next) ,
831828 format ! ( "remove the `=` if `{ident}` is a type" ) ,
832829 "" ,
833830 Applicability :: MaybeIncorrect ,
0 commit comments