@@ -987,9 +987,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
987987 let target = self . infcx . shallow_resolve ( target) ;
988988 debug ! ( ?source, ?target, "confirm_builtin_unsize_candidate" ) ;
989989
990- let mut nested = vec ! [ ] ;
991- let src;
992- match ( source. kind ( ) , target. kind ( ) ) {
990+ Ok ( match ( source. kind ( ) , target. kind ( ) ) {
993991 // Trait+Kx+'a -> Trait+Ky+'b (auto traits and lifetime subtyping).
994992 ( & ty:: Dynamic ( ref data_a, r_a, dyn_a) , & ty:: Dynamic ( ref data_b, r_b, dyn_b) )
995993 if dyn_a == dyn_b =>
@@ -1016,24 +1014,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10161014
10171015 // Require that the traits involved in this upcast are **equal**;
10181016 // only the **lifetime bound** is changed.
1019- let InferOk { obligations, .. } = self
1017+ let InferOk { mut obligations, .. } = self
10201018 . infcx
10211019 . at ( & obligation. cause , obligation. param_env )
10221020 . sup ( DefineOpaqueTypes :: No , target, source_trait)
10231021 . map_err ( |_| Unimplemented ) ?;
1024- nested. extend ( obligations) ;
10251022
10261023 // Register one obligation for 'a: 'b.
10271024 let outlives = ty:: OutlivesPredicate ( r_a, r_b) ;
1028- nested . push ( Obligation :: with_depth (
1025+ obligations . push ( Obligation :: with_depth (
10291026 tcx,
10301027 obligation. cause . clone ( ) ,
10311028 obligation. recursion_depth + 1 ,
10321029 obligation. param_env ,
10331030 obligation. predicate . rebind ( outlives) ,
10341031 ) ) ;
10351032
1036- src = BuiltinImplSource :: Misc ;
1033+ ImplSource :: Builtin ( BuiltinImplSource :: Misc , obligations )
10371034 }
10381035
10391036 // `T` -> `Trait`
@@ -1059,11 +1056,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10591056 // words, if the object type is `Foo + Send`, this would create an obligation for
10601057 // the `Send` check.)
10611058 // - Projection predicates
1062- nested. extend (
1063- data. iter ( ) . map ( |predicate| {
1064- predicate_to_obligation ( predicate. with_self_ty ( tcx, source) )
1065- } ) ,
1066- ) ;
1059+ let mut nested: Vec < _ > = data
1060+ . iter ( )
1061+ . map ( |predicate| predicate_to_obligation ( predicate. with_self_ty ( tcx, source) ) )
1062+ . collect ( ) ;
10671063
10681064 // We can only make objects from sized types.
10691065 let tr = ty:: TraitRef :: from_lang_item (
@@ -1081,7 +1077,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10811077 ty:: Binder :: dummy ( ty:: ClauseKind :: TypeOutlives ( outlives) ) . to_predicate ( tcx) ,
10821078 ) ) ;
10831079
1084- src = BuiltinImplSource :: Misc ;
1080+ ImplSource :: Builtin ( BuiltinImplSource :: Misc , nested )
10851081 }
10861082
10871083 // `[T; n]` -> `[T]`
@@ -1091,9 +1087,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10911087 . at ( & obligation. cause , obligation. param_env )
10921088 . eq ( DefineOpaqueTypes :: No , b, a)
10931089 . map_err ( |_| Unimplemented ) ?;
1094- nested. extend ( obligations) ;
10951090
1096- src = BuiltinImplSource :: Misc ;
1091+ ImplSource :: Builtin ( BuiltinImplSource :: Misc , obligations )
10971092 }
10981093
10991094 // `Struct<T>` -> `Struct<U>`
@@ -1106,6 +1101,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11061101 let tail_field = def. non_enum_variant ( ) . tail ( ) ;
11071102 let tail_field_ty = tcx. type_of ( tail_field. did ) ;
11081103
1104+ let mut nested = vec ! [ ] ;
1105+
11091106 // Extract `TailField<T>` and `TailField<U>` from `Struct<T>` and `Struct<U>`,
11101107 // normalizing in the process, since `type_of` returns something directly from
11111108 // astconv (which means it's un-normalized).
@@ -1151,7 +1148,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11511148 ) ;
11521149 nested. push ( tail_unsize_obligation) ;
11531150
1154- src = BuiltinImplSource :: Misc ;
1151+ ImplSource :: Builtin ( BuiltinImplSource :: Misc , nested )
11551152 }
11561153
11571154 // `(.., T)` -> `(.., U)`
@@ -1166,27 +1163,24 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11661163 // last element is equal to the target.
11671164 let new_tuple =
11681165 Ty :: new_tup_from_iter ( tcx, a_mid. iter ( ) . copied ( ) . chain ( iter:: once ( b_last) ) ) ;
1169- let InferOk { obligations, .. } = self
1166+ let InferOk { mut obligations, .. } = self
11701167 . infcx
11711168 . at ( & obligation. cause , obligation. param_env )
11721169 . eq ( DefineOpaqueTypes :: No , target, new_tuple)
11731170 . map_err ( |_| Unimplemented ) ?;
1174- nested. extend ( obligations) ;
11751171
11761172 // Add a nested `T: Unsize<U>` predicate.
11771173 let last_unsize_obligation = obligation. with (
11781174 tcx,
11791175 ty:: TraitRef :: new ( tcx, obligation. predicate . def_id ( ) , [ a_last, b_last] ) ,
11801176 ) ;
1181- nested . push ( last_unsize_obligation) ;
1177+ obligations . push ( last_unsize_obligation) ;
11821178
1183- src = BuiltinImplSource :: TupleUnsizing ;
1179+ ImplSource :: Builtin ( BuiltinImplSource :: TupleUnsizing , obligations )
11841180 }
11851181
11861182 _ => bug ! ( "source: {source}, target: {target}" ) ,
1187- } ;
1188-
1189- Ok ( ImplSource :: Builtin ( src, nested) )
1183+ } )
11901184 }
11911185
11921186 fn confirm_const_destruct_candidate (
0 commit comments