@@ -120,6 +120,8 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>(
120120 ty : Ty < ' tcx > ,
121121) -> Result < Vec < ty:: Binder < ' tcx , Ty < ' tcx > > > , NoSolution > {
122122 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
123125 ty:: Infer ( ty:: IntVar ( _) | ty:: FloatVar ( _) )
124126 | ty:: Uint ( _)
125127 | ty:: Int ( _)
@@ -152,8 +154,10 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>(
152154 bug ! ( "unexpected type `{ty}`" )
153155 }
154156
157+ // impl Sized for (T1, T2, .., Tn) where T1: Sized, T2: Sized, .. Tn: Sized
155158 ty:: Tuple ( tys) => Ok ( tys. iter ( ) . map ( ty:: Binder :: dummy) . collect ( ) ) ,
156159
160+ // impl Sized for Adt where T: Sized forall T in field types
157161 ty:: Adt ( def, args) => {
158162 let sized_crit = def. sized_constraint ( ecx. tcx ( ) ) ;
159163 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>(
167171 ty : Ty < ' tcx > ,
168172) -> Result < Vec < ty:: Binder < ' tcx , Ty < ' tcx > > > , NoSolution > {
169173 match * ty. kind ( ) {
174+ // impl Copy/Clone for FnDef, FnPtr
170175 ty:: FnDef ( ..) | ty:: FnPtr ( _) | ty:: Error ( _) => Ok ( vec ! [ ] ) ,
171176
172177 // Implementations are provided in core
@@ -196,12 +201,16 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
196201 bug ! ( "unexpected type `{ty}`" )
197202 }
198203
204+ // impl Copy/Clone for (T1, T2, .., Tn) where T1: Copy/Clone, T2: Copy/Clone, .. Tn: Copy/Clone
199205 ty:: Tuple ( tys) => Ok ( tys. iter ( ) . map ( ty:: Binder :: dummy) . collect ( ) ) ,
200206
207+ // impl Copy/Clone for Closure where Self::TupledUpvars: Copy/Clone
201208 ty:: Closure ( _, args) => Ok ( vec ! [ ty:: Binder :: dummy( args. as_closure( ) . tupled_upvars_ty( ) ) ] ) ,
202209
203210 ty:: CoroutineClosure ( ..) => Err ( NoSolution ) ,
204211
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)
205214 ty:: Coroutine ( def_id, args) => match ecx. tcx ( ) . coroutine_movability ( def_id) {
206215 Movability :: Static => Err ( NoSolution ) ,
207216 Movability :: Movable => {
@@ -217,6 +226,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
217226 }
218227 } ,
219228
229+ // impl Copy/Clone for CoroutineWitness where T: Copy/Clone forall T in coroutine_hidden_types
220230 ty:: CoroutineWitness ( def_id, args) => Ok ( ecx
221231 . tcx ( )
222232 . coroutine_hidden_types ( def_id)
0 commit comments