@@ -1079,14 +1079,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1079
1079
hir:: TypeBindingKind :: Equality { term }
1080
1080
}
1081
1081
AssocConstraintKind :: Bound { bounds } => {
1082
- enum DesugarKind < ' a > {
1082
+ enum DesugarKind {
1083
1083
ImplTrait ,
1084
- Error ( & ' a ImplTraitPosition ) ,
1084
+ Error ,
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 ,
1091
+
1090
1092
// We are in the return position:
1091
1093
//
1092
1094
// fn foo() -> impl Iterator<Item: Debug>
@@ -1097,19 +1099,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1097
1099
ImplTraitContext :: ReturnPositionOpaqueTy { .. }
1098
1100
| ImplTraitContext :: TypeAliasesOpaqueTy { .. } => DesugarKind :: ImplTrait ,
1099
1101
1100
- // We are in the argument position, but within a dyn type:
1101
- //
1102
- // fn foo(x: dyn Iterator<Item: Debug>)
1103
- //
1104
- // so desugar to
1105
- //
1106
- // fn foo(x: dyn Iterator<Item = impl Debug>)
1107
- ImplTraitContext :: Universal if self . is_in_dyn_type => DesugarKind :: ImplTrait ,
1108
-
1109
- ImplTraitContext :: Disallowed ( position) if self . is_in_dyn_type => {
1110
- DesugarKind :: Error ( position)
1111
- }
1112
-
1113
1102
// We are in the parameter position, but not within a dyn type:
1114
1103
//
1115
1104
// fn foo(x: impl Iterator<Item: Debug>)
@@ -1154,11 +1143,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1154
1143
1155
1144
hir:: TypeBindingKind :: Constraint { bounds }
1156
1145
}
1157
- DesugarKind :: Error ( position) => {
1158
- let guar = self . dcx ( ) . emit_err ( errors:: MisplacedAssocTyBinding {
1159
- span : constraint. span ,
1160
- position : DiagnosticArgFromDisplay ( position) ,
1161
- } ) ;
1146
+ DesugarKind :: Error => {
1147
+ let guar = self
1148
+ . dcx ( )
1149
+ . emit_err ( errors:: MisplacedAssocTyBinding { span : constraint. span } ) ;
1162
1150
let err_ty =
1163
1151
& * self . arena . alloc ( self . ty ( constraint. span , hir:: TyKind :: Err ( guar) ) ) ;
1164
1152
hir:: TypeBindingKind :: Equality { term : err_ty. into ( ) }
0 commit comments