@@ -1085,14 +1085,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1085
1085
hir:: TypeBindingKind :: Equality { term }
1086
1086
}
1087
1087
AssocConstraintKind :: Bound { bounds } => {
1088
- enum DesugarKind < ' a > {
1088
+ enum DesugarKind {
1089
1089
ImplTrait ,
1090
- Error ( & ' a ImplTraitPosition ) ,
1090
+ Error ,
1091
1091
Bound ,
1092
1092
}
1093
1093
1094
1094
// Piggy-back on the `impl Trait` context to figure out the correct behavior.
1095
1095
let desugar_kind = match itctx {
1096
+ _ if self . is_in_dyn_type => DesugarKind :: Error ,
1097
+
1096
1098
// We are in the return position:
1097
1099
//
1098
1100
// fn foo() -> impl Iterator<Item: Debug>
@@ -1103,19 +1105,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1103
1105
ImplTraitContext :: ReturnPositionOpaqueTy { .. }
1104
1106
| ImplTraitContext :: TypeAliasesOpaqueTy { .. } => DesugarKind :: ImplTrait ,
1105
1107
1106
- // We are in the argument position, but within a dyn type:
1107
- //
1108
- // fn foo(x: dyn Iterator<Item: Debug>)
1109
- //
1110
- // so desugar to
1111
- //
1112
- // fn foo(x: dyn Iterator<Item = impl Debug>)
1113
- ImplTraitContext :: Universal if self . is_in_dyn_type => DesugarKind :: ImplTrait ,
1114
-
1115
- ImplTraitContext :: Disallowed ( position) if self . is_in_dyn_type => {
1116
- DesugarKind :: Error ( position)
1117
- }
1118
-
1119
1108
// We are in the parameter position, but not within a dyn type:
1120
1109
//
1121
1110
// fn foo(x: impl Iterator<Item: Debug>)
@@ -1160,11 +1149,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1160
1149
1161
1150
hir:: TypeBindingKind :: Constraint { bounds }
1162
1151
}
1163
- DesugarKind :: Error ( position) => {
1164
- let guar = self . dcx ( ) . emit_err ( errors:: MisplacedAssocTyBinding {
1165
- span : constraint. span ,
1166
- position : DiagnosticArgFromDisplay ( position) ,
1167
- } ) ;
1152
+ DesugarKind :: Error => {
1153
+ let guar = self
1154
+ . dcx ( )
1155
+ . emit_err ( errors:: MisplacedAssocTyBinding { span : constraint. span } ) ;
1168
1156
let err_ty =
1169
1157
& * self . arena . alloc ( self . ty ( constraint. span , hir:: TyKind :: Err ( guar) ) ) ;
1170
1158
hir:: TypeBindingKind :: Equality { term : err_ty. into ( ) }
0 commit comments