Closed mejrs closed 6 months ago
A duplicate
#[rustc_layout_scalar_valid_range_start(1)]
struct S<T> {
i: u8,
t: T,
}
struct A((u32, u32));
static Ca: S<A>;
Fixed on the latest nightly, marking as E-needs-test @rustbot labels: +E-needs-test
This still panics on current nightly
#![feature(rustc_attrs)]
#[rustc_layout_scalar_valid_range_end(38)]
#[repr(packed)]
struct Len(u16);
impl Clone for Len {
fn clone(&self) -> Self {
unsafe { Len(self.0) }
}
}
Yea, that internal attribute may only be used in very specific circumstances that the layout code describes. Please do not use it outside the standard library or the compiler
The compiler will panic when all these attributes are enabled at once. Note the commented-out code that triggers a related panic.
Code
Playground
Meta
rustc --version --verbose
:Error output
Backtrace
``` stack backtrace: 0: 0x7ff9efe0857e -::fmt::h160322fcc0f12a19
1: 0x7ff9efe3461b - core::fmt::write::ha3ea633b18d2da75
2: 0x7ff9efdfb6c8 - ::fmt::h0112a934cd010a1c
3: 0x7ff9efe0c74d - std::panicking::take_hook::h7c389d310fc84231
4: 0x7ff9efe0c219 - std::panicking::take_hook::h7c389d310fc84231
5: 0x7ff9db5e7fb7 - rustc_driver::report_ice::hd4f773c8d782ddcc
6: 0x7ff9efe0d1b2 - std::panicking::rust_panic_with_hook::h13af0da83034d6f3
7: 0x7ff9efe0cca1 - rust_begin_unwind
8: 0x7ff9efe08f0f - ::fmt::h160322fcc0f12a19
9: 0x7ff9efe0cbf9 - rust_begin_unwind
10: 0x7ff9efe0cbac - std::panicking::begin_panic_fmt::he3c286d5fa8e7e0e
11: 0x7ff9df76efdc - rustc_middle::ty::layout::provide::h744eb072f27cc1fb
12: 0x7ff9df762eee - ::fmt::heca06e76b524fab9
13: 0x7ff9df6c733e - ::visit_lifetime::h8f7e64a9af649c18
14: 0x7ff9df92a7af - rustc_middle::dep_graph::::debug_node::h9ab25c38d7e58d1f
15: 0x7ff9df99538f - rustc_middle::ty::structural_impls::::lift_to_tcx::hb296e5db2f221b13
16: 0x7ff9df71ee49 - ::fmt::h92978b980e216966
17: 0x7ff9df68bc2c - ::visit_lifetime::h8f7e64a9af649c18
18: 0x7ff9df5ab1f9 - ::visit_lifetime::h8f7e64a9af649c18
19: 0x7ff9df772055 - as rustc_target::abi::LayoutOf>::layout_of::h163bea4617d945e6
20: 0x7ff9db9e8672 - ::layout_of::h8a1f9503e576acc2
21: 0x7ff9db8f7bbe - as rustc_codegen_llvm::abi::FnAbiLlvmExt>::apply_attrs_callsite::h7396d38e02214aaa
22: 0x7ff9db8b25ec - ::drop::ha2c97848c144591f
23: 0x7ff9db8b4747 - ::drop::ha2c97848c144591f
24: 0x7ff9db9db57a - ::fmt::he99486cc7e05be9d
25: 0x7ff9db8afa1f - ::drop::ha2c97848c144591f
26: 0x7ff9db8f0a8a - as rustc_codegen_llvm::abi::FnAbiLlvmExt>::apply_attrs_callsite::h7396d38e02214aaa
27: 0x7ff9db8b086e - ::drop::ha2c97848c144591f
28: 0x7ff9db9eb32a - rustc_codegen_llvm::mono_item::::predefine_fn::hedf0f64e9e762a10
29: 0x7ff9db8ac83b - ::next::h587d021e0c727ed0
30: 0x7ff9db8fc68e - as rustc_codegen_llvm::abi::FnAbiLlvmExt>::apply_attrs_callsite::h7396d38e02214aaa
31: 0x7ff9dba1ba25 - ::fmt::hdb8b973c68ec0bd5
32: 0x7ff9db8ac453 - ::next::h587d021e0c727ed0
33: 0x7ff9db9d38a1 - ::codegen_crate::hd916541c477771f1
34: 0x7ff9db801431 - rustc_interface::queries::Queries::ongoing_codegen::hf5bf7ace4f995c32
35: 0x7ff9db612ac4 - rustc_ast::util::parser::prec_let_scrutinee_needs_par::hfc7ab7b91c80b01e
36: 0x7ff9db5ec17c - ::fmt::h565c544a3fcd0386
37: 0x7ff9db609009 - ::fmt::h565c544a3fcd0386
38: 0x7ff9db615cee - rustc_ast::util::parser::prec_let_scrutinee_needs_par::hfc7ab7b91c80b01e
39: 0x7ff9db58962d - ::fmt::ha43055df5546b109
40: 0x7ff9efe1c9fa - std::sys::windows::thread::Thread::new::hd38a560d738a063d
41: 0x7ffa58957034 - BaseThreadInitThunk
42: 0x7ffa58d42651 - RtlUserThreadStart
```