@@ -128,21 +128,7 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained(
128
128
for param in & impl_generics. own_params {
129
129
match param. kind {
130
130
ty:: GenericParamDefKind :: Lifetime => {
131
- let param_lt = cgp:: Parameter :: from ( param. to_early_bound_region_data ( ) ) ;
132
- if lifetimes_in_associated_types. contains ( & param_lt) // (*)
133
- && !input_parameters. contains ( & param_lt)
134
- {
135
- let mut diag = tcx. dcx ( ) . create_err ( UnconstrainedGenericParameter {
136
- span : tcx. def_span ( param. def_id ) ,
137
- param_name : param. name ,
138
- param_def_kind : tcx. def_descr ( param. def_id ) ,
139
- const_param_note : false ,
140
- const_param_note2 : false ,
141
- } ) ;
142
- diag. code ( E0207 ) ;
143
- res = Err ( diag. emit ( ) ) ;
144
- }
145
- // (*) This is a horrible concession to reality. I think it'd be
131
+ // This is a horrible concession to reality. I think it'd be
146
132
// better to just ban unconstrained lifetimes outright, but in
147
133
// practice people do non-hygienic macros like:
148
134
//
@@ -160,6 +146,20 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained(
160
146
// permit those, so long as the lifetimes aren't used in
161
147
// associated types. I believe this is sound, because lifetimes
162
148
// used elsewhere are not projected back out.
149
+ let param_lt = cgp:: Parameter :: from ( param. to_early_bound_region_data ( ) ) ;
150
+ if lifetimes_in_associated_types. contains ( & param_lt)
151
+ && !input_parameters. contains ( & param_lt)
152
+ {
153
+ let mut diag = tcx. dcx ( ) . create_err ( UnconstrainedGenericParameter {
154
+ span : tcx. def_span ( param. def_id ) ,
155
+ param_name : param. name ,
156
+ param_def_kind : tcx. def_descr ( param. def_id ) ,
157
+ const_param_note : false ,
158
+ const_param_note2 : false ,
159
+ } ) ;
160
+ diag. code ( E0207 ) ;
161
+ res = Err ( diag. emit ( ) ) ;
162
+ }
163
163
}
164
164
ty:: GenericParamDefKind :: Type { .. } | ty:: GenericParamDefKind :: Const { .. } => {
165
165
// Enforced in `enforce_impl_non_lifetime_params_are_constrained`.
0 commit comments