Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c6223e1

Browse files
authoredApr 14, 2023
Rollup merge of #109800 - bryangarza:safe-transmute-improved-errors, r=compiler-errors
Improve safe transmute error reporting This patch updates the error reporting when Safe Transmute is not possible between 2 types by including the reason. Also, fix some small bugs that occur when computing the `Answer` for transmutability.
2 parents ec08676 + 36febe1 commit c6223e1

29 files changed

+495
-593
lines changed
 

‎compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

Lines changed: 104 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
673673
return;
674674
}
675675
let trait_ref = trait_predicate.to_poly_trait_ref();
676+
676677
let (post_message, pre_message, type_def) = self
677678
.get_parent_trait_ref(obligation.cause.code())
678679
.map(|(t, s)| {
@@ -712,33 +713,45 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
712713
(message, note, append_const_msg)
713714
};
714715

715-
let mut err = struct_span_err!(
716-
self.tcx.sess,
717-
span,
718-
E0277,
719-
"{}",
720-
message
721-
.and_then(|cannot_do_this| {
722-
match (predicate_is_const, append_const_msg) {
723-
// do nothing if predicate is not const
724-
(false, _) => Some(cannot_do_this),
725-
// suggested using default post message
726-
(true, Some(None)) => {
727-
Some(format!("{cannot_do_this} in const contexts"))
728-
}
729-
// overridden post message
730-
(true, Some(Some(post_message))) => {
731-
Some(format!("{cannot_do_this}{post_message}"))
732-
}
733-
// fallback to generic message
734-
(true, None) => None,
716+
let err_msg = message
717+
.and_then(|cannot_do_this| {
718+
match (predicate_is_const, append_const_msg) {
719+
// do nothing if predicate is not const
720+
(false, _) => Some(cannot_do_this),
721+
// suggested using default post message
722+
(true, Some(None)) => {
723+
Some(format!("{cannot_do_this} in const contexts"))
724+
}
725+
// overridden post message
726+
(true, Some(Some(post_message))) => {
727+
Some(format!("{cannot_do_this}{post_message}"))
735728
}
736-
})
737-
.unwrap_or_else(|| format!(
729+
// fallback to generic message
730+
(true, None) => None,
731+
}
732+
})
733+
.unwrap_or_else(|| {
734+
format!(
738735
"the trait bound `{}` is not satisfied{}",
739736
trait_predicate, post_message,
740-
))
741-
);
737+
)
738+
});
739+
740+
let (err_msg, safe_transmute_explanation) = if Some(trait_ref.def_id())
741+
== self.tcx.lang_items().transmute_trait()
742+
{
743+
// Recompute the safe transmute reason and use that for the error reporting
744+
self.get_safe_transmute_error_and_reason(
745+
trait_predicate,
746+
obligation.clone(),
747+
trait_ref,
748+
span,
749+
)
750+
} else {
751+
(err_msg, None)
752+
};
753+
754+
let mut err = struct_span_err!(self.tcx.sess, span, E0277, "{}", err_msg);
742755

743756
if is_try_conversion && let Some(ret_span) = self.return_type_span(&obligation) {
744757
err.span_label(
@@ -828,6 +841,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
828841
// at the type param with a label to suggest constraining it.
829842
err.help(&explanation);
830843
}
844+
} else if let Some(custom_explanation) = safe_transmute_explanation {
845+
err.span_label(span, custom_explanation);
831846
} else {
832847
err.span_label(span, explanation);
833848
}
@@ -1611,6 +1626,14 @@ trait InferCtxtPrivExt<'tcx> {
16111626
obligated_types: &mut Vec<Ty<'tcx>>,
16121627
cause_code: &ObligationCauseCode<'tcx>,
16131628
) -> bool;
1629+
1630+
fn get_safe_transmute_error_and_reason(
1631+
&self,
1632+
trait_predicate: ty::Binder<'tcx, ty::TraitPredicate<'tcx>>,
1633+
obligation: Obligation<'tcx, ty::Predicate<'tcx>>,
1634+
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
1635+
span: Span,
1636+
) -> (String, Option<String>);
16141637
}
16151638

16161639
impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
@@ -2895,6 +2918,63 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
28952918
}
28962919
false
28972920
}
2921+
2922+
fn get_safe_transmute_error_and_reason(
2923+
&self,
2924+
trait_predicate: ty::Binder<'tcx, ty::TraitPredicate<'tcx>>,
2925+
obligation: Obligation<'tcx, ty::Predicate<'tcx>>,
2926+
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
2927+
span: Span,
2928+
) -> (String, Option<String>) {
2929+
let src_and_dst = trait_predicate.map_bound(|p| rustc_transmute::Types {
2930+
dst: p.trait_ref.substs.type_at(0),
2931+
src: p.trait_ref.substs.type_at(1),
2932+
});
2933+
let scope = trait_ref.skip_binder().substs.type_at(2);
2934+
let Some(assume) =
2935+
rustc_transmute::Assume::from_const(self.infcx.tcx, obligation.param_env, trait_ref.skip_binder().substs.const_at(3)) else {
2936+
span_bug!(span, "Unable to construct rustc_transmute::Assume where it was previously possible");
2937+
};
2938+
match rustc_transmute::TransmuteTypeEnv::new(self.infcx).is_transmutable(
2939+
obligation.cause,
2940+
src_and_dst,
2941+
scope,
2942+
assume,
2943+
) {
2944+
rustc_transmute::Answer::No(reason) => {
2945+
let dst = trait_ref.skip_binder().substs.type_at(0);
2946+
let src = trait_ref.skip_binder().substs.type_at(1);
2947+
let custom_err_msg = format!("`{src}` cannot be safely transmuted into `{dst}` in the defining scope of `{scope}`").to_string();
2948+
let reason_msg = match reason {
2949+
rustc_transmute::Reason::SrcIsUnspecified => {
2950+
format!("`{src}` does not have a well-specified layout").to_string()
2951+
}
2952+
rustc_transmute::Reason::DstIsUnspecified => {
2953+
format!("`{dst}` does not have a well-specified layout").to_string()
2954+
}
2955+
rustc_transmute::Reason::DstIsBitIncompatible => {
2956+
format!("At least one value of `{src}` isn't a bit-valid value of `{dst}`")
2957+
.to_string()
2958+
}
2959+
rustc_transmute::Reason::DstIsPrivate => format!(
2960+
"`{dst}` is or contains a type or field that is not visible in that scope"
2961+
)
2962+
.to_string(),
2963+
// FIXME(bryangarza): Include the number of bytes of src and dst
2964+
rustc_transmute::Reason::DstIsTooBig => {
2965+
format!("The size of `{src}` is smaller than the size of `{dst}`")
2966+
}
2967+
};
2968+
(custom_err_msg, Some(reason_msg))
2969+
}
2970+
// Should never get a Yes at this point! We already ran it before, and did not get a Yes.
2971+
rustc_transmute::Answer::Yes => span_bug!(
2972+
span,
2973+
"Inconsistent rustc_transmute::is_transmutable(...) result, got Yes",
2974+
),
2975+
_ => span_bug!(span, "Unsupported rustc_transmute::Reason variant"),
2976+
}
2977+
}
28982978
}
28992979

