Skip to content

Conversation

nyurik
Copy link
Contributor

@nyurik nyurik commented Feb 14, 2024

Bug report for this PR: #121066

This code causes ICE in rustc when running ./x.py build --stage 1 alloc -- the error shows up in CI https://github.com/rust-lang/rust/actions/runs/7896056798/job/21549391196?pr=121064#step:26:2201

error: internal compiler error: /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/compiler/rustc_codegen_ssa/src/mir/operand.rs:201:18: not immediate: OperandRef(Ref((ptr: %6 = alloca { { ptr, i64 }, { ptr, i64 }, { ptr, [1 x i64] } }, align 8), None, Align(8 bytes)) @ TyAndLayout { ty: Arguments<'_>, layout: Layout { size: Size(48 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [Size(0 bytes), Size(32 bytes), Size(16 bytes)], memory_index: [0, 2, 1] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes) } }) 

This issue showed up with two code variants:

if unsafe { core::intrinsics::is_val_statically_known(args) } { if let Some(s) = args.as_str() { return self.write_str(s); } } if unsafe { core::intrinsics::is_val_statically_known(args) } && let Some(s) = args.as_str() { return self.write_str(s); } 
Stacktrace

thread 'rustc' panicked at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/compiler/rustc_errors/src/lib.rs:932:30: Box<dyn Any> stack backtrace: 0: 0x7f8999fdabee - std::backtrace_rs::backtrace::libunwind::trace::hc987f3c35d55761d at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5 1: 0x7f8999fdabee - std::backtrace_rs::backtrace::trace_unsynchronized::h88acce004bab2451 at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f8999fdabee - std::backtrace::Backtrace::create::ha3010e67ce0df222 at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/std/src/backtrace.rs:331:13 3: 0x7f8999fdab30 - std::backtrace::Backtrace::force_capture::h6bbfa084bd4217e5 at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/std/src/backtrace.rs:312:9 4: 0x7f8996fa9479 - std[55ab4a542350c755]::panicking::update_hook::<alloc[4da3f6bd47afec24]::boxed::Box<rustc_driver_impl[ef4ee9058c24acfe]::install_ice_hook::{closure#0}>>::{closure#0} 5: 0x7f8999ff6fd6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hff82162297b64e89 at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/alloc/src/boxed.rs:2029:9 6: 0x7f8999ff6fd6 - std::panicking::rust_panic_with_hook::h8633089b9015a8b7 at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/std/src/panicking.rs:785:13 7: 0x7f8996fd81d4 - std[55ab4a542350c755]::panicking::begin_panic::<rustc_errors[68df17d15f76634e]::ExplicitBug>::{closure#0} 8: 0x7f8996fd48c6 - std[55ab4a542350c755]::sys_common::backtrace::__rust_end_short_backtrace::<std[55ab4a542350c755]::panicking::begin_panic<rustc_errors[68df17d15f76634e]::ExplicitBug>::{closure#0}, !> 9: 0x7f8996fcfbb6 - std[55ab4a542350c755]::panicking::begin_panic::<rustc_errors[68df17d15f76634e]::ExplicitBug> 10: 0x7f8996fe3841 - <rustc_errors[68df17d15f76634e]::diagnostic_builder::BugAbort as rustc_errors[68df17d15f76634e]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee 11: 0x7f89973725eb - <rustc_errors[68df17d15f76634e]::DiagCtxt>::bug::<alloc[4da3f6bd47afec24]::string::String> 12: 0x7f899740b23b - rustc_middle[cfc4b7b04cd03608]::util::bug::opt_span_bug_fmt::<rustc_span[70f6536c5e2f3755]::span_encoding::Span>::{closure#0} 13: 0x7f89973f3dba - rustc_middle[cfc4b7b04cd03608]::ty::context::tls::with_opt::<rustc_middle[cfc4b7b04cd03608]::util::bug::opt_span_bug_fmt<rustc_span[70f6536c5e2f3755]::span_encoding::Span>::{closure#0}, !>::{closure#0} 14: 0x7f89973f3c38 - rustc_middle[cfc4b7b04cd03608]::ty::context::tls::with_context_opt::<rustc_middle[cfc4b7b04cd03608]::ty::context::tls::with_opt<rustc_middle[cfc4b7b04cd03608]::util::bug::opt_span_bug_fmt<rustc_span[70f6536c5e2f3755]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !> 15: 0x7f8995507430 - rustc_middle[cfc4b7b04cd03608]::util::bug::bug_fmt 16: 0x7f8998d4e82a - <rustc_codegen_llvm[103398a9ca8f425b]::builder::Builder as rustc_codegen_ssa[725a152d682a010f]::traits::intrinsic::IntrinsicCallMethods>::codegen_intrinsic_call 17: 0x7f8998d551a5 - <rustc_codegen_ssa[725a152d682a010f]::mir::FunctionCx<rustc_codegen_llvm[103398a9ca8f425b]::builder::Builder>>::codegen_intrinsic_call 18: 0x7f8998b8ea63 - <rustc_codegen_ssa[725a152d682a010f]::mir::FunctionCx<rustc_codegen_llvm[103398a9ca8f425b]::builder::Builder>>::codegen_block 19: 0x7f8998d404a6 - rustc_codegen_ssa[725a152d682a010f]::mir::codegen_mir::<rustc_codegen_llvm[103398a9ca8f425b]::builder::Builder> 20: 0x7f8998d2e561 - rustc_codegen_llvm[103398a9ca8f425b]::base::compile_codegen_unit::module_codegen 21: 0x7f8998fb8324 - <rustc_codegen_llvm[103398a9ca8f425b]::LlvmCodegenBackend as rustc_codegen_ssa[725a152d682a010f]::traits::backend::ExtraBackendMethods>::compile_codegen_unit 22: 0x7f8999108467 - <rustc_codegen_llvm[103398a9ca8f425b]::LlvmCodegenBackend as rustc_codegen_ssa[725a152d682a010f]::traits::backend::CodegenBackend>::codegen_crate 23: 0x7f8999106230 - rustc_interface[2106013cc2f5b63c]::passes::start_codegen 24: 0x7f8999105a06 - <rustc_interface[2106013cc2f5b63c]::queries::Queries>::codegen_and_build_linker 25: 0x7f8998f93de6 - rustc_interface[2106013cc2f5b63c]::interface::run_compiler::<core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>, rustc_driver_impl[ef4ee9058c24acfe]::run_compiler::{closure#0}>::{closure#0} 26: 0x7f8999101ba1 - std[55ab4a542350c755]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[2106013cc2f5b63c]::util::run_in_thread_with_globals<rustc_interface[2106013cc2f5b63c]::interface::run_compiler<core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>, rustc_driver_impl[ef4ee9058c24acfe]::run_compiler::{closure#0}>::{closure#0}, core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>> 27: 0x7f89991019ff - <<std[55ab4a542350c755]::thread::Builder>::spawn_unchecked_<rustc_interface[2106013cc2f5b63c]::util::run_in_thread_with_globals<rustc_interface[2106013cc2f5b63c]::interface::run_compiler<core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>, rustc_driver_impl[ef4ee9058c24acfe]::run_compiler::{closure#0}>::{closure#0}, core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>>::{closure#1} as core[ce9c323f7905c200]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 28: 0x7f899a000675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf8f17589d536646e at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/alloc/src/boxed.rs:2015:9 29: 0x7f899a000675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h68da270e7d912a3c at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/alloc/src/boxed.rs:2015:9 30: 0x7f899a000675 - std::sys::pal::unix::thread::Thread::new::thread_start::he371c43bd596b52d at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/std/src/sys/pal/unix/thread.rs:108:17 31: 0x7f8994094ac3 - start_thread at ./nptl/pthread_create.c:442:8 32: 0x7f8994126850 - __GI___clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81 33: 0x0 - <unknown> rustc version: 1.77.0-beta.1 (04ba45219 2024-02-04) platform: x86_64-unknown-linux-gnu query stack during panic: end of query stack 

Per @dtolnay suggestion in serde-rs/serde#2697 (comment) - attempt to speed up performance in the cases of a simple string format without arguments: ```rust write!(f, "text") -> f.write_str("text") ```
@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2024

r? @cuviper

rustbot has assigned @cuviper.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 14, 2024
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-16 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
GITHUB_ACTION=__run_7 GITHUB_ACTIONS=true GITHUB_ACTION_REF= GITHUB_ACTION_REPOSITORY= GITHUB_ACTOR=nyurik GITHUB_API_URL=https://api.github.com GITHUB_BASE_REF=master GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_fb26588c-e52e-4fb4-b112-483f7893e003 GITHUB_EVENT_NAME=pull_request --- GITHUB_SERVER_URL=https://github.com GITHUB_SHA=307bb41194794a55f098ba9119eae79fd099636f GITHUB_STATE=/home/runner/work/_temp/_runner_file_commands/save_state_fb26588c-e52e-4fb4-b112-483f7893e003 GITHUB_STEP_SUMMARY=/home/runner/work/_temp/_runner_file_commands/step_summary_fb26588c-e52e-4fb4-b112-483f7893e003 GITHUB_TRIGGERING_ACTOR=nyurik GITHUB_WORKFLOW_REF=rust-lang/rust/.github/workflows/ci.yml@refs/pull/121064/merge GITHUB_WORKFLOW_SHA=307bb41194794a55f098ba9119eae79fd099636f GITHUB_WORKSPACE=/home/runner/work/rust/rust GOROOT_1_19_X64=/opt/hostedtoolcache/go/1.19.13/x64 --- #12 writing image sha256:01cf7fba6b3ccd44095a242e0e5792c2f74128e1c15ac5ba4092cc74a82ca0ef done #12 naming to docker.io/library/rust-ci done #12 DONE 10.2s ##[endgroup] Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/ [CI_JOB_NAME=x86_64-gnu-llvm-16] ##[group]Clock drift check local time: Wed Feb 14 03:25:09 UTC 2024 network time: Wed, 14 Feb 2024 03:25:09 GMT network time: Wed, 14 Feb 2024 03:25:09 GMT ##[endgroup] sccache: Starting the server... ##[group]Configure the build configure: processing command line configure: configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-16', '--enable-llvm-link-shared', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'build.optimized-compiler-builtins', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling'] configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-16/bin/llvm-config configure: llvm.link-shared := True configure: rust.thin-lto-import-instr-limit := 10 configure: change-id := 99999999 --- Compiling memchr v2.5.0 Compiling std v0.0.0 (/checkout/library/std) Compiling compiler_builtins v0.1.108 Compiling rustc-std-workspace-core v1.99.0 (/checkout/library/rustc-std-workspace-core) error: internal compiler error: /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/compiler/rustc_codegen_ssa/src/mir/operand.rs:201:18: not immediate: OperandRef(Ref((ptr: %6 = alloca { { ptr, i64 }, { ptr, i64 }, { ptr, [1 x i64] } }, align 8), None, Align(8 bytes)) @ TyAndLayout { ty: Arguments<'_>, layout: Layout { size: Size(48 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [Size(0 bytes), Size(32 bytes), Size(16 bytes)], memory_index: [0, 2, 1] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes) } }) thread 'rustc' panicked at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/compiler/rustc_errors/src/lib.rs:932:30: Box<dyn Any> stack backtrace: 0: 0x7f07b0d8bd16 - std::backtrace_rs::backtrace::libunwind::trace::hc987f3c35d55761d --- at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7f07b0d8e887 - std::panicking::default_hook::{{closure}}::hdf16b4533d11beb4 10: 0x7f07b0d8e5e9 - std::panicking::default_hook::h223213ee257b8185 at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/std/src/panicking.rs:292:9 11: 0x7f07b39a896c - std[55ab4a542350c755]::panicking::update_hook::<alloc[4da3f6bd47afec24]::boxed::Box<rustc_driver_impl[ef4ee9058c24acfe]::install_ice_hook::{closure#0}>>::{closure#0} 12: 0x7f07b0d8efd6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hff82162297b64e89 13: 0x7f07b0d8efd6 - std::panicking::rust_panic_with_hook::h8633089b9015a8b7 at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/std/src/panicking.rs:785:13 at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/std/src/panicking.rs:785:13 14: 0x7f07b39d81d4 - std[55ab4a542350c755]::panicking::begin_panic::<rustc_errors[68df17d15f76634e]::ExplicitBug>::{closure#0} 15: 0x7f07b39d48c6 - std[55ab4a542350c755]::sys_common::backtrace::__rust_end_short_backtrace::<std[55ab4a542350c755]::panicking::begin_panic<rustc_errors[68df17d15f76634e]::ExplicitBug>::{closure#0}, !> 16: 0x7f07b39cfbb6 - std[55ab4a542350c755]::panicking::begin_panic::<rustc_errors[68df17d15f76634e]::ExplicitBug> 17: 0x7f07b39e3841 - <rustc_errors[68df17d15f76634e]::diagnostic_builder::BugAbort as rustc_errors[68df17d15f76634e]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee 18: 0x7f07b3d725eb - <rustc_errors[68df17d15f76634e]::DiagCtxt>::bug::<alloc[4da3f6bd47afec24]::string::String> 19: 0x7f07b3e0b23b - rustc_middle[cfc4b7b04cd03608]::util::bug::opt_span_bug_fmt::<rustc_span[70f6536c5e2f3755]::span_encoding::Span>::{closure#0} 20: 0x7f07b3df3dba - rustc_middle[cfc4b7b04cd03608]::ty::context::tls::with_opt::<rustc_middle[cfc4b7b04cd03608]::util::bug::opt_span_bug_fmt<rustc_span[70f6536c5e2f3755]::span_encoding::Span>::{closure#0}, !>::{closure#0} 21: 0x7f07b3df3c38 - rustc_middle[cfc4b7b04cd03608]::ty::context::tls::with_context_opt::<rustc_middle[cfc4b7b04cd03608]::ty::context::tls::with_opt<rustc_middle[cfc4b7b04cd03608]::util::bug::opt_span_bug_fmt<rustc_span[70f6536c5e2f3755]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !> 22: 0x7f07b1f07430 - rustc_middle[cfc4b7b04cd03608]::util::bug::bug_fmt 23: 0x7f07b574e82a - <rustc_codegen_llvm[103398a9ca8f425b]::builder::Builder as rustc_codegen_ssa[725a152d682a010f]::traits::intrinsic::IntrinsicCallMethods>::codegen_intrinsic_call 24: 0x7f07b57551a5 - <rustc_codegen_ssa[725a152d682a010f]::mir::FunctionCx<rustc_codegen_llvm[103398a9ca8f425b]::builder::Builder>>::codegen_intrinsic_call 25: 0x7f07b558ea63 - <rustc_codegen_ssa[725a152d682a010f]::mir::FunctionCx<rustc_codegen_llvm[103398a9ca8f425b]::builder::Builder>>::codegen_block 26: 0x7f07b57404a6 - rustc_codegen_ssa[725a152d682a010f]::mir::codegen_mir::<rustc_codegen_llvm[103398a9ca8f425b]::builder::Builder> 27: 0x7f07b572e561 - rustc_codegen_llvm[103398a9ca8f425b]::base::compile_codegen_unit::module_codegen 28: 0x7f07b59b7f85 - <rustc_codegen_llvm[103398a9ca8f425b]::LlvmCodegenBackend as rustc_codegen_ssa[725a152d682a010f]::traits::backend::ExtraBackendMethods>::compile_codegen_unit 29: 0x7f07b5b08467 - <rustc_codegen_llvm[103398a9ca8f425b]::LlvmCodegenBackend as rustc_codegen_ssa[725a152d682a010f]::traits::backend::CodegenBackend>::codegen_crate 30: 0x7f07b5b06230 - rustc_interface[2106013cc2f5b63c]::passes::start_codegen 31: 0x7f07b5b05a06 - <rustc_interface[2106013cc2f5b63c]::queries::Queries>::codegen_and_build_linker 32: 0x7f07b5993de6 - rustc_interface[2106013cc2f5b63c]::interface::run_compiler::<core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>, rustc_driver_impl[ef4ee9058c24acfe]::run_compiler::{closure#0}>::{closure#0} 33: 0x7f07b5b01ba1 - std[55ab4a542350c755]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[2106013cc2f5b63c]::util::run_in_thread_with_globals<rustc_interface[2106013cc2f5b63c]::interface::run_compiler<core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>, rustc_driver_impl[ef4ee9058c24acfe]::run_compiler::{closure#0}>::{closure#0}, core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>> 34: 0x7f07b5b019ff - <<std[55ab4a542350c755]::thread::Builder>::spawn_unchecked_<rustc_interface[2106013cc2f5b63c]::util::run_in_thread_with_globals<rustc_interface[2106013cc2f5b63c]::interface::run_compiler<core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>, rustc_driver_impl[ef4ee9058c24acfe]::run_compiler::{closure#0}>::{closure#0}, core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ce9c323f7905c200]::result::Result<(), rustc_span[70f6536c5e2f3755]::ErrorGuaranteed>>::{closure#1} as core[ce9c323f7905c200]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 35: 0x7f07b0d98675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf8f17589d536646e at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/alloc/src/boxed.rs:2015:9 36: 0x7f07b0d98675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h68da270e7d912a3c 37: 0x7f07b0d98675 - std::sys::pal::unix::thread::Thread::new::thread_start::he371c43bd596b52d at /rustc/04ba4521971a83d71477a406b5ce7a479e9d7af8/library/std/src/sys/pal/unix/thread.rs:108:17 38: 0x7f07b0b636ba - <unknown> 39: 0x7f07b0bf2120 - <unknown> 39: 0x7f07b0bf2120 - <unknown> 40: 0x0 - <unknown> note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md warning: the ICE couldn't be written to `/checkout/rustc-ice-2024-02-14T03_25_45-1890.txt`: Read-only file system (os error 30) note: rustc 1.77.0-beta.1 (04ba45219 2024-02-04) running on x86_64-unknown-linux-gnu note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 -C debug-assertions=on -Z unstable-options -C symbol-mangling-version=v0 -Z unstable-options -Z macro-backtrace -C split-debuginfo=off -C prefer-dynamic -C llvm-args=-import-instr-limit=10 -Z inline-mir -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -Z crate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/") -Z binary-dep-depinfo -Z force-unstable-if-unmarked note: some of the compiler flags provided by cargo are hidden query stack during panic: end of query stack 
@cuviper
Copy link
Member

cuviper commented Feb 14, 2024

@rustbot blocked

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 14, 2024
impl<W: Write + ?Sized> SpecWriteFmt for &mut W {
#[inline]
default fn spec_write_fmt(mut self, args: Arguments<'_>) -> Result {
if unsafe { core::intrinsics::is_val_statically_known(args) } {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_val_statically_known only supports primitives

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to PR a better error message, since I'd expect many people to run into this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nilstrieb I suspect ICE is ICE no matter what the users try to do? That said, I don't see anything in the docs about it only supporting primitives - it does have T: Copy though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not documented, you need to look at the implementation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can an expression be evaluated for this intrinsic? e.g. for a primitive bool:

Suggested change
if unsafe { core::intrinsics::is_val_statically_known(args) } {
if unsafe { core::intrinsics::is_val_statically_known(args.as_str().is_some()) } {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect ICE is ICE no matter what the users try to do?

No, if you use internal features such as intrinsics, then some ICEs are expected. It's not worth the effort and overhead of guarding against ICEs when users explicitly ask to fiddle with the internal details of the compiler.

@Teapot4195
Copy link
Contributor

Teapot4195 commented Feb 14, 2024

ICEing was fixed in #120484.

Best thing to do here is probably to update the docs to make it better, unless we want to backport the fix?

@Noratrieb
Copy link
Member

I don't think we want to backport this. The docs could be made better

@nyurik
Copy link
Contributor Author

nyurik commented Feb 15, 2024

For the novice, when you say backport - are you referring to the fact that the current binary bootstrapping compiler used by x.py to compile the new version of the lib does not have this bug fix, and that's why it panics, but if you were to switch to the newer version of the bootstrapping compiler, the problem would go away?

@Noratrieb
Copy link
Member

backporting means taking a commit that landed on nightly and letting it skip the release train by putting it directly into beta or even stable. We do this for urgent issues like bad regression fixes.

@Noratrieb
Copy link
Member

Going to close this PR. We get a better error message on nightly, which seems fine.
In the future, when using intrinsics, you always need to be careful, and getting an ICE when using intrinsics is probably your fault^^ (which of course doesn't mean that you can't ask for help if you need help debugging the problem, do ask for help when needed).

@Noratrieb Noratrieb closed this Feb 15, 2024
@nyurik nyurik deleted the optimize-core-fmt2 branch February 15, 2024 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-libs Relevant to the library team, which will review and decide on the PR/issue.

7 participants