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