29002980
/// Crude way of getting back an `Expr` from a `Span`.

‎compiler/rustc_transmute/src/layout/tree.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,31 +167,31 @@ where
167167
}
168168
}
169169

170-
#[derive(Debug, Copy, Clone)]
171-
pub(crate) enum Err {
172-
/// The layout of the type is unspecified.
173-
Unspecified,
174-
/// This error will be surfaced elsewhere by rustc, so don't surface it.
175-
Unknown,
176-
}
177-
178170
#[cfg(feature = "rustc")]
179171
pub(crate) mod rustc {
180-
use super::{Err, Tree};
172+
use super::Tree;
181173
use crate::layout::rustc::{Def, Ref};
182174

183-
use rustc_middle::ty;
184175
use rustc_middle::ty::layout::LayoutError;
185176
use rustc_middle::ty::util::Discr;
186177
use rustc_middle::ty::AdtDef;
187178
use rustc_middle::ty::ParamEnv;
188179
use rustc_middle::ty::SubstsRef;
189-
use rustc_middle::ty::Ty;
190-
use rustc_middle::ty::TyCtxt;
191180
use rustc_middle::ty::VariantDef;
181+
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
182+
use rustc_span::ErrorGuaranteed;
192183
use rustc_target::abi::Align;
193184
use std::alloc;
194185

186+
#[derive(Debug, Copy, Clone)]
187+
pub(crate) enum Err {
188+
/// The layout of the type is unspecified.
189+
Unspecified,
190+
/// This error will be surfaced elsewhere by rustc, so don't surface it.
191+
Unknown,
192+
TypeError(ErrorGuaranteed),
193+
}
194+
195195
impl<'tcx> From<LayoutError<'tcx>> for Err {
196196
fn from(err: LayoutError<'tcx>) -> Self {
197197
match err {
@@ -261,6 +261,10 @@ pub(crate) mod rustc {
261261
use rustc_middle::ty::UintTy::*;
262262
use rustc_target::abi::HasDataLayout;
263263

264+
if let Err(e) = ty.error_reported() {
265+
return Err(Err::TypeError(e));
266+
}
267+
264268
let target = tcx.data_layout();
265269

266270
match ty.kind() {

‎compiler/rustc_transmute/src/maybe_transmutable/mod.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ where
5656
#[cfg(feature = "rustc")]
5757
mod rustc {
5858
use super::*;
59-
use crate::layout::tree::Err;
59+
use crate::layout::tree::rustc::Err;
6060

6161
use rustc_middle::ty::Ty;
6262
use rustc_middle::ty::TyCtxt;
@@ -71,19 +71,20 @@ mod rustc {
7171
// representations. If these conversions fail, conclude that the transmutation is
7272
// unacceptable; the layouts of both the source and destination types must be
7373
// well-defined.
74-
let src = Tree::from_ty(src, context).map_err(|err| match err {
75-
// Answer `Yes` here, because "Unknown Type" will already be reported by
76-
// rustc. No need to spam the user with more errors.
77-
Err::Unknown => Answer::Yes,
78-
Err::Unspecified => Answer::No(Reason::SrcIsUnspecified),
79-
})?;
74+
let src = Tree::from_ty(src, context);
75+
let dst = Tree::from_ty(dst, context);
8076

81-
let dst = Tree::from_ty(dst, context).map_err(|err| match err {
82-
Err::Unknown => Answer::Yes,
83-
Err::Unspecified => Answer::No(Reason::DstIsUnspecified),
84-
})?;
85-
86-
Ok((src, dst))
77+
match (src, dst) {
78+
// Answer `Yes` here, because 'unknown layout' and type errors will already
79+
// be reported by rustc. No need to spam the user with more errors.
80+
(Err(Err::TypeError(_)), _) => Err(Answer::Yes),
81+
(_, Err(Err::TypeError(_))) => Err(Answer::Yes),
82+
(Err(Err::Unknown), _) => Err(Answer::Yes),
83+
(_, Err(Err::Unknown)) => Err(Answer::Yes),
84+
(Err(Err::Unspecified), _) => Err(Answer::No(Reason::SrcIsUnspecified)),
85+
(_, Err(Err::Unspecified)) => Err(Answer::No(Reason::DstIsUnspecified)),
86+
(Ok(src), Ok(dst)) => Ok((src, dst)),
87+
}
8788
});
8889

8990
match query_or_answer {

‎compiler/rustc_transmute/src/maybe_transmutable/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::query_context::test::{Def, UltraMinimal};
22
use crate::maybe_transmutable::MaybeTransmutableQuery;
3-
use crate::{layout, Answer, Reason, Set};
3+
use crate::{layout, Answer, Reason};
44
use itertools::Itertools;
55

66
mod bool {
@@ -48,9 +48,9 @@ mod bool {
4848

4949
let into_set = |alts: Vec<_>| {
5050
#[cfg(feature = "rustc")]
51-
let mut set = Set::default();
51+
let mut set = crate::Set::default();
5252
#[cfg(not(feature = "rustc"))]
53-
let mut set = Set::new();
53+
let mut set = std::collections::HashSet::new();
5454
set.extend(alts);
5555
set
5656
};

‎library/core/src/mem/transmutability.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
/// notwithstanding whatever safety checks you have asked the compiler to [`Assume`] are satisfied.
66
#[unstable(feature = "transmutability", issue = "99571")]
77
#[lang = "transmute_trait"]
8-
#[rustc_on_unimplemented(
9-
message = "`{Src}` cannot be safely transmuted into `{Self}` in the defining scope of `{Context}`.",
10-
label = "`{Src}` cannot be safely transmuted into `{Self}` in the defining scope of `{Context}`."
11-
)]
128
pub unsafe trait BikeshedIntrinsicFrom<Src, Context, const ASSUME: Assume = { Assume::NOTHING }>
139
where
1410
Src: ?Sized,

‎tests/ui/transmutability/arrays/should_require_well_defined_layout.stderr

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `[String; 0]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
1+
error[E0277]: `[String; 0]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
22
--> $DIR/should_require_well_defined_layout.rs:26:52
33
|
44
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
5-
| ^^ `[String; 0]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
5+
| ^^ `[String; 0]` does not have a well-specified layout
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<[String; 0], assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
87
note: required by a bound in `is_maybe_transmutable`
98
--> $DIR/should_require_well_defined_layout.rs:13:14
109
|
@@ -20,13 +19,12 @@ LL | | .and(Assume::VALIDITY)
2019
LL | | }>
2120
| |__________^ required by this bound in `is_maybe_transmutable`
2221

23-
error[E0277]: `u128` cannot be safely transmuted into `[String; 0]` in the defining scope of `assert::Context`.
22+
error[E0277]: `u128` cannot be safely transmuted into `[String; 0]` in the defining scope of `assert::Context`
2423
--> $DIR/should_require_well_defined_layout.rs:27:47
2524
|
2625
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
27-
| ^^^^^^^^^ `u128` cannot be safely transmuted into `[String; 0]` in the defining scope of `assert::Context`.
26+
| ^^^^^^^^^ `[String; 0]` does not have a well-specified layout
2827
|
29-
= help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `[String; 0]`
3028
note: required by a bound in `is_maybe_transmutable`
3129
--> $DIR/should_require_well_defined_layout.rs:13:14
3230
|
@@ -42,13 +40,12 @@ LL | | .and(Assume::VALIDITY)
4240
LL | | }>
4341
| |__________^ required by this bound in `is_maybe_transmutable`
4442

45-
error[E0277]: `[String; 1]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
43+
error[E0277]: `[String; 1]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
4644
--> $DIR/should_require_well_defined_layout.rs:32:52
4745
|
4846
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
49-
| ^^ `[String; 1]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
47+
| ^^ `[String; 1]` does not have a well-specified layout
5048
|
51-
= help: the trait `BikeshedIntrinsicFrom<[String; 1], assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
5249
note: required by a bound in `is_maybe_transmutable`
5350
--> $DIR/should_require_well_defined_layout.rs:13:14
5451
|
@@ -64,13 +61,12 @@ LL | | .and(Assume::VALIDITY)
6461
LL | | }>
6562
| |__________^ required by this bound in `is_maybe_transmutable`
6663

67-
error[E0277]: `u128` cannot be safely transmuted into `[String; 1]` in the defining scope of `assert::Context`.
64+
error[E0277]: `u128` cannot be safely transmuted into `[String; 1]` in the defining scope of `assert::Context`
6865
--> $DIR/should_require_well_defined_layout.rs:33:47
6966
|
7067
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
71-
| ^^^^^^^^^ `u128` cannot be safely transmuted into `[String; 1]` in the defining scope of `assert::Context`.
68+
| ^^^^^^^^^ `[String; 1]` does not have a well-specified layout
7269
|
73-
= help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `[String; 1]`
7470
note: required by a bound in `is_maybe_transmutable`
7571
--> $DIR/should_require_well_defined_layout.rs:13:14
7672
|
@@ -86,13 +82,12 @@ LL | | .and(Assume::VALIDITY)
8682
LL | | }>
8783
| |__________^ required by this bound in `is_maybe_transmutable`
8884

89-
error[E0277]: `[String; 2]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
85+
error[E0277]: `[String; 2]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
9086
--> $DIR/should_require_well_defined_layout.rs:38:52
9187
|
9288
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
93-
| ^^ `[String; 2]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
89+
| ^^ `[String; 2]` does not have a well-specified layout
9490
|
95-
= help: the trait `BikeshedIntrinsicFrom<[String; 2], assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
9691
note: required by a bound in `is_maybe_transmutable`
9792
--> $DIR/should_require_well_defined_layout.rs:13:14
9893
|
@@ -108,13 +103,12 @@ LL | | .and(Assume::VALIDITY)
108103
LL | | }>
109104
| |__________^ required by this bound in `is_maybe_transmutable`
110105

111-
error[E0277]: `u128` cannot be safely transmuted into `[String; 2]` in the defining scope of `assert::Context`.
106+
error[E0277]: `u128` cannot be safely transmuted into `[String; 2]` in the defining scope of `assert::Context`
112107
--> $DIR/should_require_well_defined_layout.rs:39:47
113108
|
114109
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
115-
| ^^^^^^^^^ `u128` cannot be safely transmuted into `[String; 2]` in the defining scope of `assert::Context`.
110+
| ^^^^^^^^^ `[String; 2]` does not have a well-specified layout
116111
|
117-
= help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `[String; 2]`
118112
note: required by a bound in `is_maybe_transmutable`
119113
--> $DIR/should_require_well_defined_layout.rs:13:14
120114
|

‎tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr

Lines changed: 40 additions & 60 deletions
Large diffs are not rendered by default.

‎tests/ui/transmutability/enums/repr/should_require_well_defined_layout.stderr

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `void::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
1+
error[E0277]: `void::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
22
--> $DIR/should_require_well_defined_layout.rs:28:52
33
|
44
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
5-
| ^^ `void::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
5+
| ^^ `void::repr_rust` does not have a well-specified layout
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<void::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
87
note: required by a bound in `is_maybe_transmutable`
98
--> $DIR/should_require_well_defined_layout.rs:14:14
109
|
@@ -21,13 +20,12 @@ LL | | }
2120
LL | | }>
2221
| |__________^ required by this bound in `is_maybe_transmutable`
2322

24-
error[E0277]: `u128` cannot be safely transmuted into `void::repr_rust` in the defining scope of `assert::Context`.
23+
error[E0277]: `u128` cannot be safely transmuted into `void::repr_rust` in the defining scope of `assert::Context`
2524
--> $DIR/should_require_well_defined_layout.rs:29:47
2625
|
2726
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
28-
| ^^^^^^^^^ `u128` cannot be safely transmuted into `void::repr_rust` in the defining scope of `assert::Context`.
27+
| ^^^^^^^^^ `void::repr_rust` does not have a well-specified layout
2928
|
30-
= help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `void::repr_rust`
3129
note: required by a bound in `is_maybe_transmutable`
3230
--> $DIR/should_require_well_defined_layout.rs:14:14
3331
|
@@ -44,13 +42,12 @@ LL | | }
4442
LL | | }>
4543
| |__________^ required by this bound in `is_maybe_transmutable`
4644

47-
error[E0277]: `singleton::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
45+
error[E0277]: `singleton::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
4846
--> $DIR/should_require_well_defined_layout.rs:34:52
4947
|
5048
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
51-
| ^^ `singleton::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
49+
| ^^ `singleton::repr_rust` does not have a well-specified layout
5250
|
53-
= help: the trait `BikeshedIntrinsicFrom<singleton::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
5451
note: required by a bound in `is_maybe_transmutable`
5552
--> $DIR/should_require_well_defined_layout.rs:14:14
5653
|
@@ -67,13 +64,12 @@ LL | | }
6764
LL | | }>
6865
| |__________^ required by this bound in `is_maybe_transmutable`
6966

70-
error[E0277]: `u128` cannot be safely transmuted into `singleton::repr_rust` in the defining scope of `assert::Context`.
67+
error[E0277]: `u128` cannot be safely transmuted into `singleton::repr_rust` in the defining scope of `assert::Context`
7168
--> $DIR/should_require_well_defined_layout.rs:35:47
7269
|
7370
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
74-
| ^^^^^^^^^ `u128` cannot be safely transmuted into `singleton::repr_rust` in the defining scope of `assert::Context`.
71+
| ^^^^^^^^^ `singleton::repr_rust` does not have a well-specified layout
7572
|
76-
= help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `singleton::repr_rust`
7773
note: required by a bound in `is_maybe_transmutable`
7874
--> $DIR/should_require_well_defined_layout.rs:14:14
7975
|
@@ -90,13 +86,12 @@ LL | | }
9086
LL | | }>
9187
| |__________^ required by this bound in `is_maybe_transmutable`
9288

93-
error[E0277]: `duplex::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
89+
error[E0277]: `duplex::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
9490
--> $DIR/should_require_well_defined_layout.rs:40:52
9591
|
9692
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
97-
| ^^ `duplex::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
93+
| ^^ `duplex::repr_rust` does not have a well-specified layout
9894
|
99-
= help: the trait `BikeshedIntrinsicFrom<duplex::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
10095
note: required by a bound in `is_maybe_transmutable`
10196
--> $DIR/should_require_well_defined_layout.rs:14:14
10297
|
@@ -113,13 +108,12 @@ LL | | }
113108
LL | | }>
114109
| |__________^ required by this bound in `is_maybe_transmutable`
115110

116-
error[E0277]: `u128` cannot be safely transmuted into `duplex::repr_rust` in the defining scope of `assert::Context`.
111+
error[E0277]: `u128` cannot be safely transmuted into `duplex::repr_rust` in the defining scope of `assert::Context`
117112
--> $DIR/should_require_well_defined_layout.rs:41:47
118113
|
119114
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
120-
| ^^^^^^^^^ `u128` cannot be safely transmuted into `duplex::repr_rust` in the defining scope of `assert::Context`.
115+
| ^^^^^^^^^ `duplex::repr_rust` does not have a well-specified layout
121116
|
122-
= help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `duplex::repr_rust`
123117
note: required by a bound in `is_maybe_transmutable`
124118
--> $DIR/should_require_well_defined_layout.rs:14:14
125119
|

