about summary refs log tree commit diff
path: root/compiler/rustc_transmute/src/maybe_transmutable/tests.rs
diff options
context:
space:
mode:
authorBryan Garza <1396101+bryangarza@users.noreply.github.com>2023-06-12 16:35:23 -0700
committerBryan Garza <1396101+bryangarza@users.noreply.github.com>2023-06-12 16:56:21 -0700
commitf4cf8f65a5e8e110c8c36469d31f16e8571e2c1a (patch)
tree81d55477f266bac64272420ca537903b35a17fb8 /compiler/rustc_transmute/src/maybe_transmutable/tests.rs
parent64a54df86faf1f55148433753296dc2bc2a7e31d (diff)
downloadrust-f4cf8f65a5e8e110c8c36469d31f16e8571e2c1a.tar.gz
rust-f4cf8f65a5e8e110c8c36469d31f16e8571e2c1a.zip
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
Diffstat (limited to 'compiler/rustc_transmute/src/maybe_transmutable/tests.rs')
-rw-r--r--compiler/rustc_transmute/src/maybe_transmutable/tests.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs
index df6a83df23f..e49bebf571d 100644
--- a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs
+++ b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs
@@ -4,6 +4,8 @@ use crate::{layout, Reason};
 use itertools::Itertools;
 
 mod bool {
+    use crate::Answer;
+
     use super::*;
 
     #[test]
@@ -17,7 +19,7 @@ mod bool {
             UltraMinimal,
         )
         .answer();
-        assert_eq!(answer, Ok(None));
+        assert_eq!(answer, Answer::Yes);
     }
 
     #[test]
@@ -30,7 +32,7 @@ mod bool {
             UltraMinimal,
         )
         .answer();
-        assert_eq!(answer, Ok(None));
+        assert_eq!(answer, Answer::Yes);
     }
 
     #[test]
@@ -65,7 +67,7 @@ mod bool {
 
                 if src_set.is_subset(&dst_set) {
                     assert_eq!(
-                        Ok(None),
+                        Answer::Yes,
                         MaybeTransmutableQuery::new(
                             src_layout.clone(),
                             dst_layout.clone(),
@@ -80,7 +82,7 @@ mod bool {
                     );
                 } else if !src_set.is_disjoint(&dst_set) {
                     assert_eq!(
-                        Ok(None),
+                        Answer::Yes,
                         MaybeTransmutableQuery::new(
                             src_layout.clone(),
                             dst_layout.clone(),
@@ -95,7 +97,7 @@ mod bool {
                     );
                 } else {
                     assert_eq!(
-                        Err(Reason::DstIsBitIncompatible),
+                        Answer::No(Reason::DstIsBitIncompatible),
                         MaybeTransmutableQuery::new(
                             src_layout.clone(),
                             dst_layout.clone(),