Safe Transmute: Refactor error handling and Answer type
- Create `Answer` type that is not just a type alias of `Result` - Remove a usage of `map_layouts` to make the code easier to read - Don't hide errors related to Unknown Layout when computing transmutability
This commit is contained in:
@@ -668,6 +668,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||
scope: Ty<'tcx>,
|
||||
assume: rustc_transmute::Assume,
|
||||
) -> Result<Certainty, NoSolution> {
|
||||
use rustc_transmute::Answer;
|
||||
// FIXME(transmutability): This really should be returning nested goals for `Answer::If*`
|
||||
match rustc_transmute::TransmuteTypeEnv::new(self.infcx).is_transmutable(
|
||||
ObligationCause::dummy(),
|
||||
@@ -675,11 +676,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||
scope,
|
||||
assume,
|
||||
) {
|
||||
Ok(None) => Ok(Certainty::Yes),
|
||||
Err(_)
|
||||
| Ok(Some(rustc_transmute::Condition::IfTransmutable { .. }))
|
||||
| Ok(Some(rustc_transmute::Condition::IfAll(_)))
|
||||
| Ok(Some(rustc_transmute::Condition::IfAny(_))) => Err(NoSolution),
|
||||
Answer::Yes => Ok(Certainty::Yes),
|
||||
Answer::No(_) | Answer::If(_) => Err(NoSolution),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user