‎tests/ui/transmutability/enums/should_pad_variants.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`.
1+
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`
22
--> $DIR/should_pad_variants.rs:44:36
33
|
44
LL | assert::is_transmutable::<Src, Dst, Context>();
5-
| ^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`.
5+
| ^^^ The size of `Src` is smaller than the size of `Dst`
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<Src, should_pad_variants::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `Dst`
87
note: required by a bound in `is_transmutable`
98
--> $DIR/should_pad_variants.rs:13:14
109
|

‎tests/ui/transmutability/enums/should_respect_endianness.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `Src` cannot be safely transmuted into `Unexpected` in the defining scope of `assert::Context`.
1+
error[E0277]: `Src` cannot be safely transmuted into `Unexpected` in the defining scope of `assert::Context`
22
--> $DIR/should_respect_endianness.rs:36:36
33
|
44
LL | assert::is_transmutable::<Src, Unexpected>();
5-
| ^^^^^^^^^^ `Src` cannot be safely transmuted into `Unexpected` in the defining scope of `assert::Context`.
5+
| ^^^^^^^^^^ At least one value of `Src` isn't a bit-valid value of `Unexpected`
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<Src, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `Unexpected`
87
note: required by a bound in `is_transmutable`
98
--> $DIR/should_respect_endianness.rs:14:14
109
|

‎tests/ui/transmutability/primitives/bool.current.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`.
1+
error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`
22
--> $DIR/bool.rs:24:35
33
|
44
LL | assert::is_transmutable::<u8, bool>();
5-
| ^^^^ `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`.
5+
| ^^^^ At least one value of `u8` isn't a bit-valid value of `bool`
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<u8, assert::Context, Assume { alignment: false, lifetimes: false, safety: true, validity: false }>` is not implemented for `bool`
87
note: required by a bound in `is_transmutable`
98
--> $DIR/bool.rs:14:14
109
|

