From ac23a2e5cd288ea6c160ecd51ea64662d3443dd4 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 6 Aug 2024 11:12:45 +0200 Subject: [PATCH 1/6] bump conflicting_repr_hints lint to be shown in dependencies --- compiler/rustc_lint_defs/src/builtin.rs | 2 +- .../feature-gate-repr-simd.stderr | 14 +++++++++++ tests/ui/issues/issue-47094.stderr | 25 +++++++++++++++++++ tests/ui/repr/conflicting-repr-hints.stderr | 22 ++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index ff0bdfcc9d261..0bfc3d11c2f65 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -250,7 +250,7 @@ declare_lint! { Deny, "conflicts between `#[repr(..)]` hints that were previously accepted and used in practice", @future_incompatible = FutureIncompatibleInfo { - reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps, + reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps, reference: "issue #68585 ", }; } diff --git a/tests/ui/feature-gates/feature-gate-repr-simd.stderr b/tests/ui/feature-gates/feature-gate-repr-simd.stderr index 5b490c0c0c33f..5a0ceb2dd74fb 100644 --- a/tests/ui/feature-gates/feature-gate-repr-simd.stderr +++ b/tests/ui/feature-gates/feature-gate-repr-simd.stderr @@ -35,3 +35,17 @@ error: aborting due to 3 previous errors Some errors have detailed explanations: E0566, E0658. For more information about an error, try `rustc --explain E0566`. +Future incompatibility report: Future breakage diagnostic: +error[E0566]: conflicting representation hints + --> $DIR/feature-gate-repr-simd.rs:4:8 + | +LL | #[repr(C)] + | ^ +LL | +LL | #[repr(simd)] + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #68585 + = note: `#[deny(conflicting_repr_hints)]` on by default + diff --git a/tests/ui/issues/issue-47094.stderr b/tests/ui/issues/issue-47094.stderr index 970e318471049..1c6693403b85b 100644 --- a/tests/ui/issues/issue-47094.stderr +++ b/tests/ui/issues/issue-47094.stderr @@ -23,3 +23,28 @@ LL | #[repr(u8)] error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0566`. +Future incompatibility report: Future breakage diagnostic: +error[E0566]: conflicting representation hints + --> $DIR/issue-47094.rs:1:8 + | +LL | #[repr(C, u8)] + | ^ ^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #68585 + = note: `#[deny(conflicting_repr_hints)]` on by default + +Future breakage diagnostic: +error[E0566]: conflicting representation hints + --> $DIR/issue-47094.rs:8:8 + | +LL | #[repr(C)] + | ^ +LL | +LL | #[repr(u8)] + | ^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #68585 + = note: `#[deny(conflicting_repr_hints)]` on by default + diff --git a/tests/ui/repr/conflicting-repr-hints.stderr b/tests/ui/repr/conflicting-repr-hints.stderr index 4dcd8f4fc280a..fbfa69e7fb145 100644 --- a/tests/ui/repr/conflicting-repr-hints.stderr +++ b/tests/ui/repr/conflicting-repr-hints.stderr @@ -81,3 +81,25 @@ error: aborting due to 12 previous errors Some errors have detailed explanations: E0566, E0587, E0634. For more information about an error, try `rustc --explain E0566`. +Future incompatibility report: Future breakage diagnostic: +error[E0566]: conflicting representation hints + --> $DIR/conflicting-repr-hints.rs:13:8 + | +LL | #[repr(C, u64)] + | ^ ^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #68585 + = note: `#[deny(conflicting_repr_hints)]` on by default + +Future breakage diagnostic: +error[E0566]: conflicting representation hints + --> $DIR/conflicting-repr-hints.rs:19:8 + | +LL | #[repr(u32, u64)] + | ^^^ ^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #68585 + = note: `#[deny(conflicting_repr_hints)]` on by default + From 1faccbaadc53c167fcb16bdd8498dc05aabef126 Mon Sep 17 00:00:00 2001 From: ivmarkov Date: Sun, 18 Aug 2024 11:29:50 +0000 Subject: [PATCH 2/6] Fix for issue #129212 for the ESP-IDF --- library/std/src/sys/pal/unix/thread.rs | 30 ++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index 0fa610eebb4ef..c9dcc5ad97a50 100644 --- a/library/std/src/sys/pal/unix/thread.rs +++ b/library/std/src/sys/pal/unix/thread.rs @@ -267,14 +267,32 @@ impl Thread { #[cfg(target_os = "espidf")] pub fn sleep(dur: Duration) { - let mut micros = dur.as_micros(); - unsafe { - while micros > 0 { - let st = if micros > u32::MAX as u128 { u32::MAX } else { micros as u32 }; + // ESP-IDF does not have `nanosleep`, so we use `usleep` instead. + // As per the documentation of `usleep`, it is expected to support + // sleep times as big as at least up to 1 second. + // + // ESP-IDF does support almost up to `u32::MAX`, but due to a potential integer overflow in its + // `usleep` implementation + // (https://github.com/espressif/esp-idf/blob/d7ca8b94c852052e3bc33292287ef4dd62c9eeb1/components/newlib/time.c#L210), + // we limit the sleep time to the maximum one that would not cause the underlying `usleep` implementation to overflow + // (`portTICK_PERIOD_MS` can be anything between 1 to 1000, and is 10 by default). + const MAX_MICROS: u32 = u32::MAX - 1_000_000 - 1; + + // Add any nanoseconds smaller than a microsecond as an extra microsecond + // so as to comply with the `std::thread::sleep` contract which mandates + // implementations to sleep for _at least_ the provided `dur`. + // We can't overflow `micros` as it is a `u128`, while `Duration` is a pair of + // (`u64` secs, `u32` nanos), where the nanos are strictly smaller than 1 second + // (i.e. < 1_000_000_000) + let mut micros = dur.as_micros() + if dur.subsec_nanos() % 1_000 > 0 { 1 } else { 0 }; + + while micros > 0 { + let st = if micros > MAX_MICROS as u128 { MAX_MICROS } else { micros as u32 }; + unsafe { libc::usleep(st); - - micros -= st as u128; } + + micros -= st as u128; } } From 490818851860fb257e23fe7aa0ee32eaffc4ba40 Mon Sep 17 00:00:00 2001 From: Arthur Carcano Date: Tue, 20 Aug 2024 18:41:42 +0200 Subject: [PATCH 3/6] Change neutral element of to neg_zero The neutral element used to be positive zero, but +0 + -0 = +0 so -0 seems better indicated. --- library/core/src/iter/traits/accum.rs | 4 +-- .../core/tests/num/float_iter_sum_identity.rs | 27 +++++++++++++++++++ library/core/tests/num/mod.rs | 1 + 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 library/core/tests/num/float_iter_sum_identity.rs diff --git a/library/core/src/iter/traits/accum.rs b/library/core/src/iter/traits/accum.rs index c97cd042ab459..5b7d95c2f65e6 100644 --- a/library/core/src/iter/traits/accum.rs +++ b/library/core/src/iter/traits/accum.rs @@ -104,7 +104,7 @@ macro_rules! float_sum_product { impl Sum for $a { fn sum>(iter: I) -> Self { iter.fold( - 0.0, + -0.0, #[rustc_inherit_overflow_checks] |a, b| a + b, ) @@ -126,7 +126,7 @@ macro_rules! float_sum_product { impl<'a> Sum<&'a $a> for $a { fn sum>(iter: I) -> Self { iter.fold( - 0.0, + -0.0, #[rustc_inherit_overflow_checks] |a, b| a + b, ) diff --git a/library/core/tests/num/float_iter_sum_identity.rs b/library/core/tests/num/float_iter_sum_identity.rs new file mode 100644 index 0000000000000..6d3224522a830 --- /dev/null +++ b/library/core/tests/num/float_iter_sum_identity.rs @@ -0,0 +1,27 @@ +#[test] +fn f32_ref() { + let x: f32 = -0.0; + let still_x: f32 = [x].iter().sum(); + assert_eq!(1. / x, 1. / still_x) +} + +#[test] +fn f32_own() { + let x: f32 = -0.0; + let still_x: f32 = [x].into_iter().sum(); + assert_eq!(1. / x, 1. / still_x) +} + +#[test] +fn f64_ref() { + let x: f64 = -0.0; + let still_x: f64 = [x].iter().sum(); + assert_eq!(1. / x, 1. / still_x) +} + +#[test] +fn f64_own() { + let x: f64 = -0.0; + let still_x: f64 = [x].into_iter().sum(); + assert_eq!(1. / x, 1. / still_x) +} diff --git a/library/core/tests/num/mod.rs b/library/core/tests/num/mod.rs index 9d2912c4b22dc..53ff5ab1cedd1 100644 --- a/library/core/tests/num/mod.rs +++ b/library/core/tests/num/mod.rs @@ -30,6 +30,7 @@ mod int_log; mod ops; mod wrapping; +mod float_iter_sum_identity; mod ieee754; mod nan; From b509b4226b371a7df226532e253604fb113a9489 Mon Sep 17 00:00:00 2001 From: Krasimir Georgiev Date: Wed, 21 Aug 2024 09:58:11 +0000 Subject: [PATCH 4/6] llvm-wrapper: adapt for LLVM 20 API changes No functional changes intended. Adapts llvm-wrapper for the LLVM commits https://github.com/llvm/llvm-project/commit/0f22d47a7a1f70ec77ea8ccdf08a6487827937db and https://github.com/llvm/llvm-project/commit/d6d8243dcd4ea768549904036ed31b8e59e14c73. --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 283c4fbbb7cf4..9884ed15b8a1f 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -1607,8 +1607,13 @@ extern "C" void LLVMRustComputeLTOCacheKey(RustStringRef KeyOut, const auto &ExportList = Data->ExportLists.lookup(ModId); const auto &ResolvedODR = Data->ResolvedODR.lookup(ModId); const auto &DefinedGlobals = Data->ModuleToDefinedGVSummaries.lookup(ModId); +#if LLVM_VERSION_GE(20, 0) + DenseSet CfiFunctionDefs; + DenseSet CfiFunctionDecls; +#else std::set CfiFunctionDefs; std::set CfiFunctionDecls; +#endif // Based on the 'InProcessThinBackend' constructor in LLVM for (auto &Name : Data->Index.cfiFunctionDefs()) @@ -1618,9 +1623,15 @@ extern "C" void LLVMRustComputeLTOCacheKey(RustStringRef KeyOut, CfiFunctionDecls.insert( GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(Name))); +#if LLVM_VERSION_GE(20, 0) + Key = llvm::computeLTOCacheKey(conf, Data->Index, ModId, ImportList, + ExportList, ResolvedODR, DefinedGlobals, + CfiFunctionDefs, CfiFunctionDecls); +#else llvm::computeLTOCacheKey(Key, conf, Data->Index, ModId, ImportList, ExportList, ResolvedODR, DefinedGlobals, CfiFunctionDefs, CfiFunctionDecls); +#endif LLVMRustStringWriteImpl(KeyOut, Key.c_str(), Key.size()); } From b6909ce61e580d7e57c2539d9ae36437bfdb091d Mon Sep 17 00:00:00 2001 From: Urgau Date: Wed, 21 Aug 2024 19:05:35 +0200 Subject: [PATCH 5/6] Force `LC_ALL=C` for all run-make tests --- src/tools/run-make-support/src/run.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/run-make-support/src/run.rs b/src/tools/run-make-support/src/run.rs index 12088e5d3b5ae..3eeba6fd5263d 100644 --- a/src/tools/run-make-support/src/run.rs +++ b/src/tools/run-make-support/src/run.rs @@ -29,6 +29,7 @@ fn run_common(name: &str, args: Option<&[&str]>) -> Command { } env::join_paths(paths.iter()).unwrap() }); + cmd.env("LC_ALL", "C"); // force english locale if is_windows() { let mut paths = vec![]; @@ -84,5 +85,6 @@ pub fn run_fail(name: &str) -> CompletedProcess { pub fn cmd>(program: S) -> Command { let mut command = Command::new(program); set_host_rpath(&mut command); + command.env("LC_ALL", "C"); // force english locale command } From e2328ebd7f37fdfa5059fa8da954d198f6f744f7 Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Wed, 21 Aug 2024 17:01:32 +0000 Subject: [PATCH 6/6] safe transmute: gracefully bubble-up layout errors Changes `.unwrap()`s to `?` to avoid ICEs. Adds ui tests. Fixes #129327 --- compiler/rustc_transmute/src/layout/tree.rs | 18 +++----- .../src/maybe_transmutable/mod.rs | 13 ++---- .../ui/transmutability/arrays/huge-len.stderr | 4 +- .../unknown_dst_field.rs | 26 +++++++++++ .../unknown_dst_field.stderr | 46 +++++++++++++++++++ .../unknown_src_field.rs | 12 +++-- .../unknown_src_field.stderr | 31 +++++++++++-- .../transmute_infinitely_recursive_type.rs | 1 - ...transmute_infinitely_recursive_type.stderr | 19 +------- 9 files changed, 121 insertions(+), 49 deletions(-) create mode 100644 tests/ui/transmutability/malformed-program-gracefulness/unknown_dst_field.rs create mode 100644 tests/ui/transmutability/malformed-program-gracefulness/unknown_dst_field.stderr diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs index 7c73f74e6290b..2c67e7d4847ac 100644 --- a/compiler/rustc_transmute/src/layout/tree.rs +++ b/compiler/rustc_transmute/src/layout/tree.rs @@ -179,7 +179,7 @@ pub(crate) mod rustc { }; use super::Tree; - use crate::layout::rustc::{Def, Ref}; + use crate::layout::rustc::{layout_of, Def, Ref}; #[derive(Debug, Copy, Clone)] pub(crate) enum Err { @@ -206,7 +206,7 @@ pub(crate) mod rustc { impl<'tcx> Tree, Ref<'tcx>> { pub fn from_ty(ty: Ty<'tcx>, cx: LayoutCx<'tcx, TyCtxt<'tcx>>) -> Result { use rustc_target::abi::HasDataLayout; - let layout = ty_layout(cx, ty); + let layout = layout_of(cx, ty)?; if let Err(e) = ty.error_reported() { return Err(Err::TypeError(e)); @@ -239,7 +239,7 @@ pub(crate) mod rustc { let FieldsShape::Array { stride, count } = &layout.fields else { return Err(Err::NotYetSupported); }; - let inner_layout = ty_layout(cx, *inner_ty); + let inner_layout = layout_of(cx, *inner_ty)?; assert_eq!(*stride, inner_layout.size); let elt = Tree::from_ty(*inner_ty, cx)?; Ok(std::iter::repeat(elt) @@ -254,7 +254,7 @@ pub(crate) mod rustc { }, ty::Ref(lifetime, ty, mutability) => { - let layout = ty_layout(cx, *ty); + let layout = layout_of(cx, *ty)?; let align = layout.align.abi.bytes_usize(); let size = layout.size.bytes_usize(); Ok(Tree::Ref(Ref { @@ -280,7 +280,7 @@ pub(crate) mod rustc { FieldsShape::Primitive => { assert_eq!(members.len(), 1); let inner_ty = members[0]; - let inner_layout = ty_layout(cx, inner_ty); + let inner_layout = layout_of(cx, inner_ty)?; Self::from_ty(inner_ty, cx) } FieldsShape::Arbitrary { offsets, .. } => { @@ -413,7 +413,7 @@ pub(crate) mod rustc { let padding = Self::padding(padding_needed.bytes_usize()); let field_ty = ty_field(cx, (ty, layout), field_idx); - let field_layout = ty_layout(cx, field_ty); + let field_layout = layout_of(cx, field_ty)?; let field_tree = Self::from_ty(field_ty, cx)?; struct_tree = struct_tree.then(padding).then(field_tree); @@ -471,7 +471,7 @@ pub(crate) mod rustc { |fields, (idx, field_def)| { let field_def = Def::Field(field_def); let field_ty = ty_field(cx, (ty, layout), idx); - let field_layout = ty_layout(cx, field_ty); + let field_layout = layout_of(cx, field_ty)?; let field = Self::from_ty(field_ty, cx)?; let trailing_padding_needed = layout.size - field_layout.size; let trailing_padding = Self::padding(trailing_padding_needed.bytes_usize()); @@ -484,10 +484,6 @@ pub(crate) mod rustc { } } - pub(crate) fn ty_layout<'tcx>(cx: LayoutCx<'tcx, TyCtxt<'tcx>>, ty: Ty<'tcx>) -> Layout<'tcx> { - crate::layout::rustc::layout_of(cx, ty).unwrap() - } - fn ty_field<'tcx>( cx: LayoutCx<'tcx, TyCtxt<'tcx>>, (ty, layout): (Ty<'tcx>, Layout<'tcx>), diff --git a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs index 1f3c4e3c817de..2762b4e638405 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs @@ -44,18 +44,11 @@ mod rustc { let Self { src, dst, assume, context } = self; let layout_cx = LayoutCx { tcx: context, param_env: ParamEnv::reveal_all() }; - let layout_of = |ty| { - crate::layout::rustc::layout_of(layout_cx, ty) - .map_err(|_| Err::NotYetSupported) - .and_then(|_| Tree::from_ty(ty, layout_cx)) - }; // Convert `src` and `dst` from their rustc representations, to `Tree`-based - // representations. If these conversions fail, conclude that the transmutation is - // unacceptable; the layouts of both the source and destination types must be - // well-defined. - let src = layout_of(src); - let dst = layout_of(dst); + // representations. + let src = Tree::from_ty(src, layout_cx); + let dst = Tree::from_ty(dst, layout_cx); match (src, dst) { (Err(Err::TypeError(_)), _) | (_, Err(Err::TypeError(_))) => { diff --git a/tests/ui/transmutability/arrays/huge-len.stderr b/tests/ui/transmutability/arrays/huge-len.stderr index 3fc652f47c12b..37160c5c9596b 100644 --- a/tests/ui/transmutability/arrays/huge-len.stderr +++ b/tests/ui/transmutability/arrays/huge-len.stderr @@ -2,7 +2,7 @@ error[E0277]: `()` cannot be safely transmuted into `ExplicitlyPadded` --> $DIR/huge-len.rs:21:41 | LL | assert::is_maybe_transmutable::<(), ExplicitlyPadded>(); - | ^^^^^^^^^^^^^^^^ analyzing the transmutability of `ExplicitlyPadded` is not yet supported + | ^^^^^^^^^^^^^^^^ values of the type `ExplicitlyPadded` are too big for the current architecture | note: required by a bound in `is_maybe_transmutable` --> $DIR/huge-len.rs:8:14 @@ -17,7 +17,7 @@ error[E0277]: `ExplicitlyPadded` cannot be safely transmuted into `()` --> $DIR/huge-len.rs:24:55 | LL | assert::is_maybe_transmutable::(); - | ^^ analyzing the transmutability of `ExplicitlyPadded` is not yet supported + | ^^ values of the type `ExplicitlyPadded` are too big for the current architecture | note: required by a bound in `is_maybe_transmutable` --> $DIR/huge-len.rs:8:14 diff --git a/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst_field.rs b/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst_field.rs new file mode 100644 index 0000000000000..8c18de111967f --- /dev/null +++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst_field.rs @@ -0,0 +1,26 @@ +// An unknown destination type should be gracefully handled. + +#![crate_type = "lib"] +#![feature(transmutability)] +#![allow(incomplete_features)] + +mod assert { + use std::mem::BikeshedIntrinsicFrom; + + pub fn is_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn should_gracefully_handle_unknown_dst_field() { + #[repr(C)] struct Src; + #[repr(C)] struct Dst(Missing); //~ cannot find type + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted +} + +fn should_gracefully_handle_unknown_dst_ref_field() { + #[repr(C)] struct Src(&'static Src); + #[repr(C)] struct Dst(&'static Missing); //~ cannot find type + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted +} diff --git a/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst_field.stderr b/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst_field.stderr new file mode 100644 index 0000000000000..df10919f6d3f0 --- /dev/null +++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst_field.stderr @@ -0,0 +1,46 @@ +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/unknown_dst_field.rs:18:27 + | +LL | #[repr(C)] struct Dst(Missing); + | ^^^^^^^ not found in this scope + +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/unknown_dst_field.rs:24:36 + | +LL | #[repr(C)] struct Dst(&'static Missing); + | ^^^^^^^ not found in this scope + +error[E0277]: `should_gracefully_handle_unknown_dst_field::Src` cannot be safely transmuted into `should_gracefully_handle_unknown_dst_field::Dst` + --> $DIR/unknown_dst_field.rs:19:36 + | +LL | assert::is_transmutable::(); + | ^^^ `should_gracefully_handle_unknown_dst_field::Dst` has an unknown layout + | +note: required by a bound in `is_transmutable` + --> $DIR/unknown_dst_field.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` + +error[E0277]: `should_gracefully_handle_unknown_dst_ref_field::Src` cannot be safely transmuted into `should_gracefully_handle_unknown_dst_ref_field::Dst` + --> $DIR/unknown_dst_field.rs:25:36 + | +LL | assert::is_transmutable::(); + | ^^^ `should_gracefully_handle_unknown_dst_ref_field::Dst` has an unknown layout + | +note: required by a bound in `is_transmutable` + --> $DIR/unknown_dst_field.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` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0277, E0412. +For more information about an error, try `rustc --explain E0277`. 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 58c16d773e17a..1da16e67223de 100644 --- a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs +++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs @@ -13,8 +13,14 @@ mod assert { {} } -fn should_gracefully_handle_unknown_dst_field() { - #[repr(C)] struct Src; - #[repr(C)] struct Dst(Missing); //~ cannot find type +fn should_gracefully_handle_unknown_src_field() { + #[repr(C)] struct Src(Missing); //~ cannot find type + #[repr(C)] struct Dst(); + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted +} + +fn should_gracefully_handle_unknown_src_ref_field() { + #[repr(C)] struct Src(&'static Missing); //~ cannot find type + #[repr(C)] struct Dst(&'static Dst); 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 cabc7bcfef762..6ec66e1706146 100644 --- a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr +++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr @@ -1,14 +1,35 @@ error[E0412]: cannot find type `Missing` in this scope - --> $DIR/unknown_src_field.rs:18:27 + --> $DIR/unknown_src_field.rs:17:27 | -LL | #[repr(C)] struct Dst(Missing); +LL | #[repr(C)] struct Src(Missing); | ^^^^^^^ not found in this scope -error[E0277]: `Src` cannot be safely transmuted into `Dst` +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/unknown_src_field.rs:23:36 + | +LL | #[repr(C)] struct Src(&'static Missing); + | ^^^^^^^ not found in this scope + +error[E0277]: `should_gracefully_handle_unknown_src_field::Src` cannot be safely transmuted into `should_gracefully_handle_unknown_src_field::Dst` --> $DIR/unknown_src_field.rs:19:36 | LL | assert::is_transmutable::(); - | ^^^ analyzing the transmutability of `Dst` is not yet supported + | ^^^ `should_gracefully_handle_unknown_src_field::Src` has an unknown layout + | +note: required by a bound in `is_transmutable` + --> $DIR/unknown_src_field.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` + +error[E0277]: `should_gracefully_handle_unknown_src_ref_field::Src` cannot be safely transmuted into `should_gracefully_handle_unknown_src_ref_field::Dst` + --> $DIR/unknown_src_field.rs:25:36 + | +LL | assert::is_transmutable::(); + | ^^^ `should_gracefully_handle_unknown_src_ref_field::Src` has an unknown layout | note: required by a bound in `is_transmutable` --> $DIR/unknown_src_field.rs:12:14 @@ -19,7 +40,7 @@ LL | where LL | Dst: BikeshedIntrinsicFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0412. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.rs b/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.rs index 64110753832cb..4c285a616b3d9 100644 --- a/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.rs +++ b/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.rs @@ -22,5 +22,4 @@ fn should_pad_explicitly_packed_field() { //~^ ERROR: recursive type assert::is_maybe_transmutable::(); - //~^ ERROR: cannot be safely transmuted } 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 ebfb536114367..7fb051f66250e 100644 --- a/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr +++ b/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr @@ -15,22 +15,7 @@ error[E0391]: cycle detected when computing layout of `should_pad_explicitly_pac = 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[E0277]: `ExplicitlyPadded` cannot be safely transmuted into `()` - --> $DIR/transmute_infinitely_recursive_type.rs:24:55 - | -LL | assert::is_maybe_transmutable::(); - | ^^ analyzing the transmutability of `ExplicitlyPadded` is not yet supported - | -note: required by a bound in `is_maybe_transmutable` - --> $DIR/transmute_infinitely_recursive_type.rs:14: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: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0072, E0277, E0391. +Some errors have detailed explanations: E0072, E0391. For more information about an error, try `rustc --explain E0072`.