summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_transmute/src/maybe_transmutable/mod.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /compiler/rustc_transmute/src/maybe_transmutable/mod.rs
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_transmute/src/maybe_transmutable/mod.rs')
-rw-r--r--compiler/rustc_transmute/src/maybe_transmutable/mod.rs27
1 files changed, 14 insertions, 13 deletions
diff --git a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs
index 1186eac37..2e2fb90e7 100644
--- a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs
+++ b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs
@@ -56,7 +56,7 @@ where
#[cfg(feature = "rustc")]
mod rustc {
use super::*;
- use crate::layout::tree::Err;
+ use crate::layout::tree::rustc::Err;
use rustc_middle::ty::Ty;
use rustc_middle::ty::TyCtxt;
@@ -71,19 +71,20 @@ mod rustc {
// representations. If these conversions fail, conclude that the transmutation is
// unacceptable; the layouts of both the source and destination types must be
// well-defined.
- let src = Tree::from_ty(src, context).map_err(|err| match err {
- // Answer `Yes` here, because "Unknown Type" will already be reported by
- // rustc. No need to spam the user with more errors.
- Err::Unknown => Answer::Yes,
- Err::Unspecified => Answer::No(Reason::SrcIsUnspecified),
- })?;
+ let src = Tree::from_ty(src, context);
+ let dst = Tree::from_ty(dst, context);
- let dst = Tree::from_ty(dst, context).map_err(|err| match err {
- Err::Unknown => Answer::Yes,
- Err::Unspecified => Answer::No(Reason::DstIsUnspecified),
- })?;
-
- Ok((src, dst))
+ match (src, dst) {
+ // Answer `Yes` here, because 'unknown layout' and type errors will already
+ // be reported by rustc. No need to spam the user with more errors.
+ (Err(Err::TypeError(_)), _) => Err(Answer::Yes),
+ (_, Err(Err::TypeError(_))) => Err(Answer::Yes),
+ (Err(Err::Unknown), _) => Err(Answer::Yes),
+ (_, Err(Err::Unknown)) => Err(Answer::Yes),
+ (Err(Err::Unspecified), _) => Err(Answer::No(Reason::SrcIsUnspecified)),
+ (_, Err(Err::Unspecified)) => Err(Answer::No(Reason::DstIsUnspecified)),
+ (Ok(src), Ok(dst)) => Ok((src, dst)),
+ }
});
match query_or_answer {