‎tests/ui/transmutability/primitives/bool.next.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`.
1+
error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`
22
--> $DIR/bool.rs:24:35
33
|
44
LL | assert::is_transmutable::<u8, bool>();
5-
| ^^^^ `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`.
5+
| ^^^^ At least one value of `u8` isn't a bit-valid value of `bool`
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<u8, assert::Context, Assume { alignment: false, lifetimes: false, safety: true, validity: false }>` is not implemented for `bool`
87
note: required by a bound in `is_transmutable`
98
--> $DIR/bool.rs:14:14
109
|

‎tests/ui/transmutability/primitives/numbers.current.stderr

Lines changed: 114 additions & 171 deletions
Large diffs are not rendered by default.

‎tests/ui/transmutability/primitives/numbers.next.stderr

Lines changed: 114 additions & 171 deletions
Large diffs are not rendered by default.

‎tests/ui/transmutability/primitives/unit.current.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context`.
1+
error[E0277]: `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context`
22
--> $DIR/unit.rs:31:35
33
|
44
LL | assert::is_transmutable::<(), u8, Context>();
5-
| ^^ `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context`.
5+
| ^^ The size of `()` is smaller than the size of `u8`
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<(), should_have_correct_size::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `u8`
87
note: required by a bound in `is_transmutable`
98
--> $DIR/unit.rs:15:14
109
|

‎tests/ui/transmutability/primitives/unit.next.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context`.
1+
error[E0277]: `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context`
22
--> $DIR/unit.rs:31:35
33
|
44
LL | assert::is_transmutable::<(), u8, Context>();
5-
| ^^ `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context`.
5+
| ^^ The size of `()` is smaller than the size of `u8`
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<(), should_have_correct_size::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `u8`
87
note: required by a bound in `is_transmutable`
98
--> $DIR/unit.rs:15:14
109
|

‎tests/ui/transmutability/references.current.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`.
1+
error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`
22
--> $DIR/references.rs:29:52
33
|
44
LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>();
5-
| ^^^^^^^^^^^^^ `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`.
5+
| ^^^^^^^^^^^^^ `&'static Unit` does not have a well-specified layout
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<&'static Unit, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `&'static Unit`
87
note: required by a bound in `is_maybe_transmutable`
98
--> $DIR/references.rs:16:14
109
|

‎tests/ui/transmutability/references.next.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`.
1+
error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`
22
--> $DIR/references.rs:29:52
33
|
44
LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>();
5-
| ^^^^^^^^^^^^^ `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`.
5+
| ^^^^^^^^^^^^^ `&'static Unit` does not have a well-specified layout
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<&'static Unit, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `&'static Unit`
87
note: required by a bound in `is_maybe_transmutable`
98
--> $DIR/references.rs:16:14
109
|

‎tests/ui/transmutability/structs/repr/should_require_well_defined_layout.stderr

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `should_reject_repr_rust::unit::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
1+
error[E0277]: `should_reject_repr_rust::unit::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
22
--> $DIR/should_require_well_defined_layout.rs:28:52
33
|
44
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
5-
| ^^ `should_reject_repr_rust::unit::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
5+
| ^^ `should_reject_repr_rust::unit::repr_rust` does not have a well-specified layout
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<should_reject_repr_rust::unit::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
87
note: required by a bound in `is_maybe_transmutable`
98
--> $DIR/should_require_well_defined_layout.rs:13:14
109
|
@@ -21,13 +20,12 @@ LL | | }
2120
LL | | }>
2221
| |__________^ required by this bound in `is_maybe_transmutable`
2322

