Safe Transmute: Change Answer type to Result

This patch updates the `Answer` type from `rustc_transmute` so that it just a
type alias to `Result`. This makes it so that the standard methods for `Result`
can be used to process the `Answer` tree, including being able to make use of
the `?` operator on `Answer`s.

Also, remove some unused functions
This commit is contained in:
Bryan Garza
2023-04-27 14:38:32 -07:00
parent 8f1cec8d84
commit 263a4f2cb6
6 changed files with 113 additions and 140 deletions

View File

@@ -1,6 +1,6 @@
use super::query_context::test::{Def, UltraMinimal};
use crate::maybe_transmutable::MaybeTransmutableQuery;
use crate::{layout, Answer, Reason};
use crate::{layout, Reason};
use itertools::Itertools;
mod bool {
@@ -17,7 +17,7 @@ mod bool {
UltraMinimal,
)
.answer();
assert_eq!(answer, Answer::Yes);
assert_eq!(answer, Ok(None));
}
#[test]
@@ -30,7 +30,7 @@ mod bool {
UltraMinimal,
)
.answer();
assert_eq!(answer, Answer::Yes);
assert_eq!(answer, Ok(None));
}
#[test]
@@ -65,7 +65,7 @@ mod bool {
if src_set.is_subset(&dst_set) {
assert_eq!(
Answer::Yes,
Ok(None),
MaybeTransmutableQuery::new(
src_layout.clone(),
dst_layout.clone(),
@@ -80,7 +80,7 @@ mod bool {
);
} else if !src_set.is_disjoint(&dst_set) {
assert_eq!(
Answer::Yes,
Ok(None),
MaybeTransmutableQuery::new(
src_layout.clone(),
dst_layout.clone(),
@@ -95,7 +95,7 @@ mod bool {
);
} else {
assert_eq!(
Answer::No(Reason::DstIsBitIncompatible),
Err(Reason::DstIsBitIncompatible),
MaybeTransmutableQuery::new(
src_layout.clone(),
dst_layout.clone(),