From 23ab1bda92b127b18f32fe7593298842fd25e05b Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Mon, 26 Feb 2024 16:49:25 +0000 Subject: [PATCH] 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 --- compiler/rustc_hir/src/lang_items.rs | 2 +- .../src/solve/eval_ctxt/mod.rs | 2 - .../src/solve/trait_goals.rs | 3 +- .../error_reporting/type_err_ctxt_ext.rs | 14 +- .../src/traits/select/confirmation.rs | 7 +- compiler/rustc_transmute/src/layout/mod.rs | 20 +- compiler/rustc_transmute/src/layout/tree.rs | 5 +- .../rustc_transmute/src/layout/tree/tests.rs | 69 ++- compiler/rustc_transmute/src/lib.rs | 6 +- .../src/maybe_transmutable/mod.rs | 67 +- .../src/maybe_transmutable/query_context.rs | 45 +- .../src/maybe_transmutable/tests.rs | 65 +- library/core/src/mem/transmutability.rs | 9 +- src/tools/tidy/src/issues.txt | 1 - .../abstraction/abstracted_assume.rs | 23 +- .../abstraction/const_generic_fn.rs | 5 +- .../transmutability/alignment/align-fail.rs | 3 +- .../alignment/align-fail.stderr | 8 +- .../transmutability/alignment/align-pass.rs | 3 +- .../arrays/huge-len.rs} | 3 +- .../arrays/huge-len.stderr} | 20 +- .../arrays/issue-103783-array-length.rs | 2 - .../arrays/issue-103783-array-length.stderr | 2 +- .../arrays/should_have_correct_length.rs | 3 +- .../arrays/should_inherit_alignment.rs | 3 +- .../should_require_well_defined_layout.rs | 3 +- .../should_require_well_defined_layout.stderr | 48 +- ...mitive_reprs_should_have_correct_length.rs | 74 +-- ...ve_reprs_should_have_correct_length.stderr | 200 +++--- .../should_require_well_defined_layout.rs | 3 +- .../should_require_well_defined_layout.stderr | 48 +- .../enums/should_order_correctly.rs | 3 +- .../enums/should_pad_variants.rs | 7 +- .../enums/should_pad_variants.stderr | 10 +- .../enums/should_respect_endianness.rs | 3 +- .../enums/should_respect_endianness.stderr | 8 +- tests/ui/transmutability/issue-101739-1.rs | 7 +- .../ui/transmutability/issue-101739-1.stderr | 12 +- tests/ui/transmutability/issue-101739-2.rs | 7 +- .../ui/transmutability/issue-101739-2.stderr | 12 +- tests/ui/transmutability/issue-110467.rs | 3 +- tests/ui/transmutability/issue-110892.rs | 5 +- tests/ui/transmutability/issue-110892.stderr | 10 +- .../unknown_dst.rs | 8 +- .../unknown_dst.stderr | 4 +- .../unknown_src.rs | 8 +- .../unknown_src.stderr | 4 +- .../unknown_src_field.rs | 8 +- .../unknown_src_field.stderr | 16 +- .../wrong-type-assume.rs | 11 +- .../wrong-type-assume.stderr | 24 +- .../ui/transmutability/primitives/bool-mut.rs | 3 +- .../primitives/bool-mut.stderr | 10 +- .../primitives/bool.current.stderr | 10 +- .../primitives/bool.next.stderr | 10 +- tests/ui/transmutability/primitives/bool.rs | 5 +- .../primitives/numbers.current.stderr | 570 +++++++++--------- .../primitives/numbers.next.stderr | 570 +++++++++--------- .../ui/transmutability/primitives/numbers.rs | 3 +- .../primitives/unit.current.stderr | 10 +- .../primitives/unit.next.stderr | 10 +- tests/ui/transmutability/primitives/unit.rs | 11 +- ...ursive-wrapper-types-bit-compatible-mut.rs | 3 +- ...ve-wrapper-types-bit-compatible-mut.stderr | 8 +- .../recursive-wrapper-types-bit-compatible.rs | 3 +- ...ecursive-wrapper-types-bit-incompatible.rs | 3 +- ...sive-wrapper-types-bit-incompatible.stderr | 8 +- .../references/recursive-wrapper-types.rs | 3 +- .../transmutability/references/u8-to-unit.rs | 3 +- .../references/unit-to-itself.rs | 3 +- .../transmutability/references/unit-to-u8.rs | 3 +- .../references/unit-to-u8.stderr | 8 +- tests/ui/transmutability/region-infer.rs | 2 - tests/ui/transmutability/region-infer.stderr | 7 +- ...ould_accept_if_dst_has_safety_invariant.rs | 24 + ..._accept_if_ref_src_has_safety_invariant.rs | 26 + ...ould_accept_if_src_has_safety_invariant.rs | 24 + ...ould_accept_if_src_has_safety_invariant.rs | 24 + ...ould_reject_if_dst_has_safety_invariant.rs | 22 + ..._reject_if_dst_has_safety_invariant.stderr | 18 + ..._reject_if_ref_src_has_safety_invariant.rs | 24 + ...ect_if_ref_src_has_safety_invariant.stderr | 18 + .../structs/repr/should_handle_align.rs | 3 +- .../structs/repr/should_handle_packed.rs | 3 +- .../should_require_well_defined_layout.rs | 3 +- .../should_require_well_defined_layout.stderr | 96 +-- .../transmute_infinitely_recursive_type.rs | 3 +- ...transmute_infinitely_recursive_type.stderr | 4 +- .../structs/should_order_fields_correctly.rs | 3 +- .../transmute-padding-ice.rs | 2 - .../transmute-padding-ice.stderr | 7 +- tests/ui/transmutability/unions/boolish.rs | 3 +- .../unions/repr/should_handle_align.rs | 3 +- .../unions/repr/should_handle_packed.rs | 3 +- .../should_require_well_defined_layout.rs | 3 +- .../should_require_well_defined_layout.stderr | 16 +- .../unions/should_pad_variants.rs | 7 +- .../unions/should_pad_variants.stderr | 10 +- ...mit_intersecting_if_validity_is_assumed.rs | 3 +- .../unions/should_reject_contraction.rs | 3 +- .../unions/should_reject_contraction.stderr | 10 +- .../unions/should_reject_disjoint.rs | 3 +- .../unions/should_reject_disjoint.stderr | 20 +- .../unions/should_reject_intersecting.rs | 5 +- .../unions/should_reject_intersecting.stderr | 20 +- .../should_accept_if_dst_has_private_field.rs | 38 -- ...hould_accept_if_dst_has_private_variant.rs | 39 -- ...ept_if_dst_has_tricky_unreachable_field.rs | 46 -- ...uld_accept_if_dst_has_unreachable_field.rs | 41 -- ...accept_if_dst_has_unreachable_field.stderr | 15 - ...should_accept_if_dst_has_unreachable_ty.rs | 40 -- ...ld_accept_if_dst_has_unreachable_ty.stderr | 15 - .../should_accept_if_src_has_private_field.rs | 37 -- ...hould_accept_if_src_has_private_variant.rs | 38 -- ...uld_accept_if_src_has_unreachable_field.rs | 39 -- ...accept_if_src_has_unreachable_field.stderr | 15 - ...should_accept_if_src_has_unreachable_ty.rs | 38 -- ...ld_accept_if_src_has_unreachable_ty.stderr | 15 - .../should_reject_if_dst_has_private_field.rs | 36 -- ...uld_reject_if_dst_has_private_field.stderr | 18 - ...hould_reject_if_dst_has_private_variant.rs | 37 -- ...d_reject_if_dst_has_private_variant.stderr | 18 - ...ect_if_dst_has_tricky_unreachable_field.rs | 51 -- ...uld_reject_if_dst_has_unreachable_field.rs | 38 -- ...reject_if_dst_has_unreachable_field.stderr | 18 - ...should_reject_if_dst_has_unreachable_ty.rs | 41 -- ...ld_reject_if_dst_has_unreachable_ty.stderr | 31 - 127 files changed, 1379 insertions(+), 1940 deletions(-) rename tests/ui/{transmute/issue-115402-overflow-size.rs => transmutability/arrays/huge-len.rs} (89%) rename tests/ui/{transmute/issue-115402-overflow-size.stderr => transmutability/arrays/huge-len.stderr} (63%) create mode 100644 tests/ui/transmutability/safety/assume/should_accept_if_dst_has_safety_invariant.rs create mode 100644 tests/ui/transmutability/safety/assume/should_accept_if_ref_src_has_safety_invariant.rs create mode 100644 tests/ui/transmutability/safety/assume/should_accept_if_src_has_safety_invariant.rs create mode 100644 tests/ui/transmutability/safety/should_accept_if_src_has_safety_invariant.rs create mode 100644 tests/ui/transmutability/safety/should_reject_if_dst_has_safety_invariant.rs create mode 100644 tests/ui/transmutability/safety/should_reject_if_dst_has_safety_invariant.stderr create mode 100644 tests/ui/transmutability/safety/should_reject_if_ref_src_has_safety_invariant.rs create mode 100644 tests/ui/transmutability/safety/should_reject_if_ref_src_has_safety_invariant.stderr rename tests/ui/{transmute => transmutability}/transmute-padding-ice.rs (92%) rename tests/ui/{transmute => transmutability}/transmute-padding-ice.stderr (77%) delete mode 100644 tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_field.rs delete mode 100644 tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_variant.rs delete mode 100644 tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_tricky_unreachable_field.rs delete mode 100644 tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs delete mode 100644 tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.stderr delete mode 100644 tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.rs delete mode 100644 tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.stderr delete mode 100644 tests/ui/transmutability/visibility/should_accept_if_src_has_private_field.rs delete mode 100644 tests/ui/transmutability/visibility/should_accept_if_src_has_private_variant.rs delete mode 100644 tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs delete mode 100644 tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr delete mode 100644 tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.rs delete mode 100644 tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.stderr delete mode 100644 tests/ui/transmutability/visibility/should_reject_if_dst_has_private_field.rs delete mode 100644 tests/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr delete mode 100644 tests/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.rs delete mode 100644 tests/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr delete mode 100644 tests/ui/transmutability/visibility/should_reject_if_dst_has_tricky_unreachable_field.rs delete mode 100644 tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.rs delete mode 100644 tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr delete mode 100644 tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.rs delete mode 100644 tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index 9c9e72d6e6512..8a89a3b5faa5e 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -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); diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs index ed428bb8e6629..df4dcaff1e714 100644 --- a/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs @@ -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 { 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), diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals.rs b/compiler/rustc_trait_selection/src/solve/trait_goals.rs index 73bf66f66890f..c309dcfb68769 100644 --- a/compiler/rustc_trait_selection/src/solve/trait_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/trait_goals.rs @@ -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) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs index 2b74b15ec9faa..ae3035cdcf576 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs @@ -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}`") } diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index d316149731e14..e4f1180703184 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -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, ); diff --git a/compiler/rustc_transmute/src/layout/mod.rs b/compiler/rustc_transmute/src/layout/mod.rs index 76d97e0e6e7a6..0441b49cb14c7 100644 --- a/compiler/rustc_transmute/src/layout/mod.rs +++ b/compiler/rustc_transmute/src/layout/mod.rs @@ -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 + } + } } diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs index 86a077ee808b6..71b72828e4cf5 100644 --- a/compiler/rustc_transmute/src/layout/tree.rs +++ b/compiler/rustc_transmute/src/layout/tree.rs @@ -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(self, f: &F) -> Tree 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() diff --git a/compiler/rustc_transmute/src/layout/tree/tests.rs b/compiler/rustc_transmute/src/layout/tree/tests.rs index 90515e92f7aef..3cb47517c2195 100644 --- a/compiler/rustc_transmute/src/layout/tree/tests.rs +++ b/compiler/rustc_transmute/src/layout/tree/tests.rs @@ -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 = 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 = + 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 = - Tree::from_bits(0x00).then(Tree::def(Def::Visible)).then(Tree::from_bits(0x01)); + let layout: Tree = 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 = Tree::def(Def::Invisible); - assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::uninhabited()); + let layout: Tree = 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 = Tree::def(Def::Visible).then(Tree::def(Def::Invisible)); - assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::uninhabited()); + let layout: Tree = + 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 = - 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 = 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 = Tree::def(Def::Visible); - assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::unit()); + let layout: Tree = 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 = Tree::def(Def::Visible).then(Tree::def(Def::Visible)); - assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::unit()); + let layout: Tree = + 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 = - 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 = 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) + ); } } } diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index ac4f67d1b5565..fefce2640ebd9 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -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::maybe_transmutable::MaybeTransmutableQuery::new( types.src, types.dst, - scope, assume, self.infcx.tcx, ) diff --git a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs index bf3c390c8008e..0e05aa4d3b2ac 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs @@ -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: ::Scope, assume: crate::Assume, context: C, } @@ -23,14 +22,8 @@ impl MaybeTransmutableQuery where C: QueryContext, { - pub(crate) fn new( - src: L, - dst: L, - scope: ::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< 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<::Ref> { - let assume_visibility = self.assume.safety; - - let Self { src, dst, scope, assume, context } = self; + let Self { src, dst, 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<::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() } } diff --git a/compiler/rustc_transmute/src/maybe_transmutable/query_context.rs b/compiler/rustc_transmute/src/maybe_transmutable/query_context.rs index 0cae0377ee8c0..54ed03d44e639 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/query_context.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/query_context.rs @@ -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!() } diff --git a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs index e49bebf571dea..9c7abf1cbd636 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs @@ -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; + + 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::::bool(), layout::Tree::::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, ) diff --git a/library/core/src/mem/transmutability.rs b/library/core/src/mem/transmutability.rs index f5cc86e7767e8..0687874a2582a 100644 --- a/library/core/src/mem/transmutability.rs +++ b/library/core/src/mem/transmutability.rs @@ -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 +pub unsafe trait BikeshedIntrinsicFrom 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 diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt index 51af8898470b3..193be94796ec4 100644 --- a/src/tools/tidy/src/issues.txt +++ b/src/tools/tidy/src/issues.txt @@ -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", diff --git a/tests/ui/transmutability/abstraction/abstracted_assume.rs b/tests/ui/transmutability/abstraction/abstracted_assume.rs index 0e62dc632bf52..897e1b4b50af3 100644 --- a/tests/ui/transmutability/abstraction/abstracted_assume.rs +++ b/tests/ui/transmutability/abstraction/abstracted_assume.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::(); + 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::(); + 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}, diff --git a/tests/ui/transmutability/abstraction/const_generic_fn.rs b/tests/ui/transmutability/abstraction/const_generic_fn.rs index 076b7c8999be2..0a5f0de02148c 100644 --- a/tests/ui/transmutability/abstraction/const_generic_fn.rs +++ b/tests/ui/transmutability/abstraction/const_generic_fn.rs @@ -7,12 +7,11 @@ mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn array_like() where - T: BikeshedIntrinsicFrom<[E; N], Context, { Assume::SAFETY }>, - [E; N]: BikeshedIntrinsicFrom + T: BikeshedIntrinsicFrom<[E; N], { Assume::SAFETY }>, + [E; N]: BikeshedIntrinsicFrom {} } diff --git a/tests/ui/transmutability/alignment/align-fail.rs b/tests/ui/transmutability/alignment/align-fail.rs index 2bb6bfeeaae16..d88f1285c1183 100644 --- a/tests/ui/transmutability/alignment/align-fail.rs +++ b/tests/ui/transmutability/alignment/align-fail.rs @@ -3,11 +3,10 @@ mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom $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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom, + Dst: BikeshedIntrinsicFrom, { } } diff --git a/tests/ui/transmute/issue-115402-overflow-size.stderr b/tests/ui/transmutability/arrays/huge-len.stderr similarity index 63% rename from tests/ui/transmute/issue-115402-overflow-size.stderr rename to tests/ui/transmutability/arrays/huge-len.stderr index 08d180f6427ea..37160c5c9596b 100644 --- a/tests/ui/transmute/issue-115402-overflow-size.stderr +++ b/tests/ui/transmutability/arrays/huge-len.stderr @@ -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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | Dst: BikeshedIntrinsicFrom, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 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::(); | ^^ 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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | Dst: BikeshedIntrinsicFrom, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` error: aborting due to 2 previous errors diff --git a/tests/ui/transmutability/arrays/issue-103783-array-length.rs b/tests/ui/transmutability/arrays/issue-103783-array-length.rs index cb36e539ed11a..7fcbcc0107563 100644 --- a/tests/ui/transmutability/arrays/issue-103783-array-length.rs +++ b/tests/ui/transmutability/arrays/issue-103783-array-length.rs @@ -4,13 +4,11 @@ mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_maybe_transmutable() where Dst: BikeshedIntrinsicFrom< Src, - Context, { Assume { alignment: true, lifetimes: true, safety: true, validity: true } }, >, { diff --git a/tests/ui/transmutability/arrays/issue-103783-array-length.stderr b/tests/ui/transmutability/arrays/issue-103783-array-length.stderr index 2c581664f3952..02ac40741cb7f 100644 --- a/tests/ui/transmutability/arrays/issue-103783-array-length.stderr +++ b/tests/ui/transmutability/arrays/issue-103783-array-length.stderr @@ -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 diff --git a/tests/ui/transmutability/arrays/should_have_correct_length.rs b/tests/ui/transmutability/arrays/should_have_correct_length.rs index 44a60360014cb..747897d49d78d 100644 --- a/tests/ui/transmutability/arrays/should_have_correct_length.rs +++ b/tests/ui/transmutability/arrays/should_have_correct_length.rs @@ -7,11 +7,10 @@ mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/tests/ui/transmutability/arrays/should_inherit_alignment.rs b/tests/ui/transmutability/arrays/should_inherit_alignment.rs index bb78cd82a3439..d95c51e3361be 100644 --- a/tests/ui/transmutability/arrays/should_inherit_alignment.rs +++ b/tests/ui/transmutability/arrays/should_inherit_alignment.rs @@ -7,11 +7,10 @@ mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom $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::(); | ^^ `[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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^^^^^^^^ `[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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^ `[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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^^^^^^^^ `[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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^ `[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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^^^^^^^^ `[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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom() + pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted } fn u_should_have_correct_length() { type Current = V0u8; - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); + assert::is_transmutable::(); //~ 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::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted } fn u_should_have_correct_length() { type Current = V0u16; - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); + assert::is_transmutable::(); //~ 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::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted } fn u_should_have_correct_length() { type Current = V0u32; - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); + assert::is_transmutable::(); //~ 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::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted } fn u_should_have_correct_length() { type Current = V0u64; - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); + assert::is_transmutable::(); //~ 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::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted } fn u_should_have_correct_length() { type Current = V0usize; - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted } } diff --git a/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr b/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr index 46cdaa925630a..b2ff04eeed9e4 100644 --- a/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr +++ b/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr @@ -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::(); +LL | assert::is_transmutable::(); | ^^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); +LL | assert::is_transmutable::(); | ^^^^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom $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::(); | ^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^^^^^^^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^^^^^^^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^^^^^^^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom() + pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted } diff --git a/tests/ui/transmutability/enums/should_pad_variants.stderr b/tests/ui/transmutability/enums/should_pad_variants.stderr index fd98e355fb915..13b4c8053adb2 100644 --- a/tests/ui/transmutability/enums/should_pad_variants.stderr +++ b/tests/ui/transmutability/enums/should_pad_variants.stderr @@ -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::(); +LL | assert::is_transmutable::(); | ^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom $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::(); | ^^^^^^^^^^ 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() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom() + pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom, //~ ERROR cannot find type `Dst` in this scope + Dst: BikeshedIntrinsicFrom, //~ 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::(); + assert::is_transmutable::(); } fn main() {} diff --git a/tests/ui/transmutability/issue-101739-1.stderr b/tests/ui/transmutability/issue-101739-1.stderr index e87693f247d36..1df7c3e2f9744 100644 --- a/tests/ui/transmutability/issue-101739-1.stderr +++ b/tests/ui/transmutability/issue-101739-1.stderr @@ -1,23 +1,23 @@ error[E0412]: cannot find type `Dst` in this scope --> $DIR/issue-101739-1.rs:8:9 | -LL | Dst: BikeshedIntrinsicFrom, +LL | Dst: BikeshedIntrinsicFrom, | ^^^ 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, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `bool` +LL | Dst: BikeshedIntrinsicFrom, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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, - | ^^^^^^^^^^^^^^^^ expected `Assume`, found `bool` +LL | Dst: BikeshedIntrinsicFrom, + | ^^^^^^^^^^^^^^^^ expected `Assume`, found `bool` error: aborting due to 3 previous errors diff --git a/tests/ui/transmutability/issue-101739-2.rs b/tests/ui/transmutability/issue-101739-2.rs index 8d670ec17ca9a..e2cec24aac147 100644 --- a/tests/ui/transmutability/issue-101739-2.rs +++ b/tests/ui/transmutability/issue-101739-2.rs @@ -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::(); + assert::is_transmutable::(); } diff --git a/tests/ui/transmutability/issue-101739-2.stderr b/tests/ui/transmutability/issue-101739-2.stderr index adbb5ff5aff03..639b446089248 100644 --- a/tests/ui/transmutability/issue-101739-2.stderr +++ b/tests/ui/transmutability/issue-101739-2.stderr @@ -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` diff --git a/tests/ui/transmutability/issue-110467.rs b/tests/ui/transmutability/issue-110467.rs index 6485ed8aab7f7..1f9e521c24b66 100644 --- a/tests/ui/transmutability/issue-110467.rs +++ b/tests/ui/transmutability/issue-110467.rs @@ -2,11 +2,10 @@ #![crate_type = "lib"] #![feature(transmutability)] use std::mem::BikeshedIntrinsicFrom; -pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom, + Dst: BikeshedIntrinsicFrom, { } diff --git a/tests/ui/transmutability/issue-110892.rs b/tests/ui/transmutability/issue-110892.rs index 1baf117518bc0..9713684c959a9 100644 --- a/tests/ui/transmutability/issue-110892.rs +++ b/tests/ui/transmutability/issue-110892.rs @@ -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::(); + assert::is_transmutable::(); } diff --git a/tests/ui/transmutability/issue-110892.stderr b/tests/ui/transmutability/issue-110892.stderr index 13654307aee73..b5d1e7084a0d9 100644 --- a/tests/ui/transmutability/issue-110892.stderr +++ b/tests/ui/transmutability/issue-110892.stderr @@ -1,29 +1,29 @@ error: expected parameter name, found `,` - --> $DIR/issue-110892.rs:27:9 + --> $DIR/issue-110892.rs:25:9 | LL | , | ^ expected parameter name error: expected parameter name, found `,` - --> $DIR/issue-110892.rs:28:9 + --> $DIR/issue-110892.rs:26:9 | LL | , | ^ expected parameter name error: expected parameter name, found `,` - --> $DIR/issue-110892.rs:29:9 + --> $DIR/issue-110892.rs:27:9 | LL | , | ^ expected parameter name error: expected parameter name, found `,` - --> $DIR/issue-110892.rs:30:9 + --> $DIR/issue-110892.rs:28: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 diff --git a/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst.rs b/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst.rs index b3a1e13b85bed..bcfbc1430a8cc 100644 --- a/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst.rs +++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst.rs @@ -6,16 +6,14 @@ mod assert { use std::mem::BikeshedIntrinsicFrom; - pub struct Context; - pub fn is_transmutable() + pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } fn should_gracefully_handle_unknown_dst() { - struct Context; struct Src; - assert::is_transmutable::(); //~ cannot find type + assert::is_transmutable::(); //~ cannot find type } diff --git a/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst.stderr b/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst.stderr index 10e057ec104b8..9fa376bf4332b 100644 --- a/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst.stderr +++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst.stderr @@ -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::(); +LL | assert::is_transmutable::(); | ^^^ not found in this scope | help: you might be missing a type parameter diff --git a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src.rs b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src.rs index 092b205b77027..bd7c3fc7fb505 100644 --- a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src.rs +++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src.rs @@ -6,16 +6,14 @@ mod assert { use std::mem::BikeshedIntrinsicFrom; - pub struct Context; - pub fn is_transmutable() + pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } fn should_gracefully_handle_unknown_src() { - struct Context; #[repr(C)] struct Dst; - assert::is_transmutable::(); //~ cannot find type + assert::is_transmutable::(); //~ cannot find type } diff --git a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src.stderr b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src.stderr index a84d2726fa989..f2c7d9e1bcc15 100644 --- a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src.stderr +++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src.stderr @@ -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::(); +LL | assert::is_transmutable::(); | ^^^ not found in this scope | help: you might be missing a type parameter diff --git a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs index 8d19cabc0f9f0..58c16d773e17a 100644 --- a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs +++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs @@ -6,17 +6,15 @@ mod assert { use std::mem::BikeshedIntrinsicFrom; - pub struct Context; - pub fn is_transmutable() + pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } fn should_gracefully_handle_unknown_dst_field() { - struct Context; #[repr(C)] struct Src; #[repr(C)] struct Dst(Missing); //~ cannot find type - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted } diff --git a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr index c2df398b8ff91..eeed8a62a2a26 100644 --- a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr +++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr @@ -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::(); +LL | assert::is_transmutable::(); | ^^^ `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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to 2 previous errors diff --git a/tests/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.rs b/tests/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.rs index 52aa4bb31016c..608366fa08936 100644 --- a/tests/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.rs +++ b/tests/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.rs @@ -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::(); //~ ERROR mismatched types - assert::is_transmutable::(); //~ ERROR mismatched types - assert::is_transmutable::(); //~ ERROR mismatched types - assert::is_transmutable::(); //~ ERROR mismatched types + assert::is_transmutable::(); //~ ERROR mismatched types + assert::is_transmutable::(); //~ ERROR mismatched types + assert::is_transmutable::(); //~ ERROR mismatched types + assert::is_transmutable::(); //~ ERROR mismatched types } diff --git a/tests/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.stderr b/tests/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.stderr index c6d93876cfafa..c6d37c24325c9 100644 --- a/tests/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.stderr +++ b/tests/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.stderr @@ -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::(); - | ^^^ expected `bool`, found `u8` +LL | assert::is_transmutable::(); + | ^^^ 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::(); - | ^^^ expected `bool`, found `u8` +LL | assert::is_transmutable::(); + | ^^^ 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::(); - | ^^^ expected `bool`, found `u8` +LL | assert::is_transmutable::(); + | ^^^ 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::(); - | ^^^ expected `bool`, found `u8` +LL | assert::is_transmutable::(); + | ^^^ expected `bool`, found `u8` error: aborting due to 4 previous errors diff --git a/tests/ui/transmutability/primitives/bool-mut.rs b/tests/ui/transmutability/primitives/bool-mut.rs index 0a74aba8f63a9..5f3f4f3a8c5b4 100644 --- a/tests/ui/transmutability/primitives/bool-mut.rs +++ b/tests/ui/transmutability/primitives/bool-mut.rs @@ -4,11 +4,10 @@ #![feature(transmutability)] mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/tests/ui/transmutability/primitives/bool-mut.stderr b/tests/ui/transmutability/primitives/bool-mut.stderr index 62a7a2b86224c..c4f295fc70a2e 100644 --- a/tests/ui/transmutability/primitives/bool-mut.stderr +++ b/tests/ui/transmutability/primitives/bool-mut.stderr @@ -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() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to 1 previous error diff --git a/tests/ui/transmutability/primitives/bool.current.stderr b/tests/ui/transmutability/primitives/bool.current.stderr index 6dfd83dd51444..d6376342c9cf9 100644 --- a/tests/ui/transmutability/primitives/bool.current.stderr +++ b/tests/ui/transmutability/primitives/bool.current.stderr @@ -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::(); | ^^^^ 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() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to 1 previous error diff --git a/tests/ui/transmutability/primitives/bool.next.stderr b/tests/ui/transmutability/primitives/bool.next.stderr index 6dfd83dd51444..d6376342c9cf9 100644 --- a/tests/ui/transmutability/primitives/bool.next.stderr +++ b/tests/ui/transmutability/primitives/bool.next.stderr @@ -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::(); | ^^^^ 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() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to 1 previous error diff --git a/tests/ui/transmutability/primitives/bool.rs b/tests/ui/transmutability/primitives/bool.rs index b7dc309e469c7..1be3b28b643e1 100644 --- a/tests/ui/transmutability/primitives/bool.rs +++ b/tests/ui/transmutability/primitives/bool.rs @@ -4,16 +4,15 @@ #![feature(transmutability)] mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/tests/ui/transmutability/primitives/numbers.current.stderr b/tests/ui/transmutability/primitives/numbers.current.stderr index d12e172971c38..7a80e444149d4 100644 --- a/tests/ui/transmutability/primitives/numbers.current.stderr +++ b/tests/ui/transmutability/primitives/numbers.current.stderr @@ -1,857 +1,857 @@ -error[E0277]: `i8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:65:40 +error[E0277]: `i8` cannot be safely transmuted into `i16` + --> $DIR/numbers.rs:64:40 | LL | assert::is_transmutable::< i8, i16>(); | ^^^ The size of `i8` is smaller than the size of `i16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:66:40 +error[E0277]: `i8` cannot be safely transmuted into `u16` + --> $DIR/numbers.rs:65:40 | LL | assert::is_transmutable::< i8, u16>(); | ^^^ The size of `i8` is smaller than the size of `u16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:67:40 +error[E0277]: `i8` cannot be safely transmuted into `i32` + --> $DIR/numbers.rs:66:40 | LL | assert::is_transmutable::< i8, i32>(); | ^^^ The size of `i8` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:68:40 +error[E0277]: `i8` cannot be safely transmuted into `f32` + --> $DIR/numbers.rs:67:40 | LL | assert::is_transmutable::< i8, f32>(); | ^^^ The size of `i8` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:69:40 +error[E0277]: `i8` cannot be safely transmuted into `u32` + --> $DIR/numbers.rs:68:40 | LL | assert::is_transmutable::< i8, u32>(); | ^^^ The size of `i8` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:70:40 +error[E0277]: `i8` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:69:40 | LL | assert::is_transmutable::< i8, u64>(); | ^^^ The size of `i8` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:71:40 +error[E0277]: `i8` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:70:40 | LL | assert::is_transmutable::< i8, i64>(); | ^^^ The size of `i8` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:72:40 +error[E0277]: `i8` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:71:40 | LL | assert::is_transmutable::< i8, f64>(); | ^^^ The size of `i8` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:73:39 +error[E0277]: `i8` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:72:39 | LL | assert::is_transmutable::< i8, u128>(); | ^^^^ The size of `i8` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:74:39 +error[E0277]: `i8` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:73:39 | LL | assert::is_transmutable::< i8, i128>(); | ^^^^ The size of `i8` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:76:40 +error[E0277]: `u8` cannot be safely transmuted into `i16` + --> $DIR/numbers.rs:75:40 | LL | assert::is_transmutable::< u8, i16>(); | ^^^ The size of `u8` is smaller than the size of `i16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:77:40 +error[E0277]: `u8` cannot be safely transmuted into `u16` + --> $DIR/numbers.rs:76:40 | LL | assert::is_transmutable::< u8, u16>(); | ^^^ The size of `u8` is smaller than the size of `u16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:78:40 +error[E0277]: `u8` cannot be safely transmuted into `i32` + --> $DIR/numbers.rs:77:40 | LL | assert::is_transmutable::< u8, i32>(); | ^^^ The size of `u8` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:79:40 +error[E0277]: `u8` cannot be safely transmuted into `f32` + --> $DIR/numbers.rs:78:40 | LL | assert::is_transmutable::< u8, f32>(); | ^^^ The size of `u8` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:80:40 +error[E0277]: `u8` cannot be safely transmuted into `u32` + --> $DIR/numbers.rs:79:40 | LL | assert::is_transmutable::< u8, u32>(); | ^^^ The size of `u8` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:81:40 +error[E0277]: `u8` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:80:40 | LL | assert::is_transmutable::< u8, u64>(); | ^^^ The size of `u8` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:82:40 +error[E0277]: `u8` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:81:40 | LL | assert::is_transmutable::< u8, i64>(); | ^^^ The size of `u8` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:83:40 +error[E0277]: `u8` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:82:40 | LL | assert::is_transmutable::< u8, f64>(); | ^^^ The size of `u8` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:84:39 +error[E0277]: `u8` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:83:39 | LL | assert::is_transmutable::< u8, u128>(); | ^^^^ The size of `u8` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:85:39 +error[E0277]: `u8` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:84:39 | LL | assert::is_transmutable::< u8, i128>(); | ^^^^ The size of `u8` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:87:40 +error[E0277]: `i16` cannot be safely transmuted into `i32` + --> $DIR/numbers.rs:86:40 | LL | assert::is_transmutable::< i16, i32>(); | ^^^ The size of `i16` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:88:40 +error[E0277]: `i16` cannot be safely transmuted into `f32` + --> $DIR/numbers.rs:87:40 | LL | assert::is_transmutable::< i16, f32>(); | ^^^ The size of `i16` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:89:40 +error[E0277]: `i16` cannot be safely transmuted into `u32` + --> $DIR/numbers.rs:88:40 | LL | assert::is_transmutable::< i16, u32>(); | ^^^ The size of `i16` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:90:40 +error[E0277]: `i16` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:89:40 | LL | assert::is_transmutable::< i16, u64>(); | ^^^ The size of `i16` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:91:40 +error[E0277]: `i16` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:90:40 | LL | assert::is_transmutable::< i16, i64>(); | ^^^ The size of `i16` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:92:40 +error[E0277]: `i16` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:91:40 | LL | assert::is_transmutable::< i16, f64>(); | ^^^ The size of `i16` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:93:39 +error[E0277]: `i16` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:92:39 | LL | assert::is_transmutable::< i16, u128>(); | ^^^^ The size of `i16` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:94:39 +error[E0277]: `i16` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:93:39 | LL | assert::is_transmutable::< i16, i128>(); | ^^^^ The size of `i16` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:96:40 +error[E0277]: `u16` cannot be safely transmuted into `i32` + --> $DIR/numbers.rs:95:40 | LL | assert::is_transmutable::< u16, i32>(); | ^^^ The size of `u16` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:97:40 +error[E0277]: `u16` cannot be safely transmuted into `f32` + --> $DIR/numbers.rs:96:40 | LL | assert::is_transmutable::< u16, f32>(); | ^^^ The size of `u16` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:98:40 +error[E0277]: `u16` cannot be safely transmuted into `u32` + --> $DIR/numbers.rs:97:40 | LL | assert::is_transmutable::< u16, u32>(); | ^^^ The size of `u16` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:99:40 +error[E0277]: `u16` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:98:40 | LL | assert::is_transmutable::< u16, u64>(); | ^^^ The size of `u16` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:100:40 +error[E0277]: `u16` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:99:40 | LL | assert::is_transmutable::< u16, i64>(); | ^^^ The size of `u16` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:101:40 +error[E0277]: `u16` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:100:40 | LL | assert::is_transmutable::< u16, f64>(); | ^^^ The size of `u16` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:102:39 +error[E0277]: `u16` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:101:39 | LL | assert::is_transmutable::< u16, u128>(); | ^^^^ The size of `u16` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:103:39 +error[E0277]: `u16` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:102:39 | LL | assert::is_transmutable::< u16, i128>(); | ^^^^ The size of `u16` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:105:40 +error[E0277]: `i32` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:104:40 | LL | assert::is_transmutable::< i32, u64>(); | ^^^ The size of `i32` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:106:40 +error[E0277]: `i32` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:105:40 | LL | assert::is_transmutable::< i32, i64>(); | ^^^ The size of `i32` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:107:40 +error[E0277]: `i32` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:106:40 | LL | assert::is_transmutable::< i32, f64>(); | ^^^ The size of `i32` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:108:39 +error[E0277]: `i32` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:107:39 | LL | assert::is_transmutable::< i32, u128>(); | ^^^^ The size of `i32` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:109:39 +error[E0277]: `i32` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:108:39 | LL | assert::is_transmutable::< i32, i128>(); | ^^^^ The size of `i32` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:111:40 +error[E0277]: `f32` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:110:40 | LL | assert::is_transmutable::< f32, u64>(); | ^^^ The size of `f32` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:112:40 +error[E0277]: `f32` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:111:40 | LL | assert::is_transmutable::< f32, i64>(); | ^^^ The size of `f32` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:113:40 +error[E0277]: `f32` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:112:40 | LL | assert::is_transmutable::< f32, f64>(); | ^^^ The size of `f32` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:114:39 +error[E0277]: `f32` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:113:39 | LL | assert::is_transmutable::< f32, u128>(); | ^^^^ The size of `f32` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:115:39 +error[E0277]: `f32` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:114:39 | LL | assert::is_transmutable::< f32, i128>(); | ^^^^ The size of `f32` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:117:40 +error[E0277]: `u32` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:116:40 | LL | assert::is_transmutable::< u32, u64>(); | ^^^ The size of `u32` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:118:40 +error[E0277]: `u32` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:117:40 | LL | assert::is_transmutable::< u32, i64>(); | ^^^ The size of `u32` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:119:40 +error[E0277]: `u32` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:118:40 | LL | assert::is_transmutable::< u32, f64>(); | ^^^ The size of `u32` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:120:39 +error[E0277]: `u32` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:119:39 | LL | assert::is_transmutable::< u32, u128>(); | ^^^^ The size of `u32` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:121:39 +error[E0277]: `u32` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:120:39 | LL | assert::is_transmutable::< u32, i128>(); | ^^^^ The size of `u32` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:123:39 +error[E0277]: `u64` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:122:39 | LL | assert::is_transmutable::< u64, u128>(); | ^^^^ The size of `u64` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:124:39 +error[E0277]: `u64` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:123:39 | LL | assert::is_transmutable::< u64, i128>(); | ^^^^ The size of `u64` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:126:39 +error[E0277]: `i64` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:125:39 | LL | assert::is_transmutable::< i64, u128>(); | ^^^^ The size of `i64` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:127:39 +error[E0277]: `i64` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:126:39 | LL | assert::is_transmutable::< i64, i128>(); | ^^^^ The size of `i64` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:129:39 +error[E0277]: `f64` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:128:39 | LL | assert::is_transmutable::< f64, u128>(); | ^^^^ The size of `f64` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:130:39 +error[E0277]: `f64` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:129:39 | LL | assert::is_transmutable::< f64, i128>(); | ^^^^ The size of `f64` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to 57 previous errors diff --git a/tests/ui/transmutability/primitives/numbers.next.stderr b/tests/ui/transmutability/primitives/numbers.next.stderr index d12e172971c38..7a80e444149d4 100644 --- a/tests/ui/transmutability/primitives/numbers.next.stderr +++ b/tests/ui/transmutability/primitives/numbers.next.stderr @@ -1,857 +1,857 @@ -error[E0277]: `i8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:65:40 +error[E0277]: `i8` cannot be safely transmuted into `i16` + --> $DIR/numbers.rs:64:40 | LL | assert::is_transmutable::< i8, i16>(); | ^^^ The size of `i8` is smaller than the size of `i16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:66:40 +error[E0277]: `i8` cannot be safely transmuted into `u16` + --> $DIR/numbers.rs:65:40 | LL | assert::is_transmutable::< i8, u16>(); | ^^^ The size of `i8` is smaller than the size of `u16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:67:40 +error[E0277]: `i8` cannot be safely transmuted into `i32` + --> $DIR/numbers.rs:66:40 | LL | assert::is_transmutable::< i8, i32>(); | ^^^ The size of `i8` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:68:40 +error[E0277]: `i8` cannot be safely transmuted into `f32` + --> $DIR/numbers.rs:67:40 | LL | assert::is_transmutable::< i8, f32>(); | ^^^ The size of `i8` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:69:40 +error[E0277]: `i8` cannot be safely transmuted into `u32` + --> $DIR/numbers.rs:68:40 | LL | assert::is_transmutable::< i8, u32>(); | ^^^ The size of `i8` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:70:40 +error[E0277]: `i8` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:69:40 | LL | assert::is_transmutable::< i8, u64>(); | ^^^ The size of `i8` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:71:40 +error[E0277]: `i8` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:70:40 | LL | assert::is_transmutable::< i8, i64>(); | ^^^ The size of `i8` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:72:40 +error[E0277]: `i8` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:71:40 | LL | assert::is_transmutable::< i8, f64>(); | ^^^ The size of `i8` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:73:39 +error[E0277]: `i8` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:72:39 | LL | assert::is_transmutable::< i8, u128>(); | ^^^^ The size of `i8` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:74:39 +error[E0277]: `i8` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:73:39 | LL | assert::is_transmutable::< i8, i128>(); | ^^^^ The size of `i8` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:76:40 +error[E0277]: `u8` cannot be safely transmuted into `i16` + --> $DIR/numbers.rs:75:40 | LL | assert::is_transmutable::< u8, i16>(); | ^^^ The size of `u8` is smaller than the size of `i16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:77:40 +error[E0277]: `u8` cannot be safely transmuted into `u16` + --> $DIR/numbers.rs:76:40 | LL | assert::is_transmutable::< u8, u16>(); | ^^^ The size of `u8` is smaller than the size of `u16` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:78:40 +error[E0277]: `u8` cannot be safely transmuted into `i32` + --> $DIR/numbers.rs:77:40 | LL | assert::is_transmutable::< u8, i32>(); | ^^^ The size of `u8` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:79:40 +error[E0277]: `u8` cannot be safely transmuted into `f32` + --> $DIR/numbers.rs:78:40 | LL | assert::is_transmutable::< u8, f32>(); | ^^^ The size of `u8` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:80:40 +error[E0277]: `u8` cannot be safely transmuted into `u32` + --> $DIR/numbers.rs:79:40 | LL | assert::is_transmutable::< u8, u32>(); | ^^^ The size of `u8` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:81:40 +error[E0277]: `u8` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:80:40 | LL | assert::is_transmutable::< u8, u64>(); | ^^^ The size of `u8` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:82:40 +error[E0277]: `u8` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:81:40 | LL | assert::is_transmutable::< u8, i64>(); | ^^^ The size of `u8` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:83:40 +error[E0277]: `u8` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:82:40 | LL | assert::is_transmutable::< u8, f64>(); | ^^^ The size of `u8` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:84:39 +error[E0277]: `u8` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:83:39 | LL | assert::is_transmutable::< u8, u128>(); | ^^^^ The size of `u8` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:85:39 +error[E0277]: `u8` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:84:39 | LL | assert::is_transmutable::< u8, i128>(); | ^^^^ The size of `u8` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:87:40 +error[E0277]: `i16` cannot be safely transmuted into `i32` + --> $DIR/numbers.rs:86:40 | LL | assert::is_transmutable::< i16, i32>(); | ^^^ The size of `i16` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:88:40 +error[E0277]: `i16` cannot be safely transmuted into `f32` + --> $DIR/numbers.rs:87:40 | LL | assert::is_transmutable::< i16, f32>(); | ^^^ The size of `i16` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:89:40 +error[E0277]: `i16` cannot be safely transmuted into `u32` + --> $DIR/numbers.rs:88:40 | LL | assert::is_transmutable::< i16, u32>(); | ^^^ The size of `i16` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:90:40 +error[E0277]: `i16` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:89:40 | LL | assert::is_transmutable::< i16, u64>(); | ^^^ The size of `i16` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:91:40 +error[E0277]: `i16` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:90:40 | LL | assert::is_transmutable::< i16, i64>(); | ^^^ The size of `i16` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:92:40 +error[E0277]: `i16` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:91:40 | LL | assert::is_transmutable::< i16, f64>(); | ^^^ The size of `i16` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:93:39 +error[E0277]: `i16` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:92:39 | LL | assert::is_transmutable::< i16, u128>(); | ^^^^ The size of `i16` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:94:39 +error[E0277]: `i16` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:93:39 | LL | assert::is_transmutable::< i16, i128>(); | ^^^^ The size of `i16` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:96:40 +error[E0277]: `u16` cannot be safely transmuted into `i32` + --> $DIR/numbers.rs:95:40 | LL | assert::is_transmutable::< u16, i32>(); | ^^^ The size of `u16` is smaller than the size of `i32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:97:40 +error[E0277]: `u16` cannot be safely transmuted into `f32` + --> $DIR/numbers.rs:96:40 | LL | assert::is_transmutable::< u16, f32>(); | ^^^ The size of `u16` is smaller than the size of `f32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:98:40 +error[E0277]: `u16` cannot be safely transmuted into `u32` + --> $DIR/numbers.rs:97:40 | LL | assert::is_transmutable::< u16, u32>(); | ^^^ The size of `u16` is smaller than the size of `u32` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:99:40 +error[E0277]: `u16` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:98:40 | LL | assert::is_transmutable::< u16, u64>(); | ^^^ The size of `u16` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:100:40 +error[E0277]: `u16` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:99:40 | LL | assert::is_transmutable::< u16, i64>(); | ^^^ The size of `u16` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:101:40 +error[E0277]: `u16` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:100:40 | LL | assert::is_transmutable::< u16, f64>(); | ^^^ The size of `u16` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:102:39 +error[E0277]: `u16` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:101:39 | LL | assert::is_transmutable::< u16, u128>(); | ^^^^ The size of `u16` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:103:39 +error[E0277]: `u16` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:102:39 | LL | assert::is_transmutable::< u16, i128>(); | ^^^^ The size of `u16` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:105:40 +error[E0277]: `i32` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:104:40 | LL | assert::is_transmutable::< i32, u64>(); | ^^^ The size of `i32` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:106:40 +error[E0277]: `i32` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:105:40 | LL | assert::is_transmutable::< i32, i64>(); | ^^^ The size of `i32` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:107:40 +error[E0277]: `i32` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:106:40 | LL | assert::is_transmutable::< i32, f64>(); | ^^^ The size of `i32` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:108:39 +error[E0277]: `i32` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:107:39 | LL | assert::is_transmutable::< i32, u128>(); | ^^^^ The size of `i32` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:109:39 +error[E0277]: `i32` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:108:39 | LL | assert::is_transmutable::< i32, i128>(); | ^^^^ The size of `i32` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:111:40 +error[E0277]: `f32` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:110:40 | LL | assert::is_transmutable::< f32, u64>(); | ^^^ The size of `f32` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:112:40 +error[E0277]: `f32` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:111:40 | LL | assert::is_transmutable::< f32, i64>(); | ^^^ The size of `f32` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:113:40 +error[E0277]: `f32` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:112:40 | LL | assert::is_transmutable::< f32, f64>(); | ^^^ The size of `f32` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:114:39 +error[E0277]: `f32` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:113:39 | LL | assert::is_transmutable::< f32, u128>(); | ^^^^ The size of `f32` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:115:39 +error[E0277]: `f32` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:114:39 | LL | assert::is_transmutable::< f32, i128>(); | ^^^^ The size of `f32` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:117:40 +error[E0277]: `u32` cannot be safely transmuted into `u64` + --> $DIR/numbers.rs:116:40 | LL | assert::is_transmutable::< u32, u64>(); | ^^^ The size of `u32` is smaller than the size of `u64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:118:40 +error[E0277]: `u32` cannot be safely transmuted into `i64` + --> $DIR/numbers.rs:117:40 | LL | assert::is_transmutable::< u32, i64>(); | ^^^ The size of `u32` is smaller than the size of `i64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:119:40 +error[E0277]: `u32` cannot be safely transmuted into `f64` + --> $DIR/numbers.rs:118:40 | LL | assert::is_transmutable::< u32, f64>(); | ^^^ The size of `u32` is smaller than the size of `f64` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:120:39 +error[E0277]: `u32` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:119:39 | LL | assert::is_transmutable::< u32, u128>(); | ^^^^ The size of `u32` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:121:39 +error[E0277]: `u32` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:120:39 | LL | assert::is_transmutable::< u32, i128>(); | ^^^^ The size of `u32` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:123:39 +error[E0277]: `u64` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:122:39 | LL | assert::is_transmutable::< u64, u128>(); | ^^^^ The size of `u64` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:124:39 +error[E0277]: `u64` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:123:39 | LL | assert::is_transmutable::< u64, i128>(); | ^^^^ The size of `u64` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:126:39 +error[E0277]: `i64` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:125:39 | LL | assert::is_transmutable::< i64, u128>(); | ^^^^ The size of `i64` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:127:39 +error[E0277]: `i64` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:126:39 | LL | assert::is_transmutable::< i64, i128>(); | ^^^^ The size of `i64` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:129:39 +error[E0277]: `f64` cannot be safely transmuted into `u128` + --> $DIR/numbers.rs:128:39 | LL | assert::is_transmutable::< f64, u128>(); | ^^^^ The size of `f64` is smaller than the size of `u128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` - --> $DIR/numbers.rs:130:39 +error[E0277]: `f64` cannot be safely transmuted into `i128` + --> $DIR/numbers.rs:129:39 | LL | assert::is_transmutable::< f64, i128>(); | ^^^^ The size of `f64` is smaller than the size of `i128` | note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:15:14 + --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to 57 previous errors diff --git a/tests/ui/transmutability/primitives/numbers.rs b/tests/ui/transmutability/primitives/numbers.rs index 8baa4b05216ef..2b7d8a7986027 100644 --- a/tests/ui/transmutability/primitives/numbers.rs +++ b/tests/ui/transmutability/primitives/numbers.rs @@ -8,11 +8,10 @@ mod assert { use std::mem::BikeshedIntrinsicFrom; - struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/tests/ui/transmutability/primitives/unit.current.stderr b/tests/ui/transmutability/primitives/unit.current.stderr index e5d8466c32364..37088a69698be 100644 --- a/tests/ui/transmutability/primitives/unit.current.stderr +++ b/tests/ui/transmutability/primitives/unit.current.stderr @@ -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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom $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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom() + pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom(); - assert::is_transmutable::(); - assert::is_transmutable::<(), u8, Context>(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::<(), Zst>(); + assert::is_transmutable::(); + assert::is_transmutable::<(), u8>(); //~ ERROR cannot be safely transmuted } diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.rs b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.rs index 8e005d83a45e7..ba2db755e3b10 100644 --- a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.rs +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.rs @@ -3,11 +3,10 @@ mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom $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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom $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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom $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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom(&'a ()); @@ -10,7 +9,6 @@ fn test<'a>() where W<'a>: BikeshedIntrinsicFrom< (), - Context, { Assume { alignment: true, lifetimes: true, safety: true, validity: true } }, >, { diff --git a/tests/ui/transmutability/region-infer.stderr b/tests/ui/transmutability/region-infer.stderr index 805862d6c4afc..5497af2429e5e 100644 --- a/tests/ui/transmutability/region-infer.stderr +++ b/tests/ui/transmutability/region-infer.stderr @@ -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` diff --git a/tests/ui/transmutability/safety/assume/should_accept_if_dst_has_safety_invariant.rs b/tests/ui/transmutability/safety/assume/should_accept_if_dst_has_safety_invariant.rs new file mode 100644 index 0000000000000..cb3c1cdf46cb6 --- /dev/null +++ b/tests/ui/transmutability/safety/assume/should_accept_if_dst_has_safety_invariant.rs @@ -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() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn test() { + type Src = (); + #[repr(C)] + struct Dst; + assert::is_transmutable::(); +} diff --git a/tests/ui/transmutability/safety/assume/should_accept_if_ref_src_has_safety_invariant.rs b/tests/ui/transmutability/safety/assume/should_accept_if_ref_src_has_safety_invariant.rs new file mode 100644 index 0000000000000..b12c4a10d12b7 --- /dev/null +++ b/tests/ui/transmutability/safety/assume/should_accept_if_ref_src_has_safety_invariant.rs @@ -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() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn test() { + #[repr(C)] + struct Src { + non_zero: u8, + } + type Dst = u8; + assert::is_transmutable::<&mut Src, &mut Dst>(); +} diff --git a/tests/ui/transmutability/safety/assume/should_accept_if_src_has_safety_invariant.rs b/tests/ui/transmutability/safety/assume/should_accept_if_src_has_safety_invariant.rs new file mode 100644 index 0000000000000..ff01462ffec51 --- /dev/null +++ b/tests/ui/transmutability/safety/assume/should_accept_if_src_has_safety_invariant.rs @@ -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() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn test() { + #[repr(C)] + struct Src; + type Dst = (); + assert::is_transmutable::(); +} diff --git a/tests/ui/transmutability/safety/should_accept_if_src_has_safety_invariant.rs b/tests/ui/transmutability/safety/should_accept_if_src_has_safety_invariant.rs new file mode 100644 index 0000000000000..d516e9a7da584 --- /dev/null +++ b/tests/ui/transmutability/safety/should_accept_if_src_has_safety_invariant.rs @@ -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() + where + Dst: BikeshedIntrinsicFrom // safety is NOT assumed + {} +} + +fn test() { + #[repr(C)] + struct Src; + type Dst = (); + assert::is_transmutable::(); +} diff --git a/tests/ui/transmutability/safety/should_reject_if_dst_has_safety_invariant.rs b/tests/ui/transmutability/safety/should_reject_if_dst_has_safety_invariant.rs new file mode 100644 index 0000000000000..4f0aee3154850 --- /dev/null +++ b/tests/ui/transmutability/safety/should_reject_if_dst_has_safety_invariant.rs @@ -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() + where + Dst: BikeshedIntrinsicFrom // safety is NOT assumed + {} +} + +fn test() { + type Src = (); + #[repr(C)] + struct Dst; + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted +} diff --git a/tests/ui/transmutability/safety/should_reject_if_dst_has_safety_invariant.stderr b/tests/ui/transmutability/safety/should_reject_if_dst_has_safety_invariant.stderr new file mode 100644 index 0000000000000..2339c2683267b --- /dev/null +++ b/tests/ui/transmutability/safety/should_reject_if_dst_has_safety_invariant.stderr @@ -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::(); + | ^^^ `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() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom // 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`. diff --git a/tests/ui/transmutability/safety/should_reject_if_ref_src_has_safety_invariant.rs b/tests/ui/transmutability/safety/should_reject_if_ref_src_has_safety_invariant.rs new file mode 100644 index 0000000000000..126059dd7b7d7 --- /dev/null +++ b/tests/ui/transmutability/safety/should_reject_if_ref_src_has_safety_invariant.rs @@ -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() + where + Dst: BikeshedIntrinsicFrom // 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 +} diff --git a/tests/ui/transmutability/safety/should_reject_if_ref_src_has_safety_invariant.stderr b/tests/ui/transmutability/safety/should_reject_if_ref_src_has_safety_invariant.stderr new file mode 100644 index 0000000000000..99feebe92118e --- /dev/null +++ b/tests/ui/transmutability/safety/should_reject_if_ref_src_has_safety_invariant.stderr @@ -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() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom // 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`. diff --git a/tests/ui/transmutability/structs/repr/should_handle_align.rs b/tests/ui/transmutability/structs/repr/should_handle_align.rs index ca18e0f1543ed..0c207766045c1 100644 --- a/tests/ui/transmutability/structs/repr/should_handle_align.rs +++ b/tests/ui/transmutability/structs/repr/should_handle_align.rs @@ -7,11 +7,10 @@ mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom $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::(); | ^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^^^^^^^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^^^^^^^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^^^^^^^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^^^^^^^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^^^^^^^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^^^^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom, + Dst: BikeshedIntrinsicFrom, { } } diff --git a/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr b/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr index 0dedd5aaf735c..7fb051f66250e 100644 --- a/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr +++ b/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr @@ -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); 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` + = note: cycle used when evaluating trait selection obligation `(): core::mem::transmutability::BikeshedIntrinsicFrom` = 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 diff --git a/tests/ui/transmutability/structs/should_order_fields_correctly.rs b/tests/ui/transmutability/structs/should_order_fields_correctly.rs index bda5bfb89a279..3675e4330ecc8 100644 --- a/tests/ui/transmutability/structs/should_order_fields_correctly.rs +++ b/tests/ui/transmutability/structs/should_order_fields_correctly.rs @@ -7,11 +7,10 @@ mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom() where Dst: BikeshedIntrinsicFrom< Src, - Context, { Assume { alignment: true, lifetimes: true, safety: true, validity: true } }, >, { diff --git a/tests/ui/transmute/transmute-padding-ice.stderr b/tests/ui/transmutability/transmute-padding-ice.stderr similarity index 77% rename from tests/ui/transmute/transmute-padding-ice.stderr rename to tests/ui/transmutability/transmute-padding-ice.stderr index ff5c5c3a5dd8b..c48a5cd80ce7f 100644 --- a/tests/ui/transmute/transmute-padding-ice.stderr +++ b/tests/ui/transmutability/transmute-padding-ice.stderr @@ -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::(); | ^ 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() | --------------------- 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` diff --git a/tests/ui/transmutability/unions/boolish.rs b/tests/ui/transmutability/unions/boolish.rs index 9ab5f2be59aec..0ba59bcaa9f20 100644 --- a/tests/ui/transmutability/unions/boolish.rs +++ b/tests/ui/transmutability/unions/boolish.rs @@ -8,11 +8,10 @@ mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/tests/ui/transmutability/unions/repr/should_handle_align.rs b/tests/ui/transmutability/unions/repr/should_handle_align.rs index 652158ecf521e..8668cca3cb50d 100644 --- a/tests/ui/transmutability/unions/repr/should_handle_align.rs +++ b/tests/ui/transmutability/unions/repr/should_handle_align.rs @@ -7,11 +7,10 @@ mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom $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::(); | ^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom | |__________^ 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::(); | ^^^^^^^^^ `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() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom() + pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom(); //~ ERROR cannot be safely transmuted + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted } diff --git a/tests/ui/transmutability/unions/should_pad_variants.stderr b/tests/ui/transmutability/unions/should_pad_variants.stderr index fd98e355fb915..13b4c8053adb2 100644 --- a/tests/ui/transmutability/unions/should_pad_variants.stderr +++ b/tests/ui/transmutability/unions/should_pad_variants.stderr @@ -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::(); +LL | assert::is_transmutable::(); | ^^^ 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() +LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/tests/ui/transmutability/unions/should_reject_contraction.rs b/tests/ui/transmutability/unions/should_reject_contraction.rs index a24dfccd3187d..62a0ee929192f 100644 --- a/tests/ui/transmutability/unions/should_reject_contraction.rs +++ b/tests/ui/transmutability/unions/should_reject_contraction.rs @@ -6,11 +6,10 @@ mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/tests/ui/transmutability/unions/should_reject_contraction.stderr b/tests/ui/transmutability/unions/should_reject_contraction.stderr index e3493e184893c..a3e387a0f8469 100644 --- a/tests/ui/transmutability/unions/should_reject_contraction.stderr +++ b/tests/ui/transmutability/unions/should_reject_contraction.stderr @@ -1,17 +1,17 @@ -error[E0277]: `Superset` cannot be safely transmuted into `Subset` in the defining scope of `assert::Context` - --> $DIR/should_reject_contraction.rs:35:41 +error[E0277]: `Superset` cannot be safely transmuted into `Subset` + --> $DIR/should_reject_contraction.rs:34:41 | LL | assert::is_transmutable::(); | ^^^^^^ At least one value of `Superset` isn't a bit-valid value of `Subset` | note: required by a bound in `is_transmutable` - --> $DIR/should_reject_contraction.rs:13:14 + --> $DIR/should_reject_contraction.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to 1 previous error diff --git a/tests/ui/transmutability/unions/should_reject_disjoint.rs b/tests/ui/transmutability/unions/should_reject_disjoint.rs index 43aaa6905fd4f..732f92e81606b 100644 --- a/tests/ui/transmutability/unions/should_reject_disjoint.rs +++ b/tests/ui/transmutability/unions/should_reject_disjoint.rs @@ -6,11 +6,10 @@ mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/tests/ui/transmutability/unions/should_reject_disjoint.stderr b/tests/ui/transmutability/unions/should_reject_disjoint.stderr index 178ae6f08c495..447ab6d9de7a3 100644 --- a/tests/ui/transmutability/unions/should_reject_disjoint.stderr +++ b/tests/ui/transmutability/unions/should_reject_disjoint.stderr @@ -1,32 +1,32 @@ -error[E0277]: `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context` - --> $DIR/should_reject_disjoint.rs:33:40 +error[E0277]: `A` cannot be safely transmuted into `B` + --> $DIR/should_reject_disjoint.rs:32:40 | LL | assert::is_maybe_transmutable::(); | ^ At least one value of `A` isn't a bit-valid value of `B` | note: required by a bound in `is_maybe_transmutable` - --> $DIR/should_reject_disjoint.rs:13:14 + --> $DIR/should_reject_disjoint.rs:12:14 | LL | pub fn is_maybe_transmutable() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` -error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context` - --> $DIR/should_reject_disjoint.rs:34:40 +error[E0277]: `B` cannot be safely transmuted into `A` + --> $DIR/should_reject_disjoint.rs:33:40 | LL | assert::is_maybe_transmutable::(); | ^ At least one value of `B` isn't a bit-valid value of `A` | note: required by a bound in `is_maybe_transmutable` - --> $DIR/should_reject_disjoint.rs:13:14 + --> $DIR/should_reject_disjoint.rs:12:14 | LL | pub fn is_maybe_transmutable() | --------------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` error: aborting due to 2 previous errors diff --git a/tests/ui/transmutability/unions/should_reject_intersecting.rs b/tests/ui/transmutability/unions/should_reject_intersecting.rs index 9cd4233ee7455..752a606c861a6 100644 --- a/tests/ui/transmutability/unions/should_reject_intersecting.rs +++ b/tests/ui/transmutability/unions/should_reject_intersecting.rs @@ -7,12 +7,11 @@ mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // validity is NOT assumed --------------^^^^^^^^^^^^^^^^^^ + Dst: BikeshedIntrinsicFrom + // validity is NOT assumed -----^^^^^^^^^^^^^^^^^^ {} } diff --git a/tests/ui/transmutability/unions/should_reject_intersecting.stderr b/tests/ui/transmutability/unions/should_reject_intersecting.stderr index 73c29ab1c970d..f0763bc8be782 100644 --- a/tests/ui/transmutability/unions/should_reject_intersecting.stderr +++ b/tests/ui/transmutability/unions/should_reject_intersecting.stderr @@ -1,32 +1,32 @@ -error[E0277]: `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context` - --> $DIR/should_reject_intersecting.rs:36:34 +error[E0277]: `A` cannot be safely transmuted into `B` + --> $DIR/should_reject_intersecting.rs:35:34 | LL | assert::is_transmutable::(); | ^ At least one value of `A` isn't a bit-valid value of `B` | note: required by a bound in `is_transmutable` - --> $DIR/should_reject_intersecting.rs:14:14 + --> $DIR/should_reject_intersecting.rs:13:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context` - --> $DIR/should_reject_intersecting.rs:37:34 +error[E0277]: `B` cannot be safely transmuted into `A` + --> $DIR/should_reject_intersecting.rs:36:34 | LL | assert::is_transmutable::(); | ^ At least one value of `B` isn't a bit-valid value of `A` | note: required by a bound in `is_transmutable` - --> $DIR/should_reject_intersecting.rs:14:14 + --> $DIR/should_reject_intersecting.rs:13:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to 2 previous errors diff --git a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_field.rs b/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_field.rs deleted file mode 100644 index fa5569325b3a0..0000000000000 --- a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_field.rs +++ /dev/null @@ -1,38 +0,0 @@ -//@ check-pass -//! If visibility is assumed, a transmutation should be accepted even if the -//! destination type contains a private field. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom - // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ - {} -} - -mod src { - #[repr(C)] pub(self) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(self) field: Zst, - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Dst { - pub(self) field: Zst, // <- private field - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); -} diff --git a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_variant.rs b/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_variant.rs deleted file mode 100644 index 8ff8e2de0e61c..0000000000000 --- a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_variant.rs +++ /dev/null @@ -1,39 +0,0 @@ -//@ check-pass -//! If visibility is assumed, a transmutation should be accepted even if the -//! destination type contains a private variant. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom - // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ - {} -} - -mod src { - #[repr(C)] pub(self) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(self) field: Zst, - } -} - -mod dst { - #[derive(Copy, Clone)] - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) union Dst { - pub(self) field: Zst, // <- private variant - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); -} diff --git a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_tricky_unreachable_field.rs b/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_tricky_unreachable_field.rs deleted file mode 100644 index b9cf66ec31096..0000000000000 --- a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_tricky_unreachable_field.rs +++ /dev/null @@ -1,46 +0,0 @@ -//@ check-pass -//! Unless visibility is assumed, a transmutation should be rejected if the -//! destination type contains an unreachable field (e.g., a public field with a -//! private type). (This rule is distinct from type privacy, which still may -//! forbid naming such types.) -//! -//! This test exercises a tricky-to-implement instance of this principle: the -//! "pub-in-priv trick". In the below example, the type `dst::private::Zst` is -//! unreachable from `Context`. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom - // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - mod private { - #[repr(C)] pub struct Zst; // <- unreachable type - } - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: private::Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); -} diff --git a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs b/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs deleted file mode 100644 index a56145f59d832..0000000000000 --- a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs +++ /dev/null @@ -1,41 +0,0 @@ -//@ check-pass - -//! If visibility is assumed, a transmutation should be accepted even if the -//! destination type contains an unreachable field (e.g., a public field with a -//! private type). (This rule is distinct from type privacy, which still may -//! forbid naming such types.) - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom - // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ - {} -} - -mod src { - #[repr(C)] pub(self) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(self) field: Zst, - } -} - -mod dst { - #[repr(C)] pub(self) struct Zst; // <- unreachable type - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: Zst, //~ WARNING type `dst::Zst` is more private than the item `Dst::field` - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); -} diff --git a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.stderr b/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.stderr deleted file mode 100644 index 80099388d6354..0000000000000 --- a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.stderr +++ /dev/null @@ -1,15 +0,0 @@ -warning: type `dst::Zst` is more private than the item `Dst::field` - --> $DIR/should_accept_if_dst_has_unreachable_field.rs:34:9 - | -LL | pub(in super) field: Zst, - | ^^^^^^^^^^^^^^^^^^^^^^^^ field `Dst::field` is reachable at visibility `pub(crate)` - | -note: but type `dst::Zst` is only usable at visibility `pub(self)` - --> $DIR/should_accept_if_dst_has_unreachable_field.rs:31:16 - | -LL | #[repr(C)] pub(self) struct Zst; // <- unreachable type - | ^^^^^^^^^^^^^^^^^^^^ - = note: `#[warn(private_interfaces)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.rs b/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.rs deleted file mode 100644 index b9b74d18338af..0000000000000 --- a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.rs +++ /dev/null @@ -1,40 +0,0 @@ -//! If visibility is assumed, a transmutation should be accepted even if the -//! destination type contains an unreachable field (e.g., a public field with a -//! private type). (This rule is distinct from type privacy, which still may -//! forbid naming such types.) - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom - // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ - {} -} - -mod src { - #[repr(C)] pub(self) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(self) field: Zst, - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - // unreachable type - #[repr(C)] pub(self) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); //~ ERROR `Dst` is private -} diff --git a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.stderr b/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.stderr deleted file mode 100644 index cf94d72b883dc..0000000000000 --- a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0603]: struct `Dst` is private - --> $DIR/should_accept_if_dst_has_unreachable_ty.rs:39:46 - | -LL | assert::is_transmutable::(); - | ^^^ private struct - | -note: the struct `Dst` is defined here - --> $DIR/should_accept_if_dst_has_unreachable_ty.rs:32:16 - | -LL | #[repr(C)] pub(self) struct Dst { - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/transmutability/visibility/should_accept_if_src_has_private_field.rs b/tests/ui/transmutability/visibility/should_accept_if_src_has_private_field.rs deleted file mode 100644 index 22392c53905ed..0000000000000 --- a/tests/ui/transmutability/visibility/should_accept_if_src_has_private_field.rs +++ /dev/null @@ -1,37 +0,0 @@ -//@ check-pass -//! The presence of a private field 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() - where - Dst: BikeshedIntrinsicFrom // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(self) field: Zst, // <- private field - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); -} diff --git a/tests/ui/transmutability/visibility/should_accept_if_src_has_private_variant.rs b/tests/ui/transmutability/visibility/should_accept_if_src_has_private_variant.rs deleted file mode 100644 index 876db7c658953..0000000000000 --- a/tests/ui/transmutability/visibility/should_accept_if_src_has_private_variant.rs +++ /dev/null @@ -1,38 +0,0 @@ -//@ check-pass -//! The presence of a private variant 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() - where - Dst: BikeshedIntrinsicFrom // safety is NOT assumed - {} -} - -mod src { - #[derive(Copy, Clone)] - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) union Src { - pub(self) field: Zst, // <- private variant - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); -} diff --git a/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs b/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs deleted file mode 100644 index 8b6db9ff150da..0000000000000 --- a/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs +++ /dev/null @@ -1,39 +0,0 @@ -//@ check-pass - -//! The presence of an unreachable field in the source type (e.g., a public -//! field with a private type does not affect transmutability. (This rule is -//! distinct from type privacy, which still may forbid naming such types.) - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(self) struct Zst; // <- unreachable type - - #[repr(C)] pub(in super) struct Src { - pub(in super) field: Zst, //~ WARNING type `src::Zst` is more private than the item `Src::field` - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); -} diff --git a/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr b/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr deleted file mode 100644 index 55fb339230578..0000000000000 --- a/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr +++ /dev/null @@ -1,15 +0,0 @@ -warning: type `src::Zst` is more private than the item `Src::field` - --> $DIR/should_accept_if_src_has_unreachable_field.rs:24:9 - | -LL | pub(in super) field: Zst, - | ^^^^^^^^^^^^^^^^^^^^^^^^ field `Src::field` is reachable at visibility `pub(crate)` - | -note: but type `src::Zst` is only usable at visibility `pub(self)` - --> $DIR/should_accept_if_src_has_unreachable_field.rs:21:16 - | -LL | #[repr(C)] pub(self) struct Zst; // <- unreachable type - | ^^^^^^^^^^^^^^^^^^^^ - = note: `#[warn(private_interfaces)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.rs b/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.rs deleted file mode 100644 index acf9f2302500a..0000000000000 --- a/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.rs +++ /dev/null @@ -1,38 +0,0 @@ -//! The presence of an unreachable source type (i.e., the source type is -//! private) does not affect transmutability. (This rule is distinct from type -//! privacy, which still may forbid naming such types.) - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - // unreachable type - #[repr(C)] pub(self) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); //~ ERROR `Src` is private -} diff --git a/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.stderr b/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.stderr deleted file mode 100644 index 57ceac61f16de..0000000000000 --- a/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0603]: struct `Src` is private - --> $DIR/should_accept_if_src_has_unreachable_ty.rs:37:36 - | -LL | assert::is_transmutable::(); - | ^^^ private struct - | -note: the struct `Src` is defined here - --> $DIR/should_accept_if_src_has_unreachable_ty.rs:22:16 - | -LL | #[repr(C)] pub(self) struct Src { - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_field.rs b/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_field.rs deleted file mode 100644 index e8c3fbc9a0469..0000000000000 --- a/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_field.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! Unless visibility is assumed, a transmutation should be rejected if the -//! destination type contains a private field. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Dst { - pub(self) field: Zst, // <- private field - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted -} diff --git a/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr b/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr deleted file mode 100644 index cb2e7ec29a5b5..0000000000000 --- a/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context` - --> $DIR/should_reject_if_dst_has_private_field.rs:35:41 - | -LL | assert::is_transmutable::(); - | ^^^^^^^^ `Dst` is or contains a type or field that is not visible in that scope - | -note: required by a bound in `is_transmutable` - --> $DIR/should_reject_if_dst_has_private_field.rs:13:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this function -LL | where -LL | Dst: BikeshedIntrinsicFrom // 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`. diff --git a/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.rs b/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.rs deleted file mode 100644 index 47bca27abaa88..0000000000000 --- a/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! Unless visibility is assumed, a transmutation should be rejected if the -//! destination type contains a private variant. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - #[derive(Copy, Clone)] - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) union Dst { - pub(self) field: Zst, // <- private variant - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted -} diff --git a/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr b/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr deleted file mode 100644 index 434c3fcd278e7..0000000000000 --- a/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context` - --> $DIR/should_reject_if_dst_has_private_variant.rs:36:41 - | -LL | assert::is_transmutable::(); - | ^^^^^^^^ `Dst` is or contains a type or field that is not visible in that scope - | -note: required by a bound in `is_transmutable` - --> $DIR/should_reject_if_dst_has_private_variant.rs:13:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this function -LL | where -LL | Dst: BikeshedIntrinsicFrom // 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`. diff --git a/tests/ui/transmutability/visibility/should_reject_if_dst_has_tricky_unreachable_field.rs b/tests/ui/transmutability/visibility/should_reject_if_dst_has_tricky_unreachable_field.rs deleted file mode 100644 index 9b7b940ca691c..0000000000000 --- a/tests/ui/transmutability/visibility/should_reject_if_dst_has_tricky_unreachable_field.rs +++ /dev/null @@ -1,51 +0,0 @@ -//@ check-pass -//! NOTE: This test documents a known-bug in the implementation of the -//! transmutability trait. Once fixed, the above "check-pass" header should be -//! removed, and an "ERROR cannot be safely transmuted" annotation should be added at the end -//! of the line starting with `assert::is_transmutable`. -//! -//! Unless visibility is assumed, a transmutation should be rejected if the -//! destination type contains an unreachable field (e.g., a public field with a -//! private type). (This rule is distinct from type privacy, which still may -//! forbid naming such types.) -//! -//! This test exercises a tricky-to-implement instance of this principle: the -//! "pub-in-priv trick". In the below example, the type `dst::private::Zst` is -//! unreachable from `Context`. Consequently, the transmute from `Src` to `Dst` -//! SHOULD be rejected. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - mod private { - #[repr(C)] pub struct Zst; // <- unreachable type - } - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: private::Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); -} diff --git a/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.rs b/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.rs deleted file mode 100644 index d7e21676fd385..0000000000000 --- a/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.rs +++ /dev/null @@ -1,38 +0,0 @@ -//! Unless visibility is assumed, a transmutation should be rejected if the -//! destination type contains an unreachable field (e.g., a public field with a -//! private type). (This rule is distinct from type privacy, which still may -//! forbid naming such types.) - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - #[repr(C)] pub(self) struct Zst; // <- unreachable type - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted -} diff --git a/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr b/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr deleted file mode 100644 index e987aa595b96f..0000000000000 --- a/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context` - --> $DIR/should_reject_if_dst_has_unreachable_field.rs:37:41 - | -LL | assert::is_transmutable::(); - | ^^^^^^^^ `Dst` is or contains a type or field that is not visible in that scope - | -note: required by a bound in `is_transmutable` - --> $DIR/should_reject_if_dst_has_unreachable_field.rs:15:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this function -LL | where -LL | Dst: BikeshedIntrinsicFrom // 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`. diff --git a/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.rs b/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.rs deleted file mode 100644 index c7b59f15b99cc..0000000000000 --- a/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Unless visibility is assumed, a transmutation should be rejected if the -//! destination type contains an unreachable field (e.g., a public field with a -//! private type). (This rule is distinct from type privacy, which still may -//! forbid naming such types.) - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - // unreachable type - #[repr(C)] pub(self) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::(); - //~^ ERROR `Dst` is private - //~| ERROR cannot be safely transmuted -} diff --git a/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr b/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr deleted file mode 100644 index ea488980cdd14..0000000000000 --- a/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0603]: struct `Dst` is private - --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:38:46 - | -LL | assert::is_transmutable::(); - | ^^^ private struct - | -note: the struct `Dst` is defined here - --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:31:16 - | -LL | #[repr(C)] pub(self) struct Dst { - | ^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context` - --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:38:41 - | -LL | assert::is_transmutable::(); - | ^^^^^^^^ `Dst` is or contains a type or field that is not visible in that scope - | -note: required by a bound in `is_transmutable` - --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:15:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this function -LL | where -LL | Dst: BikeshedIntrinsicFrom // safety is NOT assumed - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0277, E0603. -For more information about an error, try `rustc --explain E0277`.