diff options
| author | Boxy <supbscripter@gmail.com> | 2023-03-17 14:35:12 +0000 |
|---|---|---|
| committer | Boxy <supbscripter@gmail.com> | 2023-03-17 14:35:12 +0000 |
| commit | e624ef4d64cc800b9d69104bd3f77fc10d65080b (patch) | |
| tree | ca9461941ecaf26b1f039d081a3c0b338301b238 /compiler | |
| parent | aa8de179283b4c9aac6039ad2b04529ed6055680 (diff) | |
| download | rust-e624ef4d64cc800b9d69104bd3f77fc10d65080b.tar.gz rust-e624ef4d64cc800b9d69104bd3f77fc10d65080b.zip | |
replace chain with two `add_goal`
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/trait_goals.rs | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals.rs b/compiler/rustc_trait_selection/src/solve/trait_goals.rs index 9951c87f4fc..8ab55c79fc4 100644 --- a/compiler/rustc_trait_selection/src/solve/trait_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/trait_goals.rs @@ -342,23 +342,18 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> { let Some(sized_def_id) = tcx.lang_items().sized_trait() else { return Err(NoSolution); }; + // Check that the type implements all of the predicates of the def-id. + // (i.e. the principal, all of the associated types match, and any auto traits) ecx.add_goals( - data.iter() - // Check that the type implements all of the predicates of the def-id. - // (i.e. the principal, all of the associated types match, and any auto traits) - .map(|pred| goal.with(tcx, pred.with_self_ty(tcx, a_ty))) - .chain([ - // The type must be Sized to be unsized. - goal.with( - tcx, - ty::Binder::dummy(tcx.mk_trait_ref(sized_def_id, [a_ty])), - ), - // The type must outlive the lifetime of the `dyn` we're unsizing into. - goal.with( - tcx, - ty::Binder::dummy(ty::OutlivesPredicate(a_ty, region)), - ), - ]), + data.iter().map(|pred| goal.with(tcx, pred.with_self_ty(tcx, a_ty))), + ); + // The type must be Sized to be unsized. + ecx.add_goal( + goal.with(tcx, ty::Binder::dummy(tcx.mk_trait_ref(sized_def_id, [a_ty]))), + ); + // The type must outlive the lifetime of the `dyn` we're unsizing into. + ecx.add_goal( + goal.with(tcx, ty::Binder::dummy(ty::OutlivesPredicate(a_ty, region))), ); ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) } |
