@@ -120,6 +120,8 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>(
120
120
ty : Ty < ' tcx > ,
121
121
) -> Result < Vec < ty:: Binder < ' tcx , Ty < ' tcx > > > , NoSolution > {
122
122
match * ty. kind ( ) {
123
+ // impl Sized for u*, i*, bool, f*, FnDef, FnPtr, *(const/mut) T, char, &mut? T, [T; N], dyn* Trait, !
124
+ // impl Sized for Coroutine, CoroutineWitness, Closure, CoroutineClosure
123
125
ty:: Infer ( ty:: IntVar ( _) | ty:: FloatVar ( _) )
124
126
| ty:: Uint ( _)
125
127
| ty:: Int ( _)
@@ -152,8 +154,10 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>(
152
154
bug ! ( "unexpected type `{ty}`" )
153
155
}
154
156
157
+ // impl Sized for (T1, T2, .., Tn) where T1: Sized, T2: Sized, .. Tn: Sized
155
158
ty:: Tuple ( tys) => Ok ( tys. iter ( ) . map ( ty:: Binder :: dummy) . collect ( ) ) ,
156
159
160
+ // impl Sized for Adt where T: Sized forall T in field types
157
161
ty:: Adt ( def, args) => {
158
162
let sized_crit = def. sized_constraint ( ecx. tcx ( ) ) ;
159
163
Ok ( sized_crit. iter_instantiated ( ecx. tcx ( ) , args) . map ( ty:: Binder :: dummy) . collect ( ) )
@@ -167,6 +171,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
167
171
ty : Ty < ' tcx > ,
168
172
) -> Result < Vec < ty:: Binder < ' tcx , Ty < ' tcx > > > , NoSolution > {
169
173
match * ty. kind ( ) {
174
+ // impl Copy/Clone for FnDef, FnPtr
170
175
ty:: FnDef ( ..) | ty:: FnPtr ( _) | ty:: Error ( _) => Ok ( vec ! [ ] ) ,
171
176
172
177
// Implementations are provided in core
@@ -196,12 +201,16 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
196
201
bug ! ( "unexpected type `{ty}`" )
197
202
}
198
203
204
+ // impl Copy/Clone for (T1, T2, .., Tn) where T1: Copy/Clone, T2: Copy/Clone, .. Tn: Copy/Clone
199
205
ty:: Tuple ( tys) => Ok ( tys. iter ( ) . map ( ty:: Binder :: dummy) . collect ( ) ) ,
200
206
207
+ // impl Copy/Clone for Closure where Self::TupledUpvars: Copy/Clone
201
208
ty:: Closure ( _, args) => Ok ( vec ! [ ty:: Binder :: dummy( args. as_closure( ) . tupled_upvars_ty( ) ) ] ) ,
202
209
203
210
ty:: CoroutineClosure ( ..) => Err ( NoSolution ) ,
204
211
212
+ // only when `coroutine_clone` is enabled and the coroutine is movable
213
+ // impl Copy/Clone for Coroutine where T: Copy/Clone forall T in (upvars, witnesses)
205
214
ty:: Coroutine ( def_id, args) => match ecx. tcx ( ) . coroutine_movability ( def_id) {
206
215
Movability :: Static => Err ( NoSolution ) ,
207
216
Movability :: Movable => {
@@ -217,6 +226,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
217
226
}
218
227
} ,
219
228
229
+ // impl Copy/Clone for CoroutineWitness where T: Copy/Clone forall T in coroutine_hidden_types
220
230
ty:: CoroutineWitness ( def_id, args) => Ok ( ecx
221
231
. tcx ( )
222
232
. coroutine_hidden_types ( def_id)
0 commit comments