@@ -626,7 +626,11 @@ impl<'a> Parser<'a> {
626626 let bounds = self . parse_generic_bounds ( ) ?;
627627 AssocConstraintKind :: Bound { bounds }
628628 } else if self . eat ( & token:: Eq ) {
629- self . parse_assoc_equality_term ( ident, self . prev_token . span ) ?
629+ self . parse_assoc_equality_term (
630+ ident,
631+ gen_args. as_ref ( ) ,
632+ self . prev_token . span ,
633+ ) ?
630634 } else {
631635 unreachable ! ( ) ;
632636 } ;
@@ -663,11 +667,13 @@ impl<'a> Parser<'a> {
663667 }
664668
665669 /// Parse the term to the right of an associated item equality constraint.
666- /// That is, parse `<term>` in `Item = <term>`.
667- /// Right now, this only admits types in `<term>`.
670+ ///
671+ /// That is, parse `$term` in `Item = $term` where `$term` is a type or
672+ /// a const expression (wrapped in curly braces if complex).
668673 fn parse_assoc_equality_term (
669674 & mut self ,
670675 ident : Ident ,
676+ gen_args : Option < & GenericArgs > ,
671677 eq : Span ,
672678 ) -> PResult < ' a , AssocConstraintKind > {
673679 let arg = self . parse_generic_arg ( None ) ?;
@@ -679,9 +685,15 @@ impl<'a> Parser<'a> {
679685 c. into ( )
680686 }
681687 Some ( GenericArg :: Lifetime ( lt) ) => {
682- let guar =
683- self . dcx ( ) . emit_err ( errors:: AssocLifetime { span, lifetime : lt. ident . span } ) ;
684- self . mk_ty ( span, ast:: TyKind :: Err ( guar) ) . into ( )
688+ let guar = self . dcx ( ) . emit_err ( errors:: LifetimeInEqConstraint {
689+ span : lt. ident . span ,
690+ lifetime : lt. ident ,
691+ binding_label : span,
692+ colon_sugg : gen_args
693+ . map_or ( ident. span , |args| args. span ( ) )
694+ . between ( lt. ident . span ) ,
695+ } ) ;
696+ self . mk_ty ( lt. ident . span , ast:: TyKind :: Err ( guar) ) . into ( )
685697 }
686698 None => {
687699 let after_eq = eq. shrink_to_hi ( ) ;
0 commit comments