ICE: op.layout.ty.is_simd()
matthiaskrgr opened this issue · 3 comments
Code
cargo new
and put the code into src/main.rs
Then run cargo check --all-targets
#![feature(platform_intrinsics)]
#![feature(staged_api)]
struct f32x3();
extern "platform-intrinsic" {
#[rustc_const_stable(feature = "foo", since = "1.3.37")]
fn simd_extract<T, U>(x: T, idx: u32) -> U;
}
const Y0: i8 = unsafe { simd_extract(f32x3, 0) };
fn main() {}
Meta
rustc --version --verbose
:
rustc 1.67.0-nightly (a28f3c88e 2022-11-20)
binary: rustc
commit-hash: a28f3c88e50a77bc2a91889241248c4543854e61
commit-date: 2022-11-20
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4
Error output
warning: type `f32x3` should have an upper camel case name
--> src/main.rs:3:8
|
3 | struct f32x3();
| ^^^^^ help: convert the identifier to upper camel case (notice the capitalization): `F32x3`
|
= note: `#[warn(non_camel_case_types)]` on by default
warning: struct `f32x3` is never constructed
--> src/main.rs:3:8
|
3 | struct f32x3();
| ^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: constant `Y0` is never used
--> src/main.rs:8:7
|
8 | const Y0: i8 = unsafe { simd_extract(f32x3, 0) };
| ^^
warning: function `simd_extract` is never used
--> src/main.rs:6:8
|
6 | fn simd_extract<T, U>(x: T, idx: u32) -> U;
| ^^^^^^^^^^^^
Backtrace
thread '<unnamed>' panicked at 'assertion failed: op.layout.ty.is_simd()', compiler/rustc_const_eval/src/interpret/operand.rs:436:9
stack backtrace:
0: 0x7f3fae366210 - std::backtrace_rs::backtrace::libunwind::trace::heb7a33f2fe285dd9
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x7f3fae366210 - std::backtrace_rs::backtrace::trace_unsynchronized::hdd483bbded009146
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f3fae366210 - std::sys_common::backtrace::_print_fmt::h66820ec1712881f4
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/sys_common/backtrace.rs:65:5
3: 0x7f3fae366210 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd2c196610029335c
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/sys_common/backtrace.rs:44:22
error: module has missing stability attribute
--> src/main.rs:1:1
|
1 | / #![feature(platform_intrinsics)]
2 | | #![feature(staged_api)]
3 | | struct f32x3();
4 | | extern "platform-intrinsic" {
... |
9 | |
10 | | fn main() {}
| |____________^
4: 0x7f3fae3c863e - core::fmt::write::h2ca7d8a2085ff483
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/core/src/fmt/mod.rs:1208:17
5: 0x7f3fae356595 - std::io::Write::write_fmt::h12e70db3eb3892cf
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/io/mod.rs:1682:15
6: 0x7f3fae365fd5 - std::sys_common::backtrace::_print::h34ed3ab353b4c6af
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/sys_common/backtrace.rs:47:5
7: 0x7f3fae365fd5 - std::sys_common::backtrace::print::h6c57f031c456c068
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/sys_common/backtrace.rs:34:9
8: 0x7f3fae368cdf - std::panicking::default_hook::{{closure}}::hec2c128303361806
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/panicking.rs:267:22
9: 0x7f3fae368a1a - std::panicking::default_hook::hd13da34753ba960b
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/panicking.rs:286:9
10: 0x7f3fae3694ec - std::panicking::rust_panic_with_hook::h73ea3535d824209e
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/panicking.rs:688:13
11: 0x7f3fae369241 - std::panicking::begin_panic_handler::{{closure}}::hd671ecd225a3dd76
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/panicking.rs:577:13
12: 0x7f3fae3666bc - std::sys_common::backtrace::__rust_end_short_backtrace::hfb14ec03ea3b23c0
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/sys_common/backtrace.rs:137:18
13: 0x7f3fae368fa2 - rust_begin_unwind
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/panicking.rs:575:5
14: 0x7f3fae3c5013 - core::panicking::panic_fmt::h60d6645d301b37b5
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/core/src/panicking.rs:65:14
15: 0x7f3fae3c50ed - core::panicking::panic::h1c958851a359a7b8
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/core/src/panicking.rs:114:5
warning: `f` (bin "f") generated 1 warning (1 duplicate)
error: could not compile `f` due to previous error; 1 warning emitted
warning: build failed, waiting for other jobs to finish...
16: 0x7f3fb152f456 - <rustc_const_eval[46db99253ff2e25f]::interpret::eval_context::InterpCx<rustc_const_eval[46db99253ff2e25f]::const_eval::machine::CompileTimeInterpreter>>::operand_to_simd
17: 0x7f3fb07cd02d - <rustc_const_eval[46db99253ff2e25f]::interpret::eval_context::InterpCx<rustc_const_eval[46db99253ff2e25f]::const_eval::machine::CompileTimeInterpreter>>::emulate_intrinsic
18: 0x7f3fb07c6d7f - <rustc_const_eval[46db99253ff2e25f]::const_eval::machine::CompileTimeInterpreter as rustc_const_eval[46db99253ff2e25f]::interpret::machine::Machine>::call_intrinsic
19: 0x7f3fb07a5dbe - <rustc_const_eval[46db99253ff2e25f]::interpret::eval_context::InterpCx<rustc_const_eval[46db99253ff2e25f]::const_eval::machine::CompileTimeInterpreter>>::eval_fn_call
20: 0x7f3fb0704df1 - <rustc_const_eval[46db99253ff2e25f]::interpret::eval_context::InterpCx<rustc_const_eval[46db99253ff2e25f]::const_eval::machine::CompileTimeInterpreter>>::run
21: 0x7f3fb06e87e9 - rustc_const_eval[46db99253ff2e25f]::const_eval::eval_queries::eval_to_allocation_raw_provider
22: 0x7f3fb06c98d9 - <rustc_query_system[8d6e95109f3d85ae]::dep_graph::graph::DepGraph<rustc_middle[f366153565d5d77d]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[f366153565d5d77d]::ty::context::TyCtxt, rustc_middle[f366153565d5d77d]::ty::ParamEnvAnd<rustc_middle[f366153565d5d77d]::mir::interpret::GlobalId>, core[d4837f3c8a20a9c3]::result::Result<rustc_middle[f366153565d5d77d]::mir::interpret::value::ConstAlloc, rustc_middle[f366153565d5d77d]::mir::interpret::error::ErrorHandled>>
23: 0x7f3fb06c87be - rustc_query_system[8d6e95109f3d85ae]::query::plumbing::try_execute_query::<rustc_query_impl[f9274d723e979a80]::plumbing::QueryCtxt, rustc_query_system[8d6e95109f3d85ae]::query::caches::DefaultCache<rustc_middle[f366153565d5d77d]::ty::ParamEnvAnd<rustc_middle[f366153565d5d77d]::mir::interpret::GlobalId>, core[d4837f3c8a20a9c3]::result::Result<rustc_middle[f366153565d5d77d]::mir::interpret::value::ConstAlloc, rustc_middle[f366153565d5d77d]::mir::interpret::error::ErrorHandled>>>
24: 0x7f3fb0fdd986 - <rustc_query_impl[f9274d723e979a80]::Queries as rustc_middle[f366153565d5d77d]::ty::query::QueryEngine>::eval_to_allocation_raw
25: 0x7f3fb0870bca - rustc_const_eval[46db99253ff2e25f]::const_eval::eval_queries::eval_to_const_value_raw_provider
26: 0x7f3fb0246c49 - <rustc_query_system[8d6e95109f3d85ae]::dep_graph::graph::DepGraph<rustc_middle[f366153565d5d77d]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[f366153565d5d77d]::ty::context::TyCtxt, rustc_middle[f366153565d5d77d]::ty::ParamEnvAnd<rustc_middle[f366153565d5d77d]::mir::interpret::GlobalId>, core[d4837f3c8a20a9c3]::result::Result<rustc_middle[f366153565d5d77d]::mir::interpret::value::ConstValue, rustc_middle[f366153565d5d77d]::mir::interpret::error::ErrorHandled>>
27: 0x7f3fb0243fcb - rustc_query_system[8d6e95109f3d85ae]::query::plumbing::try_execute_query::<rustc_query_impl[f9274d723e979a80]::plumbing::QueryCtxt, rustc_query_system[8d6e95109f3d85ae]::query::caches::DefaultCache<rustc_middle[f366153565d5d77d]::ty::ParamEnvAnd<rustc_middle[f366153565d5d77d]::mir::interpret::GlobalId>, core[d4837f3c8a20a9c3]::result::Result<rustc_middle[f366153565d5d77d]::mir::interpret::value::ConstValue, rustc_middle[f366153565d5d77d]::mir::interpret::error::ErrorHandled>>>
28: 0x7f3fb0fddb19 - <rustc_query_impl[f9274d723e979a80]::Queries as rustc_middle[f366153565d5d77d]::ty::query::QueryEngine>::eval_to_const_value_raw
29: 0x7f3fb0871002 - rustc_const_eval[46db99253ff2e25f]::const_eval::eval_queries::eval_to_const_value_raw_provider
30: 0x7f3fb0246c49 - <rustc_query_system[8d6e95109f3d85ae]::dep_graph::graph::DepGraph<rustc_middle[f366153565d5d77d]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[f366153565d5d77d]::ty::context::TyCtxt, rustc_middle[f366153565d5d77d]::ty::ParamEnvAnd<rustc_middle[f366153565d5d77d]::mir::interpret::GlobalId>, core[d4837f3c8a20a9c3]::result::Result<rustc_middle[f366153565d5d77d]::mir::interpret::value::ConstValue, rustc_middle[f366153565d5d77d]::mir::interpret::error::ErrorHandled>>
31: 0x7f3fb0243fcb - rustc_query_system[8d6e95109f3d85ae]::query::plumbing::try_execute_query::<rustc_query_impl[f9274d723e979a80]::plumbing::QueryCtxt, rustc_query_system[8d6e95109f3d85ae]::query::caches::DefaultCache<rustc_middle[f366153565d5d77d]::ty::ParamEnvAnd<rustc_middle[f366153565d5d77d]::mir::interpret::GlobalId>, core[d4837f3c8a20a9c3]::result::Result<rustc_middle[f366153565d5d77d]::mir::interpret::value::ConstValue, rustc_middle[f366153565d5d77d]::mir::interpret::error::ErrorHandled>>>
32: 0x7f3fb0fddb19 - <rustc_query_impl[f9274d723e979a80]::Queries as rustc_middle[f366153565d5d77d]::ty::query::QueryEngine>::eval_to_const_value_raw
33: 0x7f3fb023801b - <rustc_middle[f366153565d5d77d]::ty::query::TyCtxtEnsure>::const_eval_poly
34: 0x7f3fb023362e - <rustc_lint[d23633d1eb413efe]::BuiltinCombinedModuleLateLintPass as rustc_lint[d23633d1eb413efe]::passes::LateLintPass>::check_item
35: 0x7f3fb022f1ed - rustc_hir[5773f6caf240b13a]::intravisit::walk_mod::<rustc_lint[d23633d1eb413efe]::late::LateContextAndPass<rustc_lint[d23633d1eb413efe]::BuiltinCombinedModuleLateLintPass>>
36: 0x7f3fb022e74a - rustc_lint[d23633d1eb413efe]::late::late_lint_mod::<rustc_lint[d23633d1eb413efe]::BuiltinCombinedModuleLateLintPass>
37: 0x7f3fb022e59c - rustc_lint[d23633d1eb413efe]::lint_mod
38: 0x7f3fafe62ab3 - <rustc_query_system[8d6e95109f3d85ae]::dep_graph::graph::DepGraph<rustc_middle[f366153565d5d77d]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[f366153565d5d77d]::ty::context::TyCtxt, rustc_span[9f4111115c4fed]::def_id::LocalDefId, ()>
39: 0x7f3fafe60e4e - rustc_query_system[8d6e95109f3d85ae]::query::plumbing::try_execute_query::<rustc_query_impl[f9274d723e979a80]::plumbing::QueryCtxt, rustc_query_system[8d6e95109f3d85ae]::query::caches::DefaultCache<rustc_span[9f4111115c4fed]::def_id::LocalDefId, ()>>
40: 0x7f3fb0a1ad59 - rustc_query_system[8d6e95109f3d85ae]::query::plumbing::get_query::<rustc_query_impl[f9274d723e979a80]::queries::lint_mod, rustc_query_impl[f9274d723e979a80]::plumbing::QueryCtxt>
41: 0x7f3fb0cc4988 - rustc_data_structures[826aec3a5f4bc32e]::sync::par_for_each_in::<&[rustc_hir[5773f6caf240b13a]::hir_id::OwnerId], <rustc_middle[f366153565d5d77d]::hir::map::Map>::par_for_each_module<rustc_lint[d23633d1eb413efe]::late::check_crate<rustc_lint[d23633d1eb413efe]::BuiltinCombinedLateLintPass, rustc_interface[ae1f079bdc82f0f4]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#1}::{closure#0}::{closure#0}>::{closure#0}>
42: 0x7f3fb0cc468e - <rustc_session[b4e9c942712cd38d]::session::Session>::time::<(), rustc_lint[d23633d1eb413efe]::late::check_crate<rustc_lint[d23633d1eb413efe]::BuiltinCombinedLateLintPass, rustc_interface[ae1f079bdc82f0f4]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#1}::{closure#0}>
43: 0x7f3fb0cc426a - <rustc_session[b4e9c942712cd38d]::session::Session>::time::<(), rustc_interface[ae1f079bdc82f0f4]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}>
44: 0x7f3fb0cadc0f - <core[d4837f3c8a20a9c3]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[ae1f079bdc82f0f4]::passes::analysis::{closure#5}::{closure#1}> as core[d4837f3c8a20a9c3]::ops::function::FnOnce<()>>::call_once
45: 0x7f3fafa0b627 - <rustc_session[b4e9c942712cd38d]::session::Session>::time::<(), rustc_interface[ae1f079bdc82f0f4]::passes::analysis::{closure#5}>
46: 0x7f3fafa07ba6 - rustc_interface[ae1f079bdc82f0f4]::passes::analysis
47: 0x7f3fb0df85fe - <rustc_query_system[8d6e95109f3d85ae]::dep_graph::graph::DepGraph<rustc_middle[f366153565d5d77d]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[f366153565d5d77d]::ty::context::TyCtxt, (), core[d4837f3c8a20a9c3]::result::Result<(), rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>>
48: 0x7f3fb0df7974 - rustc_query_system[8d6e95109f3d85ae]::query::plumbing::try_execute_query::<rustc_query_impl[f9274d723e979a80]::plumbing::QueryCtxt, rustc_query_system[8d6e95109f3d85ae]::query::caches::DefaultCache<(), core[d4837f3c8a20a9c3]::result::Result<(), rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>>>
49: 0x7f3fb0df73f7 - rustc_query_system[8d6e95109f3d85ae]::query::plumbing::get_query::<rustc_query_impl[f9274d723e979a80]::queries::analysis, rustc_query_impl[f9274d723e979a80]::plumbing::QueryCtxt>
50: 0x7f3fb08b493d - <rustc_interface[ae1f079bdc82f0f4]::passes::QueryContext>::enter::<rustc_driver[9703e99ec73861cf]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[d4837f3c8a20a9c3]::result::Result<(), rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>>
51: 0x7f3fb08b0b7f - <rustc_interface[ae1f079bdc82f0f4]::interface::Compiler>::enter::<rustc_driver[9703e99ec73861cf]::run_compiler::{closure#1}::{closure#2}, core[d4837f3c8a20a9c3]::result::Result<core[d4837f3c8a20a9c3]::option::Option<rustc_interface[ae1f079bdc82f0f4]::queries::Linker>, rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>>
52: 0x7f3fb08abbb2 - rustc_span[9f4111115c4fed]::with_source_map::<core[d4837f3c8a20a9c3]::result::Result<(), rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>, rustc_interface[ae1f079bdc82f0f4]::interface::run_compiler<core[d4837f3c8a20a9c3]::result::Result<(), rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>, rustc_driver[9703e99ec73861cf]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
53: 0x7f3fb08ab6a9 - <scoped_tls[ae5b04190739cce1]::ScopedKey<rustc_span[9f4111115c4fed]::SessionGlobals>>::set::<rustc_interface[ae1f079bdc82f0f4]::interface::run_compiler<core[d4837f3c8a20a9c3]::result::Result<(), rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>, rustc_driver[9703e99ec73861cf]::run_compiler::{closure#1}>::{closure#0}, core[d4837f3c8a20a9c3]::result::Result<(), rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>>
54: 0x7f3fb08aacb8 - std[19ca63742693b6d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ae1f079bdc82f0f4]::util::run_in_thread_pool_with_globals<rustc_interface[ae1f079bdc82f0f4]::interface::run_compiler<core[d4837f3c8a20a9c3]::result::Result<(), rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>, rustc_driver[9703e99ec73861cf]::run_compiler::{closure#1}>::{closure#0}, core[d4837f3c8a20a9c3]::result::Result<(), rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d4837f3c8a20a9c3]::result::Result<(), rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>>
55: 0x7f3fb08aa9dc - <<std[19ca63742693b6d]::thread::Builder>::spawn_unchecked_<rustc_interface[ae1f079bdc82f0f4]::util::run_in_thread_pool_with_globals<rustc_interface[ae1f079bdc82f0f4]::interface::run_compiler<core[d4837f3c8a20a9c3]::result::Result<(), rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>, rustc_driver[9703e99ec73861cf]::run_compiler::{closure#1}>::{closure#0}, core[d4837f3c8a20a9c3]::result::Result<(), rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d4837f3c8a20a9c3]::result::Result<(), rustc_errors[76181ab7b3254ac7]::ErrorGuaranteed>>::{closure#1} as core[d4837f3c8a20a9c3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
56: 0x7f3fb2395893 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha6912b1affeedc9f
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/alloc/src/boxed.rs:2000:9
57: 0x7f3fb2395893 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3ca4ddbfb732ff99
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/alloc/src/boxed.rs:2000:9
58: 0x7f3fb2395893 - std::sys::unix::thread::Thread::new::thread_start::ha349c7e697b17ac9
at /rustc/a28f3c88e50a77bc2a91889241248c4543854e61/library/std/src/sys/unix/thread.rs:108:17
59: 0x7f3fae0fd8fd - <unknown>
60: 0x7f3fae17fa60 - <unknown>
61: 0x0 - <unknown>
warning: `f` (bin "f" test) generated 4 warnings
error: could not compile `f`; 4 warnings emitted
During typechecking, the compiler deliberately eschews reasoning about certain type formations that are parametric in order to allow monomorphization to catch them, as at monomorphization time we have the ability to reason fully about the types. We've taken to using trait bounds to catch this behavior in code for std::simd
, however, I do not think using the intrinsic directly can really be expected to have any other behavior but miserable failure during const eval. While this is unexpected, it isn't surprising.
Previously we decided we're not going to bother making the experience nice for these intrinsics, they're all intended to be viewed as in the namespace hold_my_bev::i_know_what_i_am_doing
, so technically this is a wontfix. However, this case is somewhat interesting to examine, mostly because it appears to happen before typechecking has completed? which isn't something I think we expected to happen at the time we made our initial decisions.
Hm, no, I just didn't trace that correctly. Onwards!