@@ -1081,13 +1081,29 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1081
1081
AssocConstraintKind :: Bound { bounds } => {
1082
1082
enum DesugarKind {
1083
1083
ImplTrait ,
1084
- Error ,
1084
+ Error ( Option < Span > ) ,
1085
1085
Bound ,
1086
1086
}
1087
1087
1088
1088
// Piggy-back on the `impl Trait` context to figure out the correct behavior.
1089
1089
let desugar_kind = match itctx {
1090
- _ if self . is_in_dyn_type => DesugarKind :: Error ,
1090
+ ImplTraitContext :: ReturnPositionOpaqueTy { .. }
1091
+ | ImplTraitContext :: TypeAliasesOpaqueTy { .. }
1092
+ | ImplTraitContext :: Universal
1093
+ if self . is_in_dyn_type =>
1094
+ {
1095
+ let bound_end_span = constraint
1096
+ . gen_args
1097
+ . as_ref ( )
1098
+ . map_or ( constraint. ident . span , |args| args. span ( ) ) ;
1099
+ let colon_span = if bound_end_span. eq_ctxt ( constraint. span ) {
1100
+ Some ( self . tcx . sess . source_map ( ) . next_point ( bound_end_span) )
1101
+ } else {
1102
+ None
1103
+ } ;
1104
+ DesugarKind :: Error ( colon_span)
1105
+ }
1106
+ _ if self . is_in_dyn_type => DesugarKind :: Error ( None ) ,
1091
1107
1092
1108
// We are in the return position:
1093
1109
//
@@ -1143,10 +1159,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1143
1159
1144
1160
hir:: TypeBindingKind :: Constraint { bounds }
1145
1161
}
1146
- DesugarKind :: Error => {
1147
- let guar = self
1148
- . dcx ( )
1149
- . emit_err ( errors:: MisplacedAssocTyBinding { span : constraint. span } ) ;
1162
+ DesugarKind :: Error ( suggestion) => {
1163
+ let guar = self . dcx ( ) . emit_err ( errors:: MisplacedAssocTyBinding {
1164
+ span : constraint. span ,
1165
+ suggestion,
1166
+ } ) ;
1150
1167
let err_ty =
1151
1168
& * self . arena . alloc ( self . ty ( constraint. span , hir:: TyKind :: Err ( guar) ) ) ;
1152
1169
hir:: TypeBindingKind :: Equality { term : err_ty. into ( ) }
0 commit comments