about summary refs log tree commit diff
path: root/compiler/rustc_transmute/src/lib.rs
diff options
context:
space:
mode:
authorBryan Garza <1396101+bryangarza@users.noreply.github.com>2023-04-27 14:38:32 -0700
committerBryan Garza <1396101+bryangarza@users.noreply.github.com>2023-05-24 14:52:19 -0700
commit263a4f2cb6b455f9c4ae46493d59369c378a85ea (patch)
tree5b928687e50f2cfa00f7555552590a3610539b8e /compiler/rustc_transmute/src/lib.rs
parent8f1cec8d8472c3ffacedd4783c64182a407c72df (diff)
downloadrust-263a4f2cb6b455f9c4ae46493d59369c378a85ea.tar.gz
rust-263a4f2cb6b455f9c4ae46493d59369c378a85ea.zip
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
Diffstat (limited to 'compiler/rustc_transmute/src/lib.rs')
-rw-r--r--compiler/rustc_transmute/src/lib.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs
index c4a99d9eb89..baf63e6d3a2 100644
--- a/compiler/rustc_transmute/src/lib.rs
+++ b/compiler/rustc_transmute/src/lib.rs
@@ -19,15 +19,12 @@ pub struct Assume {
     pub validity: bool,
 }
 
-/// The type encodes answers to the question: "Are these types transmutable?"
-#[derive(Debug, Hash, Eq, PartialEq, PartialOrd, Ord, Clone)]
-pub enum Answer<R> {
-    /// `Src` is transmutable into `Dst`.
-    Yes,
-
-    /// `Src` is NOT transmutable into `Dst`.
-    No(Reason),
+/// Either we have an error, or we have an optional Condition that must hold.
+pub type Answer<R> = Result<Option<Condition<R>>, Reason>;
 
+/// A condition which must hold for safe transmutation to be possible
+#[derive(Debug, Hash, Eq, PartialEq, Clone)]
+pub enum Condition<R> {
     /// `Src` is transmutable into `Dst`, if `src` is transmutable into `dst`.
     IfTransmutable { src: R, dst: R },