mirror of https://github.com/rust-lang/rust.git
safe transmute: revise safety analysis
Migrate to a simplified safety analysis that does not use visibility. Closes https://github.com/rust-lang/project-safe-transmute/issues/15
This commit is contained in:
parent
9afdb8d1d5
commit
23ab1bda92
|
@ -167,7 +167,7 @@ language_item_table! {
|
|||
|
||||
// language items relating to transmutability
|
||||
TransmuteOpts, sym::transmute_opts, transmute_opts, Target::Struct, GenericRequirement::Exact(0);
|
||||
TransmuteTrait, sym::transmute_trait, transmute_trait, Target::Trait, GenericRequirement::Exact(3);
|
||||
TransmuteTrait, sym::transmute_trait, transmute_trait, Target::Trait, GenericRequirement::Exact(2);
|
||||
|
||||
Add, sym::add, add_trait, Target::Trait, GenericRequirement::Exact(1);
|
||||
Sub, sym::sub, sub_trait, Target::Trait, GenericRequirement::Exact(1);
|
||||
|
|
|
@ -874,7 +874,6 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
pub(super) fn is_transmutable(
|
||||
&self,
|
||||
src_and_dst: rustc_transmute::Types<'tcx>,
|
||||
scope: Ty<'tcx>,
|
||||
assume: rustc_transmute::Assume,
|
||||
) -> Result<Certainty, NoSolution> {
|
||||
use rustc_transmute::Answer;
|
||||
|
@ -882,7 +881,6 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
match rustc_transmute::TransmuteTypeEnv::new(self.infcx).is_transmutable(
|
||||
ObligationCause::dummy(),
|
||||
src_and_dst,
|
||||
scope,
|
||||
assume,
|
||||
) {
|
||||
Answer::Yes => Ok(Certainty::Yes),
|
||||
|
|
|
@ -543,14 +543,13 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
|
|||
let args = ecx.tcx().erase_regions(goal.predicate.trait_ref.args);
|
||||
|
||||
let Some(assume) =
|
||||
rustc_transmute::Assume::from_const(ecx.tcx(), goal.param_env, args.const_at(3))
|
||||
rustc_transmute::Assume::from_const(ecx.tcx(), goal.param_env, args.const_at(2))
|
||||
else {
|
||||
return Err(NoSolution);
|
||||
};
|
||||
|
||||
let certainty = ecx.is_transmutable(
|
||||
rustc_transmute::Types { dst: args.type_at(0), src: args.type_at(1) },
|
||||
args.type_at(2),
|
||||
assume,
|
||||
)?;
|
||||
ecx.evaluate_added_goals_and_make_canonical_response(certainty)
|
||||
|
|
|
@ -2970,11 +2970,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
dst: trait_ref.args.type_at(0),
|
||||
src: trait_ref.args.type_at(1),
|
||||
};
|
||||
let scope = trait_ref.args.type_at(2);
|
||||
let Some(assume) = rustc_transmute::Assume::from_const(
|
||||
self.infcx.tcx,
|
||||
obligation.param_env,
|
||||
trait_ref.args.const_at(3),
|
||||
trait_ref.args.const_at(2),
|
||||
) else {
|
||||
self.dcx().span_delayed_bug(
|
||||
span,
|
||||
|
@ -2986,15 +2985,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
match rustc_transmute::TransmuteTypeEnv::new(self.infcx).is_transmutable(
|
||||
obligation.cause,
|
||||
src_and_dst,
|
||||
scope,
|
||||
assume,
|
||||
) {
|
||||
Answer::No(reason) => {
|
||||
let dst = trait_ref.args.type_at(0);
|
||||
let src = trait_ref.args.type_at(1);
|
||||
let err_msg = format!(
|
||||
"`{src}` cannot be safely transmuted into `{dst}` in the defining scope of `{scope}`"
|
||||
);
|
||||
let err_msg = format!("`{src}` cannot be safely transmuted into `{dst}`");
|
||||
let safe_transmute_explanation = match reason {
|
||||
rustc_transmute::Reason::SrcIsUnspecified => {
|
||||
format!("`{src}` does not have a well-specified layout")
|
||||
|
@ -3008,9 +3004,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
format!("At least one value of `{src}` isn't a bit-valid value of `{dst}`")
|
||||
}
|
||||
|
||||
rustc_transmute::Reason::DstIsPrivate => format!(
|
||||
"`{dst}` is or contains a type or field that is not visible in that scope"
|
||||
),
|
||||
rustc_transmute::Reason::DstMayHaveSafetyInvariants => {
|
||||
format!("`{dst}` may carry safety invariants")
|
||||
}
|
||||
rustc_transmute::Reason::DstIsTooBig => {
|
||||
format!("The size of `{src}` is smaller than the size of `{dst}`")
|
||||
}
|
||||
|
|
|
@ -310,8 +310,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
.collect(),
|
||||
Condition::IfTransmutable { src, dst } => {
|
||||
let trait_def_id = obligation.predicate.def_id();
|
||||
let scope = predicate.trait_ref.args.type_at(2);
|
||||
let assume_const = predicate.trait_ref.args.const_at(3);
|
||||
let assume_const = predicate.trait_ref.args.const_at(2);
|
||||
let make_obl = |from_ty, to_ty| {
|
||||
let trait_ref1 = ty::TraitRef::new(
|
||||
tcx,
|
||||
|
@ -319,7 +318,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
[
|
||||
ty::GenericArg::from(to_ty),
|
||||
ty::GenericArg::from(from_ty),
|
||||
ty::GenericArg::from(scope),
|
||||
ty::GenericArg::from(assume_const),
|
||||
],
|
||||
);
|
||||
|
@ -355,7 +353,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let Some(assume) = rustc_transmute::Assume::from_const(
|
||||
self.infcx.tcx,
|
||||
obligation.param_env,
|
||||
predicate.trait_ref.args.const_at(3),
|
||||
predicate.trait_ref.args.const_at(2),
|
||||
) else {
|
||||
return Err(Unimplemented);
|
||||
};
|
||||
|
@ -367,7 +365,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let maybe_transmutable = transmute_env.is_transmutable(
|
||||
obligation.cause.clone(),
|
||||
rustc_transmute::Types { dst, src },
|
||||
predicate.trait_ref.args.type_at(2),
|
||||
assume,
|
||||
);
|
||||
|
||||
|
|
|
@ -29,14 +29,21 @@ impl fmt::Debug for Byte {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) trait Def: Debug + Hash + Eq + PartialEq + Copy + Clone {}
|
||||
pub(crate) trait Def: Debug + Hash + Eq + PartialEq + Copy + Clone {
|
||||
fn has_safety_invariants(&self) -> bool;
|
||||
}
|
||||
pub trait Ref: Debug + Hash + Eq + PartialEq + Copy + Clone {
|
||||
fn min_align(&self) -> usize;
|
||||
|
||||
fn is_mutable(&self) -> bool;
|
||||
}
|
||||
|
||||
impl Def for ! {}
|
||||
impl Def for ! {
|
||||
fn has_safety_invariants(&self) -> bool {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Ref for ! {
|
||||
fn min_align(&self) -> usize {
|
||||
unreachable!()
|
||||
|
@ -83,5 +90,12 @@ pub mod rustc {
|
|||
Primitive,
|
||||
}
|
||||
|
||||
impl<'tcx> super::Def for Def<'tcx> {}
|
||||
impl<'tcx> super::Def for Def<'tcx> {
|
||||
fn has_safety_invariants(&self) -> bool {
|
||||
// Rust presently has no notion of 'unsafe fields', so for now we
|
||||
// make the conservative assumption that everything besides
|
||||
// primitive types carry safety invariants.
|
||||
self != &Self::Primitive
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,8 @@ where
|
|||
Self::Seq(vec![Self::uninit(); width_in_bytes])
|
||||
}
|
||||
|
||||
/// Remove all `Def` nodes, and all branches of the layout for which `f` produces false.
|
||||
/// Remove all `Def` nodes, and all branches of the layout for which `f`
|
||||
/// produces `true`.
|
||||
pub(crate) fn prune<F>(self, f: &F) -> Tree<!, R>
|
||||
where
|
||||
F: Fn(D) -> bool,
|
||||
|
@ -106,7 +107,7 @@ where
|
|||
Self::Byte(b) => Tree::Byte(b),
|
||||
Self::Ref(r) => Tree::Ref(r),
|
||||
Self::Def(d) => {
|
||||
if !f(d) {
|
||||
if f(d) {
|
||||
Tree::uninhabited()
|
||||
} else {
|
||||
Tree::unit()
|
||||
|
|
|
@ -2,11 +2,15 @@ use super::Tree;
|
|||
|
||||
#[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)]
|
||||
pub enum Def {
|
||||
Visible,
|
||||
Invisible,
|
||||
NoSafetyInvariants,
|
||||
HasSafetyInvariants,
|
||||
}
|
||||
|
||||
impl super::Def for Def {}
|
||||
impl super::Def for Def {
|
||||
fn has_safety_invariants(&self) -> bool {
|
||||
self == &Self::HasSafetyInvariants
|
||||
}
|
||||
}
|
||||
|
||||
mod prune {
|
||||
use super::*;
|
||||
|
@ -16,17 +20,22 @@ mod prune {
|
|||
|
||||
#[test]
|
||||
fn seq_1() {
|
||||
let layout: Tree<Def, !> = Tree::def(Def::Visible).then(Tree::from_bits(0x00));
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::from_bits(0x00));
|
||||
let layout: Tree<Def, !> =
|
||||
Tree::def(Def::NoSafetyInvariants).then(Tree::from_bits(0x00));
|
||||
assert_eq!(
|
||||
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
|
||||
Tree::from_bits(0x00)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn seq_2() {
|
||||
let layout: Tree<Def, !> =
|
||||
Tree::from_bits(0x00).then(Tree::def(Def::Visible)).then(Tree::from_bits(0x01));
|
||||
let layout: Tree<Def, !> = Tree::from_bits(0x00)
|
||||
.then(Tree::def(Def::NoSafetyInvariants))
|
||||
.then(Tree::from_bits(0x01));
|
||||
|
||||
assert_eq!(
|
||||
layout.prune(&|d| matches!(d, Def::Visible)),
|
||||
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
|
||||
Tree::from_bits(0x00).then(Tree::from_bits(0x01))
|
||||
);
|
||||
}
|
||||
|
@ -37,21 +46,32 @@ mod prune {
|
|||
|
||||
#[test]
|
||||
fn invisible_def() {
|
||||
let layout: Tree<Def, !> = Tree::def(Def::Invisible);
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::uninhabited());
|
||||
let layout: Tree<Def, !> = Tree::def(Def::HasSafetyInvariants);
|
||||
assert_eq!(
|
||||
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
|
||||
Tree::uninhabited()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invisible_def_in_seq_len_2() {
|
||||
let layout: Tree<Def, !> = Tree::def(Def::Visible).then(Tree::def(Def::Invisible));
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::uninhabited());
|
||||
let layout: Tree<Def, !> =
|
||||
Tree::def(Def::NoSafetyInvariants).then(Tree::def(Def::HasSafetyInvariants));
|
||||
assert_eq!(
|
||||
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
|
||||
Tree::uninhabited()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invisible_def_in_seq_len_3() {
|
||||
let layout: Tree<Def, !> =
|
||||
Tree::def(Def::Visible).then(Tree::from_bits(0x00)).then(Tree::def(Def::Invisible));
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::uninhabited());
|
||||
let layout: Tree<Def, !> = Tree::def(Def::NoSafetyInvariants)
|
||||
.then(Tree::from_bits(0x00))
|
||||
.then(Tree::def(Def::HasSafetyInvariants));
|
||||
assert_eq!(
|
||||
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
|
||||
Tree::uninhabited()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,21 +80,26 @@ mod prune {
|
|||
|
||||
#[test]
|
||||
fn visible_def() {
|
||||
let layout: Tree<Def, !> = Tree::def(Def::Visible);
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::unit());
|
||||
let layout: Tree<Def, !> = Tree::def(Def::NoSafetyInvariants);
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)), Tree::unit());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn visible_def_in_seq_len_2() {
|
||||
let layout: Tree<Def, !> = Tree::def(Def::Visible).then(Tree::def(Def::Visible));
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::unit());
|
||||
let layout: Tree<Def, !> =
|
||||
Tree::def(Def::NoSafetyInvariants).then(Tree::def(Def::NoSafetyInvariants));
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)), Tree::unit());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn visible_def_in_seq_len_3() {
|
||||
let layout: Tree<Def, !> =
|
||||
Tree::def(Def::Visible).then(Tree::from_bits(0x00)).then(Tree::def(Def::Visible));
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::from_bits(0x00));
|
||||
let layout: Tree<Def, !> = Tree::def(Def::NoSafetyInvariants)
|
||||
.then(Tree::from_bits(0x00))
|
||||
.then(Tree::def(Def::NoSafetyInvariants));
|
||||
assert_eq!(
|
||||
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
|
||||
Tree::from_bits(0x00)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ pub enum Reason {
|
|||
DstIsUnspecified,
|
||||
/// The layout of the destination type is bit-incompatible with the source type.
|
||||
DstIsBitIncompatible,
|
||||
/// There aren't any public constructors for `Dst`.
|
||||
DstIsPrivate,
|
||||
/// The destination type may carry safety invariants.
|
||||
DstMayHaveSafetyInvariants,
|
||||
/// `Dst` is larger than `Src`, and the excess bytes were not exclusively uninitialized.
|
||||
DstIsTooBig,
|
||||
/// Src should have a stricter alignment than Dst, but it does not.
|
||||
|
@ -106,13 +106,11 @@ mod rustc {
|
|||
&mut self,
|
||||
cause: ObligationCause<'tcx>,
|
||||
types: Types<'tcx>,
|
||||
scope: Ty<'tcx>,
|
||||
assume: crate::Assume,
|
||||
) -> crate::Answer<crate::layout::rustc::Ref<'tcx>> {
|
||||
crate::maybe_transmutable::MaybeTransmutableQuery::new(
|
||||
types.src,
|
||||
types.dst,
|
||||
scope,
|
||||
assume,
|
||||
self.infcx.tcx,
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@ pub(crate) mod query_context;
|
|||
mod tests;
|
||||
|
||||
use crate::{
|
||||
layout::{self, dfa, Byte, Dfa, Nfa, Ref, Tree, Uninhabited},
|
||||
layout::{self, dfa, Byte, Def, Dfa, Nfa, Ref, Tree, Uninhabited},
|
||||
maybe_transmutable::query_context::QueryContext,
|
||||
Answer, Condition, Map, Reason,
|
||||
};
|
||||
|
@ -14,7 +14,6 @@ where
|
|||
{
|
||||
src: L,
|
||||
dst: L,
|
||||
scope: <C as QueryContext>::Scope,
|
||||
assume: crate::Assume,
|
||||
context: C,
|
||||
}
|
||||
|
@ -23,14 +22,8 @@ impl<L, C> MaybeTransmutableQuery<L, C>
|
|||
where
|
||||
C: QueryContext,
|
||||
{
|
||||
pub(crate) fn new(
|
||||
src: L,
|
||||
dst: L,
|
||||
scope: <C as QueryContext>::Scope,
|
||||
assume: crate::Assume,
|
||||
context: C,
|
||||
) -> Self {
|
||||
Self { src, dst, scope, assume, context }
|
||||
pub(crate) fn new(src: L, dst: L, assume: crate::Assume, context: C) -> Self {
|
||||
Self { src, dst, assume, context }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +41,7 @@ mod rustc {
|
|||
/// then computes an answer using those trees.
|
||||
#[instrument(level = "debug", skip(self), fields(src = ?self.src, dst = ?self.dst))]
|
||||
pub fn answer(self) -> Answer<<TyCtxt<'tcx> as QueryContext>::Ref> {
|
||||
let Self { src, dst, scope, assume, context } = self;
|
||||
let Self { src, dst, assume, context } = self;
|
||||
|
||||
// Convert `src` and `dst` from their rustc representations, to `Tree`-based
|
||||
// representations. If these conversions fail, conclude that the transmutation is
|
||||
|
@ -67,9 +60,7 @@ mod rustc {
|
|||
(_, Err(Err::Unspecified)) => Answer::No(Reason::DstIsUnspecified),
|
||||
(Err(Err::SizeOverflow), _) => Answer::No(Reason::SrcSizeOverflow),
|
||||
(_, Err(Err::SizeOverflow)) => Answer::No(Reason::DstSizeOverflow),
|
||||
(Ok(src), Ok(dst)) => {
|
||||
MaybeTransmutableQuery { src, dst, scope, assume, context }.answer()
|
||||
}
|
||||
(Ok(src), Ok(dst)) => MaybeTransmutableQuery { src, dst, assume, context }.answer(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,43 +77,51 @@ where
|
|||
#[inline(always)]
|
||||
#[instrument(level = "debug", skip(self), fields(src = ?self.src, dst = ?self.dst))]
|
||||
pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> {
|
||||
let assume_visibility = self.assume.safety;
|
||||
let Self { src, dst, assume, context } = self;
|
||||
|
||||
let Self { src, dst, scope, assume, context } = self;
|
||||
|
||||
// Remove all `Def` nodes from `src`, without checking their visibility.
|
||||
let src = src.prune(&|def| true);
|
||||
// Unconditionally all `Def` nodes from `src`, without pruning away the
|
||||
// branches they appear in. This is valid to do for value-to-value
|
||||
// transmutations, but not for `&mut T` to `&mut U`; we will need to be
|
||||
// more sophisticated to handle transmutations between mutable
|
||||
// references.
|
||||
let src = src.prune(&|def| false);
|
||||
|
||||
trace!(?src, "pruned src");
|
||||
|
||||
// Remove all `Def` nodes from `dst`, additionally...
|
||||
let dst = if assume_visibility {
|
||||
// ...if visibility is assumed, don't check their visibility.
|
||||
dst.prune(&|def| true)
|
||||
let dst = if assume.safety {
|
||||
// ...if safety is assumed, don't check if they carry safety
|
||||
// invariants; retain all paths.
|
||||
dst.prune(&|def| false)
|
||||
} else {
|
||||
// ...otherwise, prune away all unreachable paths through the `Dst` layout.
|
||||
dst.prune(&|def| context.is_accessible_from(def, scope))
|
||||
// ...otherwise, prune away all paths with safety invariants from
|
||||
// the `Dst` layout.
|
||||
dst.prune(&|def| def.has_safety_invariants())
|
||||
};
|
||||
|
||||
trace!(?dst, "pruned dst");
|
||||
|
||||
// Convert `src` from a tree-based representation to an NFA-based representation.
|
||||
// If the conversion fails because `src` is uninhabited, conclude that the transmutation
|
||||
// is acceptable, because instances of the `src` type do not exist.
|
||||
// Convert `src` from a tree-based representation to an NFA-based
|
||||
// representation. If the conversion fails because `src` is uninhabited,
|
||||
// conclude that the transmutation is acceptable, because instances of
|
||||
// the `src` type do not exist.
|
||||
let src = match Nfa::from_tree(src) {
|
||||
Ok(src) => src,
|
||||
Err(Uninhabited) => return Answer::Yes,
|
||||
};
|
||||
|
||||
// Convert `dst` from a tree-based representation to an NFA-based representation.
|
||||
// If the conversion fails because `src` is uninhabited, conclude that the transmutation
|
||||
// is unacceptable, because instances of the `dst` type do not exist.
|
||||
// Convert `dst` from a tree-based representation to an NFA-based
|
||||
// representation. If the conversion fails because `src` is uninhabited,
|
||||
// conclude that the transmutation is unacceptable. Valid instances of
|
||||
// the `dst` type do not exist, either because it's genuinely
|
||||
// uninhabited, or because there are no branches of the tree that are
|
||||
// free of safety invariants.
|
||||
let dst = match Nfa::from_tree(dst) {
|
||||
Ok(dst) => dst,
|
||||
Err(Uninhabited) => return Answer::No(Reason::DstIsPrivate),
|
||||
Err(Uninhabited) => return Answer::No(Reason::DstMayHaveSafetyInvariants),
|
||||
};
|
||||
|
||||
MaybeTransmutableQuery { src, dst, scope, assume, context }.answer()
|
||||
MaybeTransmutableQuery { src, dst, assume, context }.answer()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,10 +135,10 @@ where
|
|||
#[inline(always)]
|
||||
#[instrument(level = "debug", skip(self), fields(src = ?self.src, dst = ?self.dst))]
|
||||
pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> {
|
||||
let Self { src, dst, scope, assume, context } = self;
|
||||
let Self { src, dst, assume, context } = self;
|
||||
let src = Dfa::from_nfa(src);
|
||||
let dst = Dfa::from_nfa(dst);
|
||||
MaybeTransmutableQuery { src, dst, scope, assume, context }.answer()
|
||||
MaybeTransmutableQuery { src, dst, assume, context }.answer()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,6 @@ pub(crate) trait QueryContext {
|
|||
type Ref: layout::Ref;
|
||||
type Scope: Copy;
|
||||
|
||||
/// Is `def` accessible from the defining module of `scope`?
|
||||
fn is_accessible_from(&self, def: Self::Def, scope: Self::Scope) -> bool;
|
||||
|
||||
fn min_align(&self, reference: Self::Ref) -> usize;
|
||||
}
|
||||
|
||||
|
@ -20,21 +17,21 @@ pub(crate) mod test {
|
|||
|
||||
#[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)]
|
||||
pub(crate) enum Def {
|
||||
Visible,
|
||||
Invisible,
|
||||
HasSafetyInvariants,
|
||||
NoSafetyInvariants,
|
||||
}
|
||||
|
||||
impl crate::layout::Def for Def {}
|
||||
impl crate::layout::Def for Def {
|
||||
fn has_safety_invariants(&self) -> bool {
|
||||
self == &Self::HasSafetyInvariants
|
||||
}
|
||||
}
|
||||
|
||||
impl QueryContext for UltraMinimal {
|
||||
type Def = Def;
|
||||
type Ref = !;
|
||||
type Scope = ();
|
||||
|
||||
fn is_accessible_from(&self, def: Def, scope: ()) -> bool {
|
||||
matches!(Def::Visible, def)
|
||||
}
|
||||
|
||||
fn min_align(&self, reference: !) -> usize {
|
||||
unimplemented!()
|
||||
}
|
||||
|
@ -52,34 +49,6 @@ mod rustc {
|
|||
|
||||
type Scope = Ty<'tcx>;
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn is_accessible_from(&self, def: Self::Def, scope: Self::Scope) -> bool {
|
||||
use layout::rustc::Def;
|
||||
use rustc_middle::ty;
|
||||
|
||||
let parent = if let ty::Adt(adt_def, ..) = scope.kind() {
|
||||
self.parent(adt_def.did())
|
||||
} else {
|
||||
// Is this always how we want to handle a non-ADT scope?
|
||||
return false;
|
||||
};
|
||||
|
||||
let def_id = match def {
|
||||
Def::Adt(adt_def) => adt_def.did(),
|
||||
Def::Variant(variant_def) => variant_def.def_id,
|
||||
Def::Field(field_def) => field_def.did,
|
||||
Def::Primitive => {
|
||||
// primitives do not have a def_id, but they're always accessible
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
let ret: bool = self.visibility(def_id).is_accessible_from(parent, *self);
|
||||
|
||||
trace!(?ret, "ret");
|
||||
ret
|
||||
}
|
||||
|
||||
fn min_align(&self, reference: Self::Ref) -> usize {
|
||||
unimplemented!()
|
||||
}
|
||||
|
|
|
@ -3,6 +3,65 @@ use crate::maybe_transmutable::MaybeTransmutableQuery;
|
|||
use crate::{layout, Reason};
|
||||
use itertools::Itertools;
|
||||
|
||||
mod safety {
|
||||
use crate::Answer;
|
||||
|
||||
use super::*;
|
||||
|
||||
type Tree = layout::Tree<Def, !>;
|
||||
|
||||
const DST_HAS_SAFETY_INVARIANTS: Answer<!> =
|
||||
Answer::No(crate::Reason::DstMayHaveSafetyInvariants);
|
||||
|
||||
fn is_transmutable(src: &Tree, dst: &Tree, assume_safety: bool) -> crate::Answer<!> {
|
||||
let src = src.clone();
|
||||
let dst = dst.clone();
|
||||
// The only dimension of the transmutability analysis we want to test
|
||||
// here is the safety analysis. To ensure this, we disable all other
|
||||
// toggleable aspects of the transmutability analysis.
|
||||
let assume = crate::Assume {
|
||||
alignment: true,
|
||||
lifetimes: true,
|
||||
validity: true,
|
||||
safety: assume_safety,
|
||||
};
|
||||
crate::maybe_transmutable::MaybeTransmutableQuery::new(src, dst, assume, UltraMinimal)
|
||||
.answer()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn src_safe_dst_safe() {
|
||||
let src = Tree::Def(Def::NoSafetyInvariants).then(Tree::u8());
|
||||
let dst = Tree::Def(Def::NoSafetyInvariants).then(Tree::u8());
|
||||
assert_eq!(is_transmutable(&src, &dst, false), Answer::Yes);
|
||||
assert_eq!(is_transmutable(&src, &dst, true), Answer::Yes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn src_safe_dst_unsafe() {
|
||||
let src = Tree::Def(Def::NoSafetyInvariants).then(Tree::u8());
|
||||
let dst = Tree::Def(Def::HasSafetyInvariants).then(Tree::u8());
|
||||
assert_eq!(is_transmutable(&src, &dst, false), DST_HAS_SAFETY_INVARIANTS);
|
||||
assert_eq!(is_transmutable(&src, &dst, true), Answer::Yes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn src_unsafe_dst_safe() {
|
||||
let src = Tree::Def(Def::HasSafetyInvariants).then(Tree::u8());
|
||||
let dst = Tree::Def(Def::NoSafetyInvariants).then(Tree::u8());
|
||||
assert_eq!(is_transmutable(&src, &dst, false), Answer::Yes);
|
||||
assert_eq!(is_transmutable(&src, &dst, true), Answer::Yes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn src_unsafe_dst_unsafe() {
|
||||
let src = Tree::Def(Def::HasSafetyInvariants).then(Tree::u8());
|
||||
let dst = Tree::Def(Def::HasSafetyInvariants).then(Tree::u8());
|
||||
assert_eq!(is_transmutable(&src, &dst, false), DST_HAS_SAFETY_INVARIANTS);
|
||||
assert_eq!(is_transmutable(&src, &dst, true), Answer::Yes);
|
||||
}
|
||||
}
|
||||
|
||||
mod bool {
|
||||
use crate::Answer;
|
||||
|
||||
|
@ -10,11 +69,9 @@ mod bool {
|
|||
|
||||
#[test]
|
||||
fn should_permit_identity_transmutation_tree() {
|
||||
println!("{:?}", layout::Tree::<!, !>::bool());
|
||||
let answer = crate::maybe_transmutable::MaybeTransmutableQuery::new(
|
||||
layout::Tree::<Def, !>::bool(),
|
||||
layout::Tree::<Def, !>::bool(),
|
||||
(),
|
||||
crate::Assume { alignment: false, lifetimes: false, validity: true, safety: false },
|
||||
UltraMinimal,
|
||||
)
|
||||
|
@ -27,7 +84,6 @@ mod bool {
|
|||
let answer = crate::maybe_transmutable::MaybeTransmutableQuery::new(
|
||||
layout::Dfa::<!>::bool(),
|
||||
layout::Dfa::<!>::bool(),
|
||||
(),
|
||||
crate::Assume { alignment: false, lifetimes: false, validity: true, safety: false },
|
||||
UltraMinimal,
|
||||
)
|
||||
|
@ -71,7 +127,6 @@ mod bool {
|
|||
MaybeTransmutableQuery::new(
|
||||
src_layout.clone(),
|
||||
dst_layout.clone(),
|
||||
(),
|
||||
crate::Assume { validity: false, ..crate::Assume::default() },
|
||||
UltraMinimal,
|
||||
)
|
||||
|
@ -86,7 +141,6 @@ mod bool {
|
|||
MaybeTransmutableQuery::new(
|
||||
src_layout.clone(),
|
||||
dst_layout.clone(),
|
||||
(),
|
||||
crate::Assume { validity: true, ..crate::Assume::default() },
|
||||
UltraMinimal,
|
||||
)
|
||||
|
@ -101,7 +155,6 @@ mod bool {
|
|||
MaybeTransmutableQuery::new(
|
||||
src_layout.clone(),
|
||||
dst_layout.clone(),
|
||||
(),
|
||||
crate::Assume { validity: false, ..crate::Assume::default() },
|
||||
UltraMinimal,
|
||||
)
|
||||
|
|
|
@ -6,10 +6,10 @@ use crate::marker::ConstParamTy;
|
|||
/// any value of type `Self` are safely transmutable into a value of type `Dst`, in a given `Context`,
|
||||
/// notwithstanding whatever safety checks you have asked the compiler to [`Assume`] are satisfied.
|
||||
#[unstable(feature = "transmutability", issue = "99571")]
|
||||
#[lang = "transmute_trait"]
|
||||
#[cfg_attr(not(bootstrap), lang = "transmute_trait")]
|
||||
#[rustc_deny_explicit_impl(implement_via_object = false)]
|
||||
#[rustc_coinductive]
|
||||
pub unsafe trait BikeshedIntrinsicFrom<Src, Context, const ASSUME: Assume = { Assume::NOTHING }>
|
||||
pub unsafe trait BikeshedIntrinsicFrom<Src, const ASSUME: Assume = { Assume::NOTHING }>
|
||||
where
|
||||
Src: ?Sized,
|
||||
{
|
||||
|
@ -28,8 +28,9 @@ pub struct Assume {
|
|||
/// that violates Rust's memory model.
|
||||
pub lifetimes: bool,
|
||||
|
||||
/// When `true`, the compiler assumes that *you* have ensured that it is safe for you to violate the
|
||||
/// type and field privacy of the destination type (and sometimes of the source type, too).
|
||||
/// When `true`, the compiler assumes that *you* have ensured that no
|
||||
/// unsoundness will arise from violating the safety invariants of the
|
||||
/// destination type (and sometimes of the source type, too).
|
||||
pub safety: bool,
|
||||
|
||||
/// When `true`, the compiler assumes that *you* are ensuring that the source type is actually a valid
|
||||
|
|
|
@ -4133,7 +4133,6 @@
|
|||
"ui/transmutability/issue-101739-2.rs",
|
||||
"ui/transmutability/issue-110467.rs",
|
||||
"ui/transmutability/issue-110892.rs",
|
||||
"ui/transmute/issue-115402-overflow-size.rs",
|
||||
"ui/trivial-bounds/issue-73021-impossible-inline.rs",
|
||||
"ui/try-block/issue-45124.rs",
|
||||
"ui/try-trait/issue-32709.rs",
|
||||
|
|
|
@ -13,41 +13,27 @@ mod assert {
|
|||
pub fn is_transmutable<
|
||||
Src,
|
||||
Dst,
|
||||
Context,
|
||||
const ASSUME: std::mem::Assume,
|
||||
>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<
|
||||
Src,
|
||||
Context,
|
||||
ASSUME,
|
||||
>,
|
||||
{}
|
||||
}
|
||||
|
||||
fn direct() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst;
|
||||
|
||||
assert::is_transmutable::<Src, Dst, Context, { std::mem::Assume::NOTHING }>();
|
||||
assert::is_transmutable::<(), (), { std::mem::Assume::NOTHING }>();
|
||||
}
|
||||
|
||||
fn via_const() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst;
|
||||
|
||||
const FALSE: bool = false;
|
||||
|
||||
assert::is_transmutable::<Src, Dst, Context, { std::mem::Assume::NOTHING }>();
|
||||
assert::is_transmutable::<(), (), { std::mem::Assume::NOTHING }>();
|
||||
}
|
||||
|
||||
fn via_associated_const() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst;
|
||||
|
||||
trait Trait {
|
||||
const FALSE: bool = true;
|
||||
}
|
||||
|
@ -57,9 +43,8 @@ fn via_associated_const() {
|
|||
impl Trait for Ty {}
|
||||
|
||||
assert::is_transmutable::<
|
||||
Src,
|
||||
Dst,
|
||||
Context,
|
||||
(),
|
||||
(),
|
||||
{
|
||||
std::mem::Assume {
|
||||
alignment: {Ty::FALSE},
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn array_like<T, E, const N: usize>()
|
||||
where
|
||||
T: BikeshedIntrinsicFrom<[E; N], Context, { Assume::SAFETY }>,
|
||||
[E; N]: BikeshedIntrinsicFrom<T, Context, { Assume::SAFETY }>
|
||||
T: BikeshedIntrinsicFrom<[E; N], { Assume::SAFETY }>,
|
||||
[E; N]: BikeshedIntrinsicFrom<T, { Assume::SAFETY }>
|
||||
{}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: false,
|
||||
lifetimes: true,
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `&[u8; 0]` cannot be safely transmuted into `&[u16; 0]` in the defining scope of `assert::Context`
|
||||
--> $DIR/align-fail.rs:22:55
|
||||
error[E0277]: `&[u8; 0]` cannot be safely transmuted into `&[u16; 0]`
|
||||
--> $DIR/align-fail.rs:21:55
|
||||
|
|
||||
LL | ...tatic [u8; 0], &'static [u16; 0]>();
|
||||
| ^^^^^^^^^^^^^^^^^ The minimum alignment of `&[u8; 0]` (1) should be greater than that of `&[u16; 0]` (2)
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/align-fail.rs:10:14
|
||||
--> $DIR/align-fail.rs:9:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: false,
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: false,
|
||||
lifetimes: false,
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
#![feature(transmutability)]
|
||||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context>,
|
||||
Dst: BikeshedIntrinsicFrom<Src>,
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,32 +1,32 @@
|
|||
error[E0277]: `()` cannot be safely transmuted into `ExplicitlyPadded` in the defining scope of `assert::Context`
|
||||
--> $DIR/issue-115402-overflow-size.rs:22:41
|
||||
error[E0277]: `()` cannot be safely transmuted into `ExplicitlyPadded`
|
||||
--> $DIR/huge-len.rs:21:41
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<(), ExplicitlyPadded>();
|
||||
| ^^^^^^^^^^^^^^^^ values of the type `ExplicitlyPadded` are too big for the current architecture
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/issue-115402-overflow-size.rs:9:14
|
||||
--> $DIR/huge-len.rs:8:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `ExplicitlyPadded` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/issue-115402-overflow-size.rs:25:55
|
||||
error[E0277]: `ExplicitlyPadded` cannot be safely transmuted into `()`
|
||||
--> $DIR/huge-len.rs:24:55
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<ExplicitlyPadded, ()>();
|
||||
| ^^ values of the type `ExplicitlyPadded` are too big for the current architecture
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/issue-115402-overflow-size.rs:9:14
|
||||
--> $DIR/huge-len.rs:8:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
@ -4,13 +4,11 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<
|
||||
Src,
|
||||
Context,
|
||||
{ Assume { alignment: true, lifetimes: true, safety: true, validity: true } },
|
||||
>,
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-103783-array-length.rs:21:34
|
||||
--> $DIR/issue-103783-array-length.rs:19:34
|
||||
|
|
||||
LL | type NaughtyLenArray = [u32; 3.14159];
|
||||
| ^^^^^^^ expected `usize`, found floating-point number
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY.and(Assume::VALIDITY) }>
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY.and(Assume::VALIDITY) }>
|
||||
{}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume::ALIGNMENT
|
||||
.and(Assume::LIFETIMES)
|
||||
.and(Assume::SAFETY)
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume::ALIGNMENT
|
||||
.and(Assume::LIFETIMES)
|
||||
.and(Assume::SAFETY)
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `[String; 0]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:26:52
|
||||
error[E0277]: `[String; 0]` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:25:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `[String; 0]` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
@ -19,19 +19,19 @@ LL | | .and(Assume::VALIDITY)
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `[String; 0]` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:27:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `[String; 0]`
|
||||
--> $DIR/should_require_well_defined_layout.rs:26:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `[String; 0]` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
@ -40,19 +40,19 @@ LL | | .and(Assume::VALIDITY)
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `[String; 1]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:32:52
|
||||
error[E0277]: `[String; 1]` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:31:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `[String; 1]` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
@ -61,19 +61,19 @@ LL | | .and(Assume::VALIDITY)
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `[String; 1]` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:33:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `[String; 1]`
|
||||
--> $DIR/should_require_well_defined_layout.rs:32:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `[String; 1]` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
@ -82,19 +82,19 @@ LL | | .and(Assume::VALIDITY)
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `[String; 2]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:38:52
|
||||
error[E0277]: `[String; 2]` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:37:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `[String; 2]` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
@ -103,19 +103,19 @@ LL | | .and(Assume::VALIDITY)
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `[String; 2]` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:39:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `[String; 2]`
|
||||
--> $DIR/should_require_well_defined_layout.rs:38:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `[String; 2]` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
|
||||
pub fn is_transmutable<Src, Dst, Context>()
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: true,
|
||||
|
@ -36,8 +36,6 @@ struct Zst;
|
|||
#[repr(usize)] enum V0usize { V }
|
||||
|
||||
fn n8() {
|
||||
struct Context;
|
||||
|
||||
type Smaller = Zst;
|
||||
type Analog = u8;
|
||||
type Larger = u16;
|
||||
|
@ -45,23 +43,21 @@ fn n8() {
|
|||
fn i_should_have_correct_length() {
|
||||
type Current = V0i8;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
||||
fn u_should_have_correct_length() {
|
||||
type Current = V0u8;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
}
|
||||
|
||||
fn n16() {
|
||||
struct Context;
|
||||
|
||||
type Smaller = u8;
|
||||
type Analog = u16;
|
||||
type Larger = u32;
|
||||
|
@ -69,23 +65,21 @@ fn n16() {
|
|||
fn i_should_have_correct_length() {
|
||||
type Current = V0i16;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
||||
fn u_should_have_correct_length() {
|
||||
type Current = V0u16;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
}
|
||||
|
||||
fn n32() {
|
||||
struct Context;
|
||||
|
||||
type Smaller = u16;
|
||||
type Analog = u32;
|
||||
type Larger = u64;
|
||||
|
@ -93,23 +87,21 @@ fn n32() {
|
|||
fn i_should_have_correct_length() {
|
||||
type Current = V0i32;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
||||
fn u_should_have_correct_length() {
|
||||
type Current = V0u32;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
}
|
||||
|
||||
fn n64() {
|
||||
struct Context;
|
||||
|
||||
type Smaller = u32;
|
||||
type Analog = u64;
|
||||
type Larger = u128;
|
||||
|
@ -117,23 +109,21 @@ fn n64() {
|
|||
fn i_should_have_correct_length() {
|
||||
type Current = V0i64;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
||||
fn u_should_have_correct_length() {
|
||||
type Current = V0u64;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
}
|
||||
|
||||
fn nsize() {
|
||||
struct Context;
|
||||
|
||||
type Smaller = u8;
|
||||
type Analog = usize;
|
||||
type Larger = [usize; 2];
|
||||
|
@ -141,16 +131,16 @@ fn nsize() {
|
|||
fn i_should_have_correct_length() {
|
||||
type Current = V0isize;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
||||
fn u_should_have_correct_length() {
|
||||
type Current = V0usize;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `Zst` cannot be safely transmuted into `V0i8` in the defining scope of `n8::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:48:44
|
||||
error[E0277]: `Zst` cannot be safely transmuted into `V0i8`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:46:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `Zst` is smaller than the size of `V0i8`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -20,19 +20,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0i8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:50:44
|
||||
error[E0277]: `V0i8` cannot be safely transmuted into `u16`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:48:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0i8` is smaller than the size of `u16`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -42,19 +42,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `Zst` cannot be safely transmuted into `V0u8` in the defining scope of `n8::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:56:44
|
||||
error[E0277]: `Zst` cannot be safely transmuted into `V0u8`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:54:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `Zst` is smaller than the size of `V0u8`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -64,19 +64,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0u8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:58:44
|
||||
error[E0277]: `V0u8` cannot be safely transmuted into `u16`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:56:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0u8` is smaller than the size of `u16`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -86,19 +86,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0i16` in the defining scope of `n16::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:72:44
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0i16`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:68:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u8` is smaller than the size of `V0i16`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -108,19 +108,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0i16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:74:44
|
||||
error[E0277]: `V0i16` cannot be safely transmuted into `u32`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:70:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0i16` is smaller than the size of `u32`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -130,19 +130,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0u16` in the defining scope of `n16::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:80:44
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0u16`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:76:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u8` is smaller than the size of `V0u16`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -152,19 +152,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0u16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:82:44
|
||||
error[E0277]: `V0u16` cannot be safely transmuted into `u32`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:78:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0u16` is smaller than the size of `u32`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -174,19 +174,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u16` cannot be safely transmuted into `V0i32` in the defining scope of `n32::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:96:44
|
||||
error[E0277]: `u16` cannot be safely transmuted into `V0i32`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:90:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u16` is smaller than the size of `V0i32`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -196,19 +196,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0i32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:98:44
|
||||
error[E0277]: `V0i32` cannot be safely transmuted into `u64`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:92:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0i32` is smaller than the size of `u64`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -218,19 +218,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u16` cannot be safely transmuted into `V0u32` in the defining scope of `n32::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:104:44
|
||||
error[E0277]: `u16` cannot be safely transmuted into `V0u32`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:98:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u16` is smaller than the size of `V0u32`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -240,19 +240,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0u32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:106:44
|
||||
error[E0277]: `V0u32` cannot be safely transmuted into `u64`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:100:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0u32` is smaller than the size of `u64`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -262,19 +262,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u32` cannot be safely transmuted into `V0i64` in the defining scope of `n64::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:120:44
|
||||
error[E0277]: `u32` cannot be safely transmuted into `V0i64`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:112:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u32` is smaller than the size of `V0i64`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -284,19 +284,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0i64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:122:44
|
||||
error[E0277]: `V0i64` cannot be safely transmuted into `u128`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:114:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0i64` is smaller than the size of `u128`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -306,19 +306,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u32` cannot be safely transmuted into `V0u64` in the defining scope of `n64::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:128:44
|
||||
error[E0277]: `u32` cannot be safely transmuted into `V0u64`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:120:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u32` is smaller than the size of `V0u64`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -328,19 +328,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0u64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:130:44
|
||||
error[E0277]: `V0u64` cannot be safely transmuted into `u128`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:122:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0u64` is smaller than the size of `u128`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -350,19 +350,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0isize` in the defining scope of `nsize::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:144:44
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0isize`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:134:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u8` is smaller than the size of `V0isize`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -372,19 +372,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0isize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:146:44
|
||||
error[E0277]: `V0isize` cannot be safely transmuted into `[usize; 2]`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:136:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0isize` is smaller than the size of `[usize; 2]`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -394,19 +394,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0usize` in the defining scope of `nsize::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:152:44
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0usize`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:142:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u8` is smaller than the size of `V0usize`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -416,19 +416,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0usize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:154:44
|
||||
error[E0277]: `V0usize` cannot be safely transmuted into `[usize; 2]`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:144:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0usize` is smaller than the size of `[usize; 2]`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: true,
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `void::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:28:52
|
||||
error[E0277]: `void::repr_rust` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:27:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `void::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:14:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -20,19 +20,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `void::repr_rust` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:29:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `void::repr_rust`
|
||||
--> $DIR/should_require_well_defined_layout.rs:28:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `void::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:14:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -42,19 +42,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `singleton::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:34:52
|
||||
error[E0277]: `singleton::repr_rust` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:33:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `singleton::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:14:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -64,19 +64,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `singleton::repr_rust` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:35:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `singleton::repr_rust`
|
||||
--> $DIR/should_require_well_defined_layout.rs:34:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `singleton::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:14:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -86,19 +86,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `duplex::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:40:52
|
||||
error[E0277]: `duplex::repr_rust` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:39:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `duplex::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:14:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -108,19 +108,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `duplex::repr_rust` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:41:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `duplex::repr_rust`
|
||||
--> $DIR/should_require_well_defined_layout.rs:40:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `duplex::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:14:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume::ALIGNMENT
|
||||
.and(Assume::LIFETIMES)
|
||||
.and(Assume::SAFETY)
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
|
||||
pub fn is_transmutable<Src, Dst, Context>()
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume::ALIGNMENT
|
||||
.and(Assume::LIFETIMES)
|
||||
.and(Assume::SAFETY)
|
||||
|
@ -38,8 +38,7 @@ enum Lopsided {
|
|||
#[repr(C)] struct Dst(Lopsided, V2);
|
||||
|
||||
fn should_pad_variants() {
|
||||
struct Context;
|
||||
// If the implementation (incorrectly) fails to pad `Lopsided::Smol` with
|
||||
// an uninitialized byte, this transmutation might be (wrongly) accepted:
|
||||
assert::is_transmutable::<Src, Dst, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Src, Dst>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`
|
||||
--> $DIR/should_pad_variants.rs:44:36
|
||||
error[E0277]: `Src` cannot be safely transmuted into `Dst`
|
||||
--> $DIR/should_pad_variants.rs:43:36
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context>();
|
||||
LL | assert::is_transmutable::<Src, Dst>();
|
||||
| ^^^ The size of `Src` is smaller than the size of `Dst`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/should_pad_variants.rs:13:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume::ALIGNMENT
|
||||
.and(Assume::LIFETIMES)
|
||||
.and(Assume::SAFETY)
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `Src` cannot be safely transmuted into `Unexpected` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_respect_endianness.rs:36:36
|
||||
error[E0277]: `Src` cannot be safely transmuted into `Unexpected`
|
||||
--> $DIR/should_respect_endianness.rs:35:36
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Unexpected>();
|
||||
| ^^^^^^^^^^ At least one value of `Src` isn't a bit-valid value of `Unexpected`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/should_respect_endianness.rs:14:14
|
||||
--> $DIR/should_respect_endianness.rs:13:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
|
||||
pub fn is_transmutable<Src, Context, const ASSUME_ALIGNMENT: bool>()
|
||||
pub fn is_transmutable<Src, const ASSUME_ALIGNMENT: bool>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME_ALIGNMENT>, //~ ERROR cannot find type `Dst` in this scope
|
||||
Dst: BikeshedIntrinsicFrom<Src, ASSUME_ALIGNMENT>, //~ ERROR cannot find type `Dst` in this scope
|
||||
//~^ the constant `ASSUME_ALIGNMENT` is not of type `Assume`
|
||||
//~| ERROR: mismatched types
|
||||
{
|
||||
|
@ -13,10 +13,9 @@ mod assert {
|
|||
}
|
||||
|
||||
fn via_const() {
|
||||
struct Context;
|
||||
struct Src;
|
||||
|
||||
assert::is_transmutable::<Src, Context, false>();
|
||||
assert::is_transmutable::<Src, false>();
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
error[E0412]: cannot find type `Dst` in this scope
|
||||
--> $DIR/issue-101739-1.rs:8:9
|
||||
|
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME_ALIGNMENT>,
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, ASSUME_ALIGNMENT>,
|
||||
| ^^^ not found in this scope
|
||||
|
||||
error: the constant `ASSUME_ALIGNMENT` is not of type `Assume`
|
||||
--> $DIR/issue-101739-1.rs:8:14
|
||||
|
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME_ALIGNMENT>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, ASSUME_ALIGNMENT>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
|
||||
|
|
||||
note: required by a bound in `BikeshedIntrinsicFrom`
|
||||
--> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-101739-1.rs:8:50
|
||||
--> $DIR/issue-101739-1.rs:8:41
|
||||
|
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME_ALIGNMENT>,
|
||||
| ^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, ASSUME_ALIGNMENT>,
|
||||
| ^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -8,17 +8,15 @@ mod assert {
|
|||
pub fn is_transmutable<
|
||||
Src,
|
||||
Dst,
|
||||
Context,
|
||||
const ASSUME_ALIGNMENT: bool,
|
||||
const ASSUME_LIFETIMES: bool,
|
||||
const ASSUME_VALIDITY: bool,
|
||||
const ASSUME_VISIBILITY: bool,
|
||||
>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom< //~ ERROR trait takes at most 3 generic arguments but 6 generic arguments were supplied
|
||||
Dst: BikeshedIntrinsicFrom< //~ ERROR trait takes at most 2 generic arguments but 5 generic arguments were supplied
|
||||
//~^ ERROR: the constant `ASSUME_ALIGNMENT` is not of type `Assume`
|
||||
Src,
|
||||
Context,
|
||||
ASSUME_ALIGNMENT, //~ ERROR: mismatched types
|
||||
ASSUME_LIFETIMES,
|
||||
ASSUME_VALIDITY,
|
||||
|
@ -28,11 +26,10 @@ mod assert {
|
|||
}
|
||||
|
||||
fn via_const() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst;
|
||||
|
||||
const FALSE: bool = false;
|
||||
|
||||
assert::is_transmutable::<Src, Dst, Context, FALSE, FALSE, FALSE, FALSE>();
|
||||
assert::is_transmutable::<Src, Dst, FALSE, FALSE, FALSE, FALSE>();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error[E0107]: trait takes at most 3 generic arguments but 6 generic arguments were supplied
|
||||
--> $DIR/issue-101739-2.rs:18:14
|
||||
error[E0107]: trait takes at most 2 generic arguments but 5 generic arguments were supplied
|
||||
--> $DIR/issue-101739-2.rs:17:14
|
||||
|
|
||||
LL | Dst: BikeshedIntrinsicFrom<
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected at most 3 generic arguments
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected at most 2 generic arguments
|
||||
...
|
||||
LL | / ASSUME_LIFETIMES,
|
||||
LL | | ASSUME_VALIDITY,
|
||||
|
@ -10,13 +10,13 @@ LL | | ASSUME_VISIBILITY,
|
|||
| |_____________________________- help: remove these generic arguments
|
||||
|
||||
error: the constant `ASSUME_ALIGNMENT` is not of type `Assume`
|
||||
--> $DIR/issue-101739-2.rs:18:14
|
||||
--> $DIR/issue-101739-2.rs:17:14
|
||||
|
|
||||
LL | Dst: BikeshedIntrinsicFrom<
|
||||
| ______________^
|
||||
LL | |
|
||||
LL | | Src,
|
||||
LL | | Context,
|
||||
LL | | ASSUME_ALIGNMENT,
|
||||
... |
|
||||
LL | | ASSUME_VISIBILITY,
|
||||
LL | | >,
|
||||
|
@ -26,7 +26,7 @@ note: required by a bound in `BikeshedIntrinsicFrom`
|
|||
--> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-101739-2.rs:22:13
|
||||
--> $DIR/issue-101739-2.rs:20:13
|
||||
|
|
||||
LL | ASSUME_ALIGNMENT,
|
||||
| ^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
#![crate_type = "lib"]
|
||||
#![feature(transmutability)]
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context>,
|
||||
Dst: BikeshedIntrinsicFrom<Src>,
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ mod assert {
|
|||
pub fn is_transmutable<
|
||||
Src,
|
||||
Dst,
|
||||
Context,
|
||||
const ASSUME_ALIGNMENT: bool,
|
||||
const ASSUME_LIFETIMES: bool,
|
||||
const ASSUME_SAFETY: bool,
|
||||
|
@ -17,7 +16,6 @@ mod assert {
|
|||
where
|
||||
Dst: BikeshedIntrinsicFrom<
|
||||
Src,
|
||||
Context,
|
||||
{ from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
|
||||
>,
|
||||
{}
|
||||
|
@ -32,9 +30,8 @@ mod assert {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst;
|
||||
|
||||
assert::is_transmutable::<Src, Dst, Context, false, false, { true }, false>();
|
||||
assert::is_transmutable::<Src, Dst, false, false, { true }, false>();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
error: expected parameter name, found `,`
|
||||
--> $DIR/issue-110892.rs:25:9
|
||||
|
|
||||
LL | ,
|
||||
| ^ expected parameter name
|
||||
|
||||
error: expected parameter name, found `,`
|
||||
--> $DIR/issue-110892.rs:26:9
|
||||
|
|
||||
LL | ,
|
||||
| ^ expected parameter name
|
||||
|
||||
error: expected parameter name, found `,`
|
||||
--> $DIR/issue-110892.rs:27:9
|
||||
|
|
||||
|
@ -10,20 +22,8 @@ error: expected parameter name, found `,`
|
|||
LL | ,
|
||||
| ^ expected parameter name
|
||||
|
||||
error: expected parameter name, found `,`
|
||||
--> $DIR/issue-110892.rs:29:9
|
||||
|
|
||||
LL | ,
|
||||
| ^ expected parameter name
|
||||
|
||||
error: expected parameter name, found `,`
|
||||
--> $DIR/issue-110892.rs:30:9
|
||||
|
|
||||
LL | ,
|
||||
| ^ expected parameter name
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-110892.rs:31:10
|
||||
--> $DIR/issue-110892.rs:29:10
|
||||
|
|
||||
LL | const fn from_options(
|
||||
| ------------ implicitly returns `()` as its body has no tail or `return` expression
|
||||
|
|
|
@ -6,16 +6,14 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst, Context>()
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context>
|
||||
Dst: BikeshedIntrinsicFrom<Src>
|
||||
{}
|
||||
}
|
||||
|
||||
fn should_gracefully_handle_unknown_dst() {
|
||||
struct Context;
|
||||
struct Src;
|
||||
assert::is_transmutable::<Src, Dst, Context>(); //~ cannot find type
|
||||
assert::is_transmutable::<Src, Dst>(); //~ cannot find type
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
error[E0412]: cannot find type `Dst` in this scope
|
||||
--> $DIR/unknown_dst.rs:20:36
|
||||
--> $DIR/unknown_dst.rs:18:36
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context>();
|
||||
LL | assert::is_transmutable::<Src, Dst>();
|
||||
| ^^^ not found in this scope
|
||||
|
|
||||
help: you might be missing a type parameter
|
||||
|
|
|
@ -6,16 +6,14 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst, Context>()
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context>
|
||||
Dst: BikeshedIntrinsicFrom<Src>
|
||||
{}
|
||||
}
|
||||
|
||||
fn should_gracefully_handle_unknown_src() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Dst;
|
||||
assert::is_transmutable::<Src, Dst, Context>(); //~ cannot find type
|
||||
assert::is_transmutable::<Src, Dst>(); //~ cannot find type
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
error[E0412]: cannot find type `Src` in this scope
|
||||
--> $DIR/unknown_src.rs:20:31
|
||||
--> $DIR/unknown_src.rs:18:31
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context>();
|
||||
LL | assert::is_transmutable::<Src, Dst>();
|
||||
| ^^^ not found in this scope
|
||||
|
|
||||
help: you might be missing a type parameter
|
||||
|
|
|
@ -6,17 +6,15 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst, Context>()
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context>
|
||||
Dst: BikeshedIntrinsicFrom<Src>
|
||||
{}
|
||||
}
|
||||
|
||||
fn should_gracefully_handle_unknown_dst_field() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst(Missing); //~ cannot find type
|
||||
assert::is_transmutable::<Src, Dst, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Src, Dst>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
error[E0412]: cannot find type `Missing` in this scope
|
||||
--> $DIR/unknown_src_field.rs:20:27
|
||||
--> $DIR/unknown_src_field.rs:18:27
|
||||
|
|
||||
LL | #[repr(C)] struct Dst(Missing);
|
||||
| ^^^^^^^ not found in this scope
|
||||
|
||||
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_gracefully_handle_unknown_dst_field::Context`
|
||||
--> $DIR/unknown_src_field.rs:21:36
|
||||
error[E0277]: `Src` cannot be safely transmuted into `Dst`
|
||||
--> $DIR/unknown_src_field.rs:19:36
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context>();
|
||||
LL | assert::is_transmutable::<Src, Dst>();
|
||||
| ^^^ `Dst` has an unknown layout
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/unknown_src_field.rs:13:14
|
||||
--> $DIR/unknown_src_field.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ mod assert {
|
|||
pub fn is_transmutable<
|
||||
Src,
|
||||
Dst,
|
||||
Context,
|
||||
const ASSUME_ALIGNMENT: bool,
|
||||
const ASSUME_LIFETIMES: bool,
|
||||
const ASSUME_SAFETY: bool,
|
||||
|
@ -22,7 +21,6 @@ mod assert {
|
|||
where
|
||||
Dst: BikeshedIntrinsicFrom<
|
||||
Src,
|
||||
Context,
|
||||
{ from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
|
||||
>,
|
||||
{}
|
||||
|
@ -43,11 +41,10 @@ mod assert {
|
|||
}
|
||||
|
||||
fn test() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst;
|
||||
assert::is_transmutable::<Src, Dst, Context, {0u8}, false, false, false>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, Context, false, {0u8}, false, false>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, Context, false, false, {0u8}, false>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, Context, false, false, false, {0u8}>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, {0u8}, false, false, false>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, false, {0u8}, false, false>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, false, false, {0u8}, false>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, false, false, false, {0u8}>(); //~ ERROR mismatched types
|
||||
}
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/wrong-type-assume.rs:49:51
|
||||
--> $DIR/wrong-type-assume.rs:46:42
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context, {0u8}, false, false, false>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
LL | assert::is_transmutable::<Src, Dst, {0u8}, false, false, false>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/wrong-type-assume.rs:50:58
|
||||
--> $DIR/wrong-type-assume.rs:47:49
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context, false, {0u8}, false, false>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
LL | assert::is_transmutable::<Src, Dst, false, {0u8}, false, false>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/wrong-type-assume.rs:51:65
|
||||
--> $DIR/wrong-type-assume.rs:48:56
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context, false, false, {0u8}, false>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
LL | assert::is_transmutable::<Src, Dst, false, false, {0u8}, false>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/wrong-type-assume.rs:52:72
|
||||
--> $DIR/wrong-type-assume.rs:49:63
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context, false, false, false, {0u8}>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
LL | assert::is_transmutable::<Src, Dst, false, false, false, {0u8}>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
#![feature(transmutability)]
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
{}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`
|
||||
--> $DIR/bool-mut.rs:16:50
|
||||
error[E0277]: `u8` cannot be safely transmuted into `bool`
|
||||
--> $DIR/bool-mut.rs:15:50
|
||||
|
|
||||
LL | assert::is_transmutable::<&'static mut bool, &'static mut u8>()
|
||||
| ^^^^^^^^^^^^^^^ At least one value of `u8` isn't a bit-valid value of `bool`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/bool-mut.rs:11:14
|
||||
--> $DIR/bool-mut.rs:10:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`
|
||||
--> $DIR/bool.rs:21:35
|
||||
error[E0277]: `u8` cannot be safely transmuted into `bool`
|
||||
--> $DIR/bool.rs:20:35
|
||||
|
|
||||
LL | assert::is_transmutable::<u8, bool>();
|
||||
| ^^^^ At least one value of `u8` isn't a bit-valid value of `bool`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/bool.rs:11:14
|
||||
--> $DIR/bool.rs:10:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`
|
||||
--> $DIR/bool.rs:21:35
|
||||
error[E0277]: `u8` cannot be safely transmuted into `bool`
|
||||
--> $DIR/bool.rs:20:35
|
||||
|
|
||||
LL | assert::is_transmutable::<u8, bool>();
|
||||
| ^^^^ At least one value of `u8` isn't a bit-valid value of `bool`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/bool.rs:11:14
|
||||
--> $DIR/bool.rs:10:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -4,16 +4,15 @@
|
|||
#![feature(transmutability)]
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
{}
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY.and(Assume::VALIDITY) }>
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY.and(Assume::VALIDITY) }>
|
||||
{}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -8,11 +8,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context>
|
||||
Dst: BikeshedIntrinsicFrom<Src>
|
||||
{}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context`
|
||||
--> $DIR/unit.rs:31:35
|
||||
error[E0277]: `()` cannot be safely transmuted into `u8`
|
||||
--> $DIR/unit.rs:30:35
|
||||
|
|
||||
LL | assert::is_transmutable::<(), u8, Context>();
|
||||
LL | assert::is_transmutable::<(), u8>();
|
||||
| ^^ The size of `()` is smaller than the size of `u8`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/unit.rs:15:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context`
|
||||
--> $DIR/unit.rs:31:35
|
||||
error[E0277]: `()` cannot be safely transmuted into `u8`
|
||||
--> $DIR/unit.rs:30:35
|
||||
|
|
||||
LL | assert::is_transmutable::<(), u8, Context>();
|
||||
LL | assert::is_transmutable::<(), u8>();
|
||||
| ^^ The size of `()` is smaller than the size of `u8`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/unit.rs:15:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
|
||||
pub fn is_transmutable<Src, Dst, Context>()
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume::ALIGNMENT
|
||||
.and(Assume::LIFETIMES)
|
||||
.and(Assume::SAFETY)
|
||||
|
@ -25,8 +25,7 @@ mod assert {
|
|||
struct Zst;
|
||||
|
||||
fn should_have_correct_size() {
|
||||
struct Context;
|
||||
assert::is_transmutable::<(), Zst, Context>();
|
||||
assert::is_transmutable::<Zst, (), Context>();
|
||||
assert::is_transmutable::<(), u8, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<(), Zst>();
|
||||
assert::is_transmutable::<Zst, ()>();
|
||||
assert::is_transmutable::<(), u8>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: false,
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `&A` cannot be safely transmuted into `&mut B` in the defining scope of `assert::Context`
|
||||
--> $DIR/recursive-wrapper-types-bit-compatible-mut.rs:24:49
|
||||
error[E0277]: `&A` cannot be safely transmuted into `&mut B`
|
||||
--> $DIR/recursive-wrapper-types-bit-compatible-mut.rs:23:49
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<&'static A, &'static mut B>();
|
||||
| ^^^^^^^^^^^^^^ `&A` is a shared reference, but `&mut B` is a unique reference
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/recursive-wrapper-types-bit-compatible-mut.rs:10:14
|
||||
--> $DIR/recursive-wrapper-types-bit-compatible-mut.rs:9:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: false,
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: false,
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`
|
||||
--> $DIR/recursive-wrapper-types-bit-incompatible.rs:24:49
|
||||
error[E0277]: `B` cannot be safely transmuted into `A`
|
||||
--> $DIR/recursive-wrapper-types-bit-incompatible.rs:23:49
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<&'static B, &'static A>();
|
||||
| ^^^^^^^^^^ At least one value of `B` isn't a bit-valid value of `A`
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/recursive-wrapper-types-bit-incompatible.rs:10:14
|
||||
--> $DIR/recursive-wrapper-types-bit-incompatible.rs:9:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: false,
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: false,
|
||||
lifetimes: true,
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: false,
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: true,
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `Unit` cannot be safely transmuted into `u8` in the defining scope of `assert::Context`
|
||||
--> $DIR/unit-to-u8.rs:23:52
|
||||
error[E0277]: `Unit` cannot be safely transmuted into `u8`
|
||||
--> $DIR/unit-to-u8.rs:22:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<&'static Unit, &'static u8>();
|
||||
| ^^^^^^^^^^^ The size of `Unit` is smaller than the size of `u8`
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/unit-to-u8.rs:10:14
|
||||
--> $DIR/unit-to-u8.rs:9:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#![feature(transmutability)]
|
||||
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
#[repr(C)]
|
||||
struct W<'a>(&'a ());
|
||||
|
@ -10,7 +9,6 @@ fn test<'a>()
|
|||
where
|
||||
W<'a>: BikeshedIntrinsicFrom<
|
||||
(),
|
||||
Context,
|
||||
{ Assume { alignment: true, lifetimes: true, safety: true, validity: true } },
|
||||
>,
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0277]: `()` cannot be safely transmuted into `W<'_>` in the defining scope of `Context`
|
||||
--> $DIR/region-infer.rs:20:5
|
||||
error[E0277]: `()` cannot be safely transmuted into `W<'_>`
|
||||
--> $DIR/region-infer.rs:18:5
|
||||
|
|
||||
LL | test();
|
||||
| ^^^^^^ The size of `()` is smaller than the size of `W<'_>`
|
||||
|
|
||||
note: required by a bound in `test`
|
||||
--> $DIR/region-infer.rs:11:12
|
||||
--> $DIR/region-infer.rs:10:12
|
||||
|
|
||||
LL | fn test<'a>()
|
||||
| ---- required by a bound in this function
|
||||
|
@ -13,7 +13,6 @@ LL | where
|
|||
LL | W<'a>: BikeshedIntrinsicFrom<
|
||||
| ____________^
|
||||
LL | | (),
|
||||
LL | | Context,
|
||||
LL | | { Assume { alignment: true, lifetimes: true, safety: true, validity: true } },
|
||||
LL | | >,
|
||||
| |_________^ required by this bound in `test`
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
//@ check-pass
|
||||
|
||||
//! When safety is assumed, a transmutation should be accepted if the
|
||||
//! destination type might carry a safety invariant.
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(transmutability)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
{}
|
||||
}
|
||||
|
||||
fn test() {
|
||||
type Src = ();
|
||||
#[repr(C)]
|
||||
struct Dst;
|
||||
assert::is_transmutable::<Src, Dst>();
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
//@ check-pass
|
||||
|
||||
//! When safety is assumed, a transmutation over exclusive references should be
|
||||
//! accepted if the source type potentially carries safety invariants.
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(transmutability)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
{}
|
||||
}
|
||||
|
||||
fn test() {
|
||||
#[repr(C)]
|
||||
struct Src {
|
||||
non_zero: u8,
|
||||
}
|
||||
type Dst = u8;
|
||||
assert::is_transmutable::<&mut Src, &mut Dst>();
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
//@ check-pass
|
||||
|
||||
//! The presence of safety invariants in the source type does not affect
|
||||
//! transmutability.
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(transmutability)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
{}
|
||||
}
|
||||
|
||||
fn test() {
|
||||
#[repr(C)]
|
||||
struct Src;
|
||||
type Dst = ();
|
||||
assert::is_transmutable::<Src, Dst>();
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
//@ check-pass
|
||||
|
||||
//! The presence of safety invariants in the source type does not affect
|
||||
//! transmutability.
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(transmutability)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src> // safety is NOT assumed
|
||||
{}
|
||||
}
|
||||
|
||||
fn test() {
|
||||
#[repr(C)]
|
||||
struct Src;
|
||||
type Dst = ();
|
||||
assert::is_transmutable::<Src, Dst>();
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
//! Unless safety is assumed, a transmutation should be rejected if the
|
||||
//! destination type may have a safety invariant.
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(transmutability)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src> // safety is NOT assumed
|
||||
{}
|
||||
}
|
||||
|
||||
fn test() {
|
||||
type Src = ();
|
||||
#[repr(C)]
|
||||
struct Dst;
|
||||
assert::is_transmutable::<Src, Dst>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
error[E0277]: `()` cannot be safely transmuted into `Dst`
|
||||
--> $DIR/should_reject_if_dst_has_safety_invariant.rs:21:36
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst>();
|
||||
| ^^^ `Dst` may carry safety invariants
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/should_reject_if_dst_has_safety_invariant.rs:13:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src> // safety is NOT assumed
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
|
@ -0,0 +1,24 @@
|
|||
//! Unless safety is assumed, a transmutation over exclusive references should
|
||||
//! be rejected if the source potentially carries safety invariants.
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(transmutability)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src> // safety is NOT assumed
|
||||
{}
|
||||
}
|
||||
|
||||
fn test() {
|
||||
#[repr(C)]
|
||||
struct Src {
|
||||
non_zero: u8,
|
||||
}
|
||||
type Dst = u8;
|
||||
assert::is_transmutable::<&mut Src, &mut Dst>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
error[E0277]: `u8` cannot be safely transmuted into `Src`
|
||||
--> $DIR/should_reject_if_ref_src_has_safety_invariant.rs:23:41
|
||||
|
|
||||
LL | assert::is_transmutable::<&mut Src, &mut Dst>();
|
||||
| ^^^^^^^^ `Src` may carry safety invariants
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/should_reject_if_ref_src_has_safety_invariant.rs:13:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src> // safety is NOT assumed
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: true,
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: true,
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: true,
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `should_reject_repr_rust::unit::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:28:52
|
||||
error[E0277]: `should_reject_repr_rust::unit::repr_rust` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:27:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `should_reject_repr_rust::unit::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -20,19 +20,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::unit::repr_rust` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:29:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::unit::repr_rust`
|
||||
--> $DIR/should_require_well_defined_layout.rs:28:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `should_reject_repr_rust::unit::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -42,19 +42,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `should_reject_repr_rust::tuple::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:34:52
|
||||
error[E0277]: `should_reject_repr_rust::tuple::repr_rust` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:33:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `should_reject_repr_rust::tuple::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -64,19 +64,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::tuple::repr_rust` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:35:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::tuple::repr_rust`
|
||||
--> $DIR/should_require_well_defined_layout.rs:34:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `should_reject_repr_rust::tuple::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -86,19 +86,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `should_reject_repr_rust::braces::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:40:52
|
||||
error[E0277]: `should_reject_repr_rust::braces::repr_rust` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:39:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `should_reject_repr_rust::braces::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -108,19 +108,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::braces::repr_rust` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:41:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::braces::repr_rust`
|
||||
--> $DIR/should_require_well_defined_layout.rs:40:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `should_reject_repr_rust::braces::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -130,19 +130,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `aligned::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:46:52
|
||||
error[E0277]: `aligned::repr_rust` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:45:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `aligned::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -152,19 +152,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `aligned::repr_rust` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:47:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `aligned::repr_rust`
|
||||
--> $DIR/should_require_well_defined_layout.rs:46:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `aligned::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -174,19 +174,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `packed::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:52:52
|
||||
error[E0277]: `packed::repr_rust` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:51:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `packed::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -196,19 +196,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `packed::repr_rust` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:53:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `packed::repr_rust`
|
||||
--> $DIR/should_require_well_defined_layout.rs:52:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `packed::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -218,19 +218,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `nested::repr_c` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:59:49
|
||||
error[E0277]: `nested::repr_c` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:58:49
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_c, ()>();
|
||||
| ^^ `nested::repr_c` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -240,19 +240,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `nested::repr_c` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:60:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `nested::repr_c`
|
||||
--> $DIR/should_require_well_defined_layout.rs:59:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_c>();
|
||||
| ^^^^^^ `nested::repr_c` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
|
|
@ -8,11 +8,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context>,
|
||||
Dst: BikeshedIntrinsicFrom<Src>,
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0072]: recursive type `ExplicitlyPadded` has infinite size
|
||||
--> $DIR/transmute_infinitely_recursive_type.rs:22:5
|
||||
--> $DIR/transmute_infinitely_recursive_type.rs:21:5
|
||||
|
|
||||
LL | struct ExplicitlyPadded(ExplicitlyPadded);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ ---------------- recursive without indirection
|
||||
|
@ -12,7 +12,7 @@ LL | struct ExplicitlyPadded(Box<ExplicitlyPadded>);
|
|||
error[E0391]: cycle detected when computing layout of `should_pad_explicitly_packed_field::ExplicitlyPadded`
|
||||
|
|
||||
= note: ...which immediately requires computing layout of `should_pad_explicitly_packed_field::ExplicitlyPadded` again
|
||||
= note: cycle used when evaluating trait selection obligation `(): core::mem::transmutability::BikeshedIntrinsicFrom<should_pad_explicitly_packed_field::ExplicitlyPadded, assert::Context, core::mem::transmutability::Assume { alignment: false, lifetimes: false, safety: false, validity: false }>`
|
||||
= note: cycle used when evaluating trait selection obligation `(): core::mem::transmutability::BikeshedIntrinsicFrom<should_pad_explicitly_packed_field::ExplicitlyPadded, core::mem::transmutability::Assume { alignment: false, lifetimes: false, safety: false, validity: false }>`
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume::ALIGNMENT
|
||||
.and(Assume::LIFETIMES)
|
||||
.and(Assume::SAFETY)
|
||||
|
|
|
@ -4,13 +4,11 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<
|
||||
Src,
|
||||
Context,
|
||||
{ Assume { alignment: true, lifetimes: true, safety: true, validity: true } },
|
||||
>,
|
||||
{
|
|
@ -1,11 +1,11 @@
|
|||
error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`
|
||||
--> $DIR/transmute-padding-ice.rs:27:40
|
||||
error[E0277]: `B` cannot be safely transmuted into `A`
|
||||
--> $DIR/transmute-padding-ice.rs:25:40
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<B, A>();
|
||||
| ^ The size of `B` is smaller than the size of `A`
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/transmute-padding-ice.rs:11:14
|
||||
--> $DIR/transmute-padding-ice.rs:10:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
|
@ -13,7 +13,6 @@ LL | where
|
|||
LL | Dst: BikeshedIntrinsicFrom<
|
||||
| ______________^
|
||||
LL | | Src,
|
||||
LL | | Context,
|
||||
LL | | { Assume { alignment: true, lifetimes: true, safety: true, validity: true } },
|
||||
LL | | >,
|
||||
| |_________^ required by this bound in `is_maybe_transmutable`
|
|
@ -8,11 +8,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
{}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: true,
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: true,
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: true,
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `should_reject_repr_rust::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:30:48
|
||||
error[E0277]: `should_reject_repr_rust::repr_rust` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:29:48
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `should_reject_repr_rust::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -20,19 +20,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::repr_rust` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:31:43
|
||||
error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::repr_rust`
|
||||
--> $DIR/should_require_well_defined_layout.rs:30:43
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `should_reject_repr_rust::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
|
||||
pub fn is_transmutable<Src, Dst, Context>()
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume::ALIGNMENT
|
||||
.and(Assume::LIFETIMES)
|
||||
.and(Assume::SAFETY)
|
||||
|
@ -38,8 +38,7 @@ union Lopsided {
|
|||
#[repr(C)] struct Dst(V0, Lopsided, V2);
|
||||
|
||||
fn should_pad_variants() {
|
||||
struct Context;
|
||||
// If the implementation (incorrectly) fails to pad `Lopsided::smol` with
|
||||
// an uninitialized byte, this transmutation might be (wrongly) accepted:
|
||||
assert::is_transmutable::<Src, Dst, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Src, Dst>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`
|
||||
--> $DIR/should_pad_variants.rs:44:36
|
||||
error[E0277]: `Src` cannot be safely transmuted into `Dst`
|
||||
--> $DIR/should_pad_variants.rs:43:36
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context>();
|
||||
LL | assert::is_transmutable::<Src, Dst>();
|
||||
| ^^^ The size of `Src` is smaller than the size of `Dst`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/should_pad_variants.rs:13:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
|
|
@ -8,11 +8,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY.and(Assume::VALIDITY) }>
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY.and(Assume::VALIDITY) }>
|
||||
{}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
{}
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue