diff options
| author | Bryan Garza <1396101+bryangarza@users.noreply.github.com> | 2023-05-24 17:47:13 -0700 |
|---|---|---|
| committer | Bryan Garza <1396101+bryangarza@users.noreply.github.com> | 2023-05-24 17:49:56 -0700 |
| commit | d2164d5c9a17a7c2eefeccf623c278612b2650de (patch) | |
| tree | b1dd74d0baeb833d0da51390c42cd91a8faf702c /compiler/rustc_trait_selection/src/traits/select | |
| parent | 62663582375d7dedf42c0a30bfe04c7b53b452d7 (diff) | |
Safe Transmute: Update definition of Condition type
- Change `Condition` to not contain `Answer`s but instead just contain other `Condition`s directly. - Also improve error reporting for `DstHasStricterAlignment`
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/select')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/confirmation.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 6b8d8a947ea..3f07ad814ff 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -290,25 +290,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { tcx: TyCtxt<'tcx>, obligation: &TraitObligation<'tcx>, predicate: TraitPredicate<'tcx>, - answer: rustc_transmute::Answer<rustc_transmute::layout::rustc::Ref<'tcx>>, - ) -> Result<Vec<PredicateObligation<'tcx>>, SelectionError<'tcx>> { + answer: rustc_transmute::Condition<rustc_transmute::layout::rustc::Ref<'tcx>>, + ) -> Vec<PredicateObligation<'tcx>> { match answer { - Ok(None) => Ok(vec![]), - Err(_) => Err(Unimplemented), // FIXME(bryangarza): Add separate `IfAny` case, instead of treating as `IfAll` // Not possible until the trait solver supports disjunctions of obligations - Ok(Some(rustc_transmute::Condition::IfAll(answers))) - | Ok(Some(rustc_transmute::Condition::IfAny(answers))) => { + rustc_transmute::Condition::IfAll(answers) + | rustc_transmute::Condition::IfAny(answers) => { let mut nested = vec![]; for flattened in answers .into_iter() .map(|answer| flatten_answer_tree(tcx, obligation, predicate, answer)) { - nested.extend(flattened?); + nested.extend(flattened); } - Ok(nested) + nested } - Ok(Some(rustc_transmute::Condition::IfTransmutable { src, dst })) => { + rustc_transmute::Condition::IfTransmutable { src, dst } => { let trait_def_id = obligation.predicate.def_id(); let scope = predicate.trait_ref.substs.type_at(2); let assume_const = predicate.trait_ref.substs.const_at(3); @@ -339,7 +337,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { if dst.mutability == Mutability::Mut { obligations.push(make_obl(dst.ty, src.ty)); } - Ok(obligations) + obligations } } } @@ -371,8 +369,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { assume, ); - let fully_flattened = - flatten_answer_tree(self.tcx(), obligation, predicate, maybe_transmutable)?; + let fully_flattened = match maybe_transmutable { + Err(_) => Err(Unimplemented)?, + Ok(Some(mt)) => flatten_answer_tree(self.tcx(), obligation, predicate, mt), + Ok(None) => vec![], + }; + debug!(?fully_flattened); Ok(ImplSourceBuiltinData { nested: fully_flattened }) } |