24-
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::unit::repr_rust` in the defining scope of `assert::Context`.
23+
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::unit::repr_rust` in the defining scope of `assert::Context`
2524
--> $DIR/should_require_well_defined_layout.rs:29:47
2625
|
2726
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
28-
| ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::unit::repr_rust` in the defining scope of `assert::Context`.
27+
| ^^^^^^^^^ `should_reject_repr_rust::unit::repr_rust` does not have a well-specified layout
2928
|
30-
= help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `should_reject_repr_rust::unit::repr_rust`
3129
note: required by a bound in `is_maybe_transmutable`
3230
--> $DIR/should_require_well_defined_layout.rs:13:14
3331
|
@@ -44,13 +42,12 @@ LL | | }
4442
LL | | }>
4543
| |__________^ required by this bound in `is_maybe_transmutable`
4644

47-
error[E0277]: `should_reject_repr_rust::tuple::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
45+
error[E0277]: `should_reject_repr_rust::tuple::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
4846
--> $DIR/should_require_well_defined_layout.rs:34:52
4947
|
5048
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
51-
| ^^ `should_reject_repr_rust::tuple::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
49+
| ^^ `should_reject_repr_rust::tuple::repr_rust` does not have a well-specified layout
5250
|
53-
= help: the trait `BikeshedIntrinsicFrom<should_reject_repr_rust::tuple::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
5451
note: required by a bound in `is_maybe_transmutable`
5552
--> $DIR/should_require_well_defined_layout.rs:13:14
5653
|
@@ -67,13 +64,12 @@ LL | | }
6764
LL | | }>
6865
| |__________^ required by this bound in `is_maybe_transmutable`
6966

70-
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::tuple::repr_rust` in the defining scope of `assert::Context`.
67+
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::tuple::repr_rust` in the defining scope of `assert::Context`
7168
--> $DIR/should_require_well_defined_layout.rs:35:47
7269
|
7370
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
74-
| ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::tuple::repr_rust` in the defining scope of `assert::Context`.
71+
| ^^^^^^^^^ `should_reject_repr_rust::tuple::repr_rust` does not have a well-specified layout
7572
|
76-
= help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `should_reject_repr_rust::tuple::repr_rust`
7773
note: required by a bound in `is_maybe_transmutable`
7874
--> $DIR/should_require_well_defined_layout.rs:13:14
7975
|
@@ -90,13 +86,12 @@ LL | | }
9086
LL | | }>
9187
| |__________^ required by this bound in `is_maybe_transmutable`
9288

93-
error[E0277]: `should_reject_repr_rust::braces::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
89+
error[E0277]: `should_reject_repr_rust::braces::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
9490
--> $DIR/should_require_well_defined_layout.rs:40:52
9591
|
9692
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
97-
| ^^ `should_reject_repr_rust::braces::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
93+
| ^^ `should_reject_repr_rust::braces::repr_rust` does not have a well-specified layout
9894
|
99-
= help: the trait `BikeshedIntrinsicFrom<should_reject_repr_rust::braces::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
10095
note: required by a bound in `is_maybe_transmutable`
10196
--> $DIR/should_require_well_defined_layout.rs:13:14
10297
|
@@ -113,13 +108,12 @@ LL | | }
113108
LL | | }>
114109
| |__________^ required by this bound in `is_maybe_transmutable`
115110

116-
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::braces::repr_rust` in the defining scope of `assert::Context`.
111+
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::braces::repr_rust` in the defining scope of `assert::Context`
117112
--> $DIR/should_require_well_defined_layout.rs:41:47
118113
|
119114
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
120-
| ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::braces::repr_rust` in the defining scope of `assert::Context`.
115+
| ^^^^^^^^^ `should_reject_repr_rust::braces::repr_rust` does not have a well-specified layout
121116
|
122-
= help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `should_reject_repr_rust::braces::repr_rust`
123117
note: required by a bound in `is_maybe_transmutable`
124118
--> $DIR/should_require_well_defined_layout.rs:13:14
125119
|
@@ -136,13 +130,12 @@ LL | | }
136130
LL | | }>
137131
| |__________^ required by this bound in `is_maybe_transmutable`
138132

139-
error[E0277]: `aligned::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
133+
error[E0277]: `aligned::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
140134
--> $DIR/should_require_well_defined_layout.rs:46:52
141135
|
142136
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
143-
| ^^ `aligned::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
137+
| ^^ `aligned::repr_rust` does not have a well-specified layout
144138
|
145-
= help: the trait `BikeshedIntrinsicFrom<aligned::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
146139
note: required by a bound in `is_maybe_transmutable`
147140
--> $DIR/should_require_well_defined_layout.rs:13:14
148141
|
@@ -159,13 +152,12 @@ LL | | }
159152
LL | | }>
160153
| |__________^ required by this bound in `is_maybe_transmutable`
161154

162-
error[E0277]: `u128` cannot be safely transmuted into `aligned::repr_rust` in the defining scope of `assert::Context`.
155+
error[E0277]: `u128` cannot be safely transmuted into `aligned::repr_rust` in the defining scope of `assert::Context`
163156
--> $DIR/should_require_well_defined_layout.rs:47:47
164157
|
165158
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
166-
| ^^^^^^^^^ `u128` cannot be safely transmuted into `aligned::repr_rust` in the defining scope of `assert::Context`.
159+
| ^^^^^^^^^ `aligned::repr_rust` does not have a well-specified layout
167160
|
168-
= help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `aligned::repr_rust`
169161
note: required by a bound in `is_maybe_transmutable`
170162
--> $DIR/should_require_well_defined_layout.rs:13:14
171163
|
@@ -182,13 +174,12 @@ LL | | }
182174
LL | | }>
183175
| |__________^ required by this bound in `is_maybe_transmutable`
184176

185-
error[E0277]: `packed::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
177+
error[E0277]: `packed::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
186178
--> $DIR/should_require_well_defined_layout.rs:52:52
187179
|
188180
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
189-
| ^^ `packed::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
181+
| ^^ `packed::repr_rust` does not have a well-specified layout
190182
|
191-
= help: the trait `BikeshedIntrinsicFrom<packed::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
192183
note: required by a bound in `is_maybe_transmutable`
193184
--> $DIR/should_require_well_defined_layout.rs:13:14
194185
|
@@ -205,13 +196,12 @@ LL | | }
205196
LL | | }>
206197
| |__________^ required by this bound in `is_maybe_transmutable`
207198

208-
error[E0277]: `u128` cannot be safely transmuted into `packed::repr_rust` in the defining scope of `assert::Context`.
199+
error[E0277]: `u128` cannot be safely transmuted into `packed::repr_rust` in the defining scope of `assert::Context`
209200
--> $DIR/should_require_well_defined_layout.rs:53:47
210201
|
211202
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
212-
| ^^^^^^^^^ `u128` cannot be safely transmuted into `packed::repr_rust` in the defining scope of `assert::Context`.
203+
| ^^^^^^^^^ `packed::repr_rust` does not have a well-specified layout
213204
|
214-
= help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `packed::repr_rust`
215205
note: required by a bound in `is_maybe_transmutable`
216206
--> $DIR/should_require_well_defined_layout.rs:13:14
217207
|
@@ -228,13 +218,12 @@ LL | | }
228218
LL | | }>
229219
| |__________^ required by this bound in `is_maybe_transmutable`
230220

231-
error[E0277]: `nested::repr_c` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
221+
error[E0277]: `nested::repr_c` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
232222
--> $DIR/should_require_well_defined_layout.rs:59:49
233223
|
234224
LL | assert::is_maybe_transmutable::<repr_c, ()>();
235-
| ^^ `nested::repr_c` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
225+
| ^^ `nested::repr_c` does not have a well-specified layout
236226
|
237-
= help: the trait `BikeshedIntrinsicFrom<nested::repr_c, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
238227
note: required by a bound in `is_maybe_transmutable`
239228
--> $DIR/should_require_well_defined_layout.rs:13:14
240229
|
@@ -251,13 +240,12 @@ LL | | }
251240
LL | | }>
252241
| |__________^ required by this bound in `is_maybe_transmutable`
253242

254-
error[E0277]: `u128` cannot be safely transmuted into `nested::repr_c` in the defining scope of `assert::Context`.
243+
error[E0277]: `u128` cannot be safely transmuted into `nested::repr_c` in the defining scope of `assert::Context`
255244
--> $DIR/should_require_well_defined_layout.rs:60:47
256245
|
257246
LL | assert::is_maybe_transmutable::<u128, repr_c>();
258-
| ^^^^^^ `u128` cannot be safely transmuted into `nested::repr_c` in the defining scope of `assert::Context`.
247+
| ^^^^^^ `nested::repr_c` does not have a well-specified layout
259248
|
260-
= help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `nested::repr_c`
261249
note: required by a bound in `is_maybe_transmutable`
262250
--> $DIR/should_require_well_defined_layout.rs:13:14
263251
|

‎tests/ui/transmutability/unions/repr/should_require_well_defined_layout.stderr

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `should_reject_repr_rust::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
1+
error[E0277]: `should_reject_repr_rust::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
22
--> $DIR/should_require_well_defined_layout.rs:30:48
33
|
44
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
5-
| ^^ `should_reject_repr_rust::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
5+
| ^^ `should_reject_repr_rust::repr_rust` does not have a well-specified layout
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<should_reject_repr_rust::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
87
note: required by a bound in `is_maybe_transmutable`
98
--> $DIR/should_require_well_defined_layout.rs:13:14
109
|
@@ -21,13 +20,12 @@ LL | | }
2120
LL | | }>
2221
| |__________^ required by this bound in `is_maybe_transmutable`
2322

24-
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::repr_rust` in the defining scope of `assert::Context`.
23+
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::repr_rust` in the defining scope of `assert::Context`
2524
--> $DIR/should_require_well_defined_layout.rs:31:43
2625
|
2726
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
28-
| ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::repr_rust` in the defining scope of `assert::Context`.
27+
| ^^^^^^^^^ `should_reject_repr_rust::repr_rust` does not have a well-specified layout
2928
|
30-
= help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `should_reject_repr_rust::repr_rust`
3129
note: required by a bound in `is_maybe_transmutable`
3230
--> $DIR/should_require_well_defined_layout.rs:13:14
3331
|

‎tests/ui/transmutability/unions/should_pad_variants.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`.
1+
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`
22
--> $DIR/should_pad_variants.rs:44:36
33
|
44
LL | assert::is_transmutable::<Src, Dst, Context>();
5-
| ^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`.
5+
| ^^^ The size of `Src` is smaller than the size of `Dst`
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<Src, should_pad_variants::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `Dst`
87
note: required by a bound in `is_transmutable`
98
--> $DIR/should_pad_variants.rs:13:14
109
|

‎tests/ui/transmutability/unions/should_reject_contraction.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `Superset` cannot be safely transmuted into `Subset` in the defining scope of `assert::Context`.
1+
error[E0277]: `Superset` cannot be safely transmuted into `Subset` in the defining scope of `assert::Context`
22
--> $DIR/should_reject_contraction.rs:35:41
33
|
44
LL | assert::is_transmutable::<Superset, Subset>();
5-
| ^^^^^^ `Superset` cannot be safely transmuted into `Subset` in the defining scope of `assert::Context`.
5+
| ^^^^^^ At least one value of `Superset` isn't a bit-valid value of `Subset`
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<Superset, assert::Context, Assume { alignment: false, lifetimes: false, safety: true, validity: false }>` is not implemented for `Subset`
87
note: required by a bound in `is_transmutable`
98
--> $DIR/should_reject_contraction.rs:13:14
109
|

‎tests/ui/transmutability/unions/should_reject_disjoint.stderr

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context`.
1+
error[E0277]: `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context`
22
--> $DIR/should_reject_disjoint.rs:33:40
33
|
44
LL | assert::is_maybe_transmutable::<A, B>();
5-
| ^ `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context`.
5+
| ^ At least one value of `A` isn't a bit-valid value of `B`
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<A, assert::Context, Assume { alignment: false, lifetimes: false, safety: true, validity: true }>` is not implemented for `B`
87
note: required by a bound in `is_maybe_transmutable`
98
--> $DIR/should_reject_disjoint.rs:13:14
109
|
@@ -14,13 +13,12 @@ LL | where
1413
LL | Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY.and(Assume::VALIDITY) }>
1514
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable`
1615

17-
error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`.
16+
error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`
1817
--> $DIR/should_reject_disjoint.rs:34:40
1918
|
2019
LL | assert::is_maybe_transmutable::<B, A>();
21-
| ^ `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`.
20+
| ^ At least one value of `B` isn't a bit-valid value of `A`
2221
|
23-
= help: the trait `BikeshedIntrinsicFrom<B, assert::Context, Assume { alignment: false, lifetimes: false, safety: true, validity: true }>` is not implemented for `A`
2422
note: required by a bound in `is_maybe_transmutable`
2523
--> $DIR/should_reject_disjoint.rs:13:14
2624
|

‎tests/ui/transmutability/unions/should_reject_intersecting.stderr

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context`.
1+
error[E0277]: `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context`
22
--> $DIR/should_reject_intersecting.rs:36:34
33
|
44
LL | assert::is_transmutable::<A, B>();
5-
| ^ `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context`.
5+
| ^ At least one value of `A` isn't a bit-valid value of `B`
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<A, assert::Context, Assume { alignment: false, lifetimes: false, safety: true, validity: false }>` is not implemented for `B`
87
note: required by a bound in `is_transmutable`
98
--> $DIR/should_reject_intersecting.rs:14:14
109
|
@@ -14,13 +13,12 @@ LL | where
1413
LL | Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
1514
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
1615

17-
error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`.
16+
error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`
1817
--> $DIR/should_reject_intersecting.rs:37:34
1918
|
2019
LL | assert::is_transmutable::<B, A>();
21-
| ^ `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`.
20+
| ^ At least one value of `B` isn't a bit-valid value of `A`
2221
|
23-
= help: the trait `BikeshedIntrinsicFrom<B, assert::Context, Assume { alignment: false, lifetimes: false, safety: true, validity: false }>` is not implemented for `A`
2422
note: required by a bound in `is_transmutable`
2523
--> $DIR/should_reject_intersecting.rs:14:14
2624
|

‎tests/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`.
1+
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`
22
--> $DIR/should_reject_if_dst_has_private_field.rs:35:41
33
|
44
LL | assert::is_transmutable::<src::Src, dst::Dst, Context>();
5-
| ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`.
5+
| ^^^^^^^^ `Dst` is or contains a type or field that is not visible in that scope
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<Src, test::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `Dst`
87
note: required by a bound in `is_transmutable`
98
--> $DIR/should_reject_if_dst_has_private_field.rs:13:14
109
|

‎tests/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`.
1+
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`
22
--> $DIR/should_reject_if_dst_has_private_variant.rs:36:41
33
|
44
LL | assert::is_transmutable::<src::Src, dst::Dst, Context>();
5-
| ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`.
5+
| ^^^^^^^^ `Dst` is or contains a type or field that is not visible in that scope
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<Src, test::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `Dst`
87
note: required by a bound in `is_transmutable`
98
--> $DIR/should_reject_if_dst_has_private_variant.rs:13:14
109
|

‎tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`.
1+
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`
22
--> $DIR/should_reject_if_dst_has_unreachable_field.rs:37:41
33
|
44
LL | assert::is_transmutable::<src::Src, dst::Dst, Context>();
5-
| ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`.
5+
| ^^^^^^^^ `Dst` is or contains a type or field that is not visible in that scope
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<Src, test::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `Dst`
87
note: required by a bound in `is_transmutable`
98
--> $DIR/should_reject_if_dst_has_unreachable_field.rs:15:14
109
|

‎tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ note: the struct `Dst` is defined here
1010
LL | #[repr(C)] pub(self) struct Dst {
1111
| ^^^^^^^^^^^^^^^^^^^^
1212

13-
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`.
13+
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`
1414
--> $DIR/should_reject_if_dst_has_unreachable_ty.rs:38:41
1515
|
1616
LL | assert::is_transmutable::<src::Src, dst::Dst, Context>();
17-
| ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`.
17+
| ^^^^^^^^ `Dst` is or contains a type or field that is not visible in that scope
1818
|
19-
= help: the trait `BikeshedIntrinsicFrom<Src, test::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `Dst`
2019
note: required by a bound in `is_transmutable`
2120
--> $DIR/should_reject_if_dst_has_unreachable_ty.rs:15:14
2221
|

‎tests/ui/transmute/transmute-padding-ice.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`.
1+
error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`
22
--> $DIR/transmute-padding-ice.rs:27:40
33
|
44
LL | assert::is_maybe_transmutable::<B, A>();
5-
| ^ `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`.
5+
| ^ The size of `B` is smaller than the size of `A`
66
|
7-
= help: the trait `BikeshedIntrinsicFrom<B, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `A`
87
note: required by a bound in `is_maybe_transmutable`
98
--> $DIR/transmute-padding-ice.rs:11:14
109
|

0 commit comments

Comments
 (0)
Please sign in to comment.