@@ -718,7 +718,11 @@ impl<'a> Parser<'a> {
718
718
let bounds = self . parse_generic_bounds ( ) ?;
719
719
AssocConstraintKind :: Bound { bounds }
720
720
} else if self . eat ( & token:: Eq ) {
721
- self . parse_assoc_equality_term ( ident, self . prev_token . span ) ?
721
+ self . parse_assoc_equality_term (
722
+ ident,
723
+ gen_args. as_ref ( ) ,
724
+ self . prev_token . span ,
725
+ ) ?
722
726
} else {
723
727
unreachable ! ( ) ;
724
728
} ;
@@ -753,11 +757,13 @@ impl<'a> Parser<'a> {
753
757
}
754
758
755
759
/// Parse the term to the right of an associated item equality constraint.
756
- /// That is, parse `<term>` in `Item = <term>`.
757
- /// Right now, this only admits types in `<term>`.
760
+ ///
761
+ /// That is, parse `$term` in `Item = $term` where `$term` is a type or
762
+ /// a const expression (wrapped in curly braces if complex).
758
763
fn parse_assoc_equality_term (
759
764
& mut self ,
760
765
ident : Ident ,
766
+ gen_args : Option < & GenericArgs > ,
761
767
eq : Span ,
762
768
) -> PResult < ' a , AssocConstraintKind > {
763
769
let arg = self . parse_generic_arg ( None ) ?;
@@ -769,9 +775,15 @@ impl<'a> Parser<'a> {
769
775
c. into ( )
770
776
}
771
777
Some ( GenericArg :: Lifetime ( lt) ) => {
772
- let guar =
773
- self . dcx ( ) . emit_err ( errors:: AssocLifetime { span, lifetime : lt. ident . span } ) ;
774
- self . mk_ty ( span, ast:: TyKind :: Err ( guar) ) . into ( )
778
+ let guar = self . dcx ( ) . emit_err ( errors:: LifetimeInEqConstraint {
779
+ span : lt. ident . span ,
780
+ lifetime : lt. ident ,
781
+ binding_label : span,
782
+ colon_sugg : gen_args
783
+ . map_or ( ident. span , |args| args. span ( ) )
784
+ . between ( lt. ident . span ) ,
785
+ } ) ;
786
+ self . mk_ty ( lt. ident . span , ast:: TyKind :: Err ( guar) ) . into ( )
775
787
}
776
788
None => {
777
789
let after_eq = eq. shrink_to_hi ( ) ;
0 commit comments