Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc should not suggest #![feature(core_intrinsics)] #97501

Closed
kaya3 opened this issue May 28, 2022 · 8 comments · Fixed by #128173 or #128202
Closed

rustc should not suggest #![feature(core_intrinsics)] #97501

kaya3 opened this issue May 28, 2022 · 8 comments · Fixed by #128173 or #128202
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-intrinsics Area: Intrinsics A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. F-core_intrinsics Issue in the "core intrinsics" for internal usage only. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@kaya3
Copy link

kaya3 commented May 28, 2022

Rust beginner here. I was trying something out on the Playground, turns out I didn't understand how to use wrapping_add correctly; but following a sequence of suggested fixes from the compiler I arrived at the below, which gives two internal compiler errors. I asked on Discord and was told it is worth reporting it here, even though this code is incorrect and uses an unstable library feature.

Code

#![feature(core_intrinsics)]
use std::intrinsics::wrapping_add;

#[derive(Clone, Copy)]
struct WrapInt8 {
    value: u8
}

impl std::ops::Add for WrapInt8 {
    type Output = WrapInt8;
    fn add(self, other: WrapInt8) -> WrapInt8 {
        wrapping_add(self, other)
    }
}

fn main() {
    let p = WrapInt8 { value: 123 };
    let q = WrapInt8 { value: 234 };
    println!("{}", (p + q).value);
}

Meta

This occurred on the Playground, using the current nightly build (1.63.0-nightly, 2022-05-27 ebbcbfc).

Error output

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:8 ~ playground[3faf]::{impl#0}::add), const_param_did: None }) (end of phase transition to Optimized) at bb0[2]:
                                Cannot perform arithmetic on type WrapInt8
  --> src/main.rs:12:9
   |
12 |         wrapping_add(self, other)
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:127:36

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1368:13
stack backtrace:
   0:     0x7f216626ffcd - std::backtrace_rs::backtrace::libunwind::trace::h9dd319c001cd5d5b
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f216626ffcd - std::backtrace_rs::backtrace::trace_unsynchronized::h5cdb9413f7b7f703
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f216626ffcd - std::sys_common::backtrace::_print_fmt::h62e01fe71d2f0609
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f216626ffcd - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb568664ce7d28696
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f21662cbe5c - core::fmt::write::hff09181fc8f150c2
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/core/src/fmt/mod.rs:1196:17
   5:     0x7f21662616c1 - std::io::Write::write_fmt::h77801493f17dbb5a
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/std/src/io/mod.rs:1654:15
   6:     0x7f2166272cb5 - std::sys_common::backtrace::_print::hace3cc1f256ece45
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f2166272cb5 - std::sys_common::backtrace::print::hc1b81d3f2867b83b
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f2166272cb5 - std::panicking::default_hook::{{closure}}::he802b1e81f85775c
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/std/src/panicking.rs:295:22
   9:     0x7f21662729d6 - std::panicking::default_hook::h57b0d510bf2c9fe7
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/std/src/panicking.rs:314:9
  10:     0x7f2166a3c211 - rustc_driver[8a2d58f6f4bf431a]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f216627338a - std::panicking::rust_panic_with_hook::hdd373bc6c22fa56f
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/std/src/panicking.rs:702:17
  12:     0x7f2167bdb181 - std[aa967257b9f8f73b]::panicking::begin_panic::<rustc_errors[1ed68885dba1d6d1]::ExplicitBug>::{closure#0}
  13:     0x7f2167bd9e06 - std[aa967257b9f8f73b]::sys_common::backtrace::__rust_end_short_backtrace::<std[aa967257b9f8f73b]::panicking::begin_panic<rustc_errors[1ed68885dba1d6d1]::ExplicitBug>::{closure#0}, !>
  14:     0x7f2167bedd56 - std[aa967257b9f8f73b]::panicking::begin_panic::<rustc_errors[1ed68885dba1d6d1]::ExplicitBug>
  15:     0x7f2167bf1ec6 - std[aa967257b9f8f73b]::panic::panic_any::<rustc_errors[1ed68885dba1d6d1]::ExplicitBug>
  16:     0x7f21694638e1 - <rustc_errors[1ed68885dba1d6d1]::HandlerInner as core[8467f2214112d7a4]::ops::drop::Drop>::drop
  17:     0x7f2168bcf7a8 - core[8467f2214112d7a4]::ptr::drop_in_place::<rustc_session[f5a33ef05da8b8fa]::parse::ParseSess>
  18:     0x7f2168bd1ac3 - <alloc[e5cd0633e65a6c1f]::rc::Rc<rustc_session[f5a33ef05da8b8fa]::session::Session> as core[8467f2214112d7a4]::ops::drop::Drop>::drop
  19:     0x7f2168bce36d - core[8467f2214112d7a4]::ptr::drop_in_place::<rustc_interface[b93c8180971df832]::interface::Compiler>
  20:     0x7f2168bcdd94 - rustc_span[4bbade9624b8160a]::with_source_map::<core[8467f2214112d7a4]::result::Result<(), rustc_errors[1ed68885dba1d6d1]::ErrorGuaranteed>, rustc_interface[b93c8180971df832]::interface::create_compiler_and_run<core[8467f2214112d7a4]::result::Result<(), rustc_errors[1ed68885dba1d6d1]::ErrorGuaranteed>, rustc_driver[8a2d58f6f4bf431a]::run_compiler::{closure#1}>::{closure#1}>
  21:     0x7f2168bba454 - rustc_interface[b93c8180971df832]::interface::create_compiler_and_run::<core[8467f2214112d7a4]::result::Result<(), rustc_errors[1ed68885dba1d6d1]::ErrorGuaranteed>, rustc_driver[8a2d58f6f4bf431a]::run_compiler::{closure#1}>
  22:     0x7f2168ba4792 - <scoped_tls[6dc72d687799c0be]::ScopedKey<rustc_span[4bbade9624b8160a]::SessionGlobals>>::set::<rustc_interface[b93c8180971df832]::interface::run_compiler<core[8467f2214112d7a4]::result::Result<(), rustc_errors[1ed68885dba1d6d1]::ErrorGuaranteed>, rustc_driver[8a2d58f6f4bf431a]::run_compiler::{closure#1}>::{closure#0}, core[8467f2214112d7a4]::result::Result<(), rustc_errors[1ed68885dba1d6d1]::ErrorGuaranteed>>
  23:     0x7f2168bbbb3f - std[aa967257b9f8f73b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[b93c8180971df832]::util::run_in_thread_pool_with_globals<rustc_interface[b93c8180971df832]::interface::run_compiler<core[8467f2214112d7a4]::result::Result<(), rustc_errors[1ed68885dba1d6d1]::ErrorGuaranteed>, rustc_driver[8a2d58f6f4bf431a]::run_compiler::{closure#1}>::{closure#0}, core[8467f2214112d7a4]::result::Result<(), rustc_errors[1ed68885dba1d6d1]::ErrorGuaranteed>>::{closure#0}, core[8467f2214112d7a4]::result::Result<(), rustc_errors[1ed68885dba1d6d1]::ErrorGuaranteed>>
  24:     0x7f2168bbbc79 - <<std[aa967257b9f8f73b]::thread::Builder>::spawn_unchecked_<rustc_interface[b93c8180971df832]::util::run_in_thread_pool_with_globals<rustc_interface[b93c8180971df832]::interface::run_compiler<core[8467f2214112d7a4]::result::Result<(), rustc_errors[1ed68885dba1d6d1]::ErrorGuaranteed>, rustc_driver[8a2d58f6f4bf431a]::run_compiler::{closure#1}>::{closure#0}, core[8467f2214112d7a4]::result::Result<(), rustc_errors[1ed68885dba1d6d1]::ErrorGuaranteed>>::{closure#0}, core[8467f2214112d7a4]::result::Result<(), rustc_errors[1ed68885dba1d6d1]::ErrorGuaranteed>>::{closure#1} as core[8467f2214112d7a4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f216627d2a3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf3233b13e94151c3
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/alloc/src/boxed.rs:1872:9
  26:     0x7f216627d2a3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4e8ef0a8db850d9e
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/alloc/src/boxed.rs:1872:9
  27:     0x7f216627d2a3 - std::sys::unix::thread::Thread::new::thread_start::haa7458da1d6aafbd
                               at /rustc/ebbcbfc236ced21d5e6a92269edb704692ff26b8/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f21661a3609 - start_thread
  29:     0x7f21660c6133 - clone
  30:                0x0 - <unknown>

note: the compiler unexpectedly panicked. this is a bug.

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

note: rustc 1.63.0-nightly (ebbcbfc23 2022-05-27) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `playground`
@kaya3 kaya3 added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 28, 2022
@compiler-errors
Copy link
Member

searched nightlies: from nightly-2022-03-01 to nightly-2022-05-28
regressed nightly: nightly-2022-04-13
searched commit range: 90ca447...52ca603
regressed commit: 2a83fbc

bisected with cargo-bisect-rustc v0.6.2

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start=2022-03-01 --end=2022-05-28 --regress=ice 

Makes sense to fail in #95320, cc @JakobDegen. Maybe this should be a hard error instead of a delayed bug?

@JakobDegen
Copy link
Contributor

JakobDegen commented May 29, 2022

Thanks for the report!

Before that PR, this:

#![feature(core_intrinsics)]

pub fn add(a: bool, b: bool) -> bool {
    std::intrinsics::wrapping_add(a, b)
}

just happily compiled, and this:

#![feature(core_intrinsics)]
use std::intrinsics::wrapping_add;

#[derive(Clone, Copy)]
struct WrapInt8 {
    value: u8,
    value2: u16,
}

impl std::ops::Add for WrapInt8 {
    type Output = WrapInt8;
    fn add(self, other: WrapInt8) -> WrapInt8 {
        wrapping_add(self, other)
    }
}

fn main() {
    let p = WrapInt8 { value: 1, value2: 2 };
    let q = WrapInt8 { value: 3, value2: 4 };
    println!("{}", (p + q).value);
}

already ICEd, so I don't think this is a regression. I'm tempted to say that we shouldn't bother trying to fix this, and that #![feature(core_intrinsics)] is not "supported" in the sense that this bug wants it to be. I'm not sure what the procedure is for making a decision on this though.

Edit: Maybe the actual bug here is that we recommend #![feature(core_intrinsics)] in diagnostics?

@kaya3
Copy link
Author

kaya3 commented May 29, 2022

Maybe the actual bug here is that we recommend #![feature(core_intrinsics)] in diagnostics?

I would agree with this. It probably makes sense to exclude std::intrinsics and core::intrinsics from suggested fixes, too.

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label May 29, 2022
@scottmcm
Copy link
Member

I agree that ICEing for this is actually pretty expected -- intrinsics are super-internal, and ICEing for misuse is basically fine.

👍 to seeing if we can make sure not to suggest core_intrinsics the feature, or really anything with the extern "rust-intrinsic" ABI called via the intrinsics module. (Sadly there are some stable things with that ABI.)

Maybe for the things that are stable we can have them emit warnings/errors pointing to the stable versions? Since this example really wants u8::wrapping_add, not the intrinsic. (Well, really it wants num::Wrapping<u8>, but we're probably not able to be that smart about it.)

@RalfJung
Copy link
Member

RalfJung commented Jun 3, 2022

We might also want to change this message if the crate uses the core_intrinsic feature:

note: the compiler unexpectedly panicked. this is a bug.

ICEs are not always bugs when intrinsics are used directly.

@workingjubilee workingjubilee added A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` A-intrinsics Area: Intrinsics D-confusing Diagnostics: Confusing error or lint that should be reworked. D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. labels Mar 11, 2023
@workingjubilee
Copy link
Member

🤔

note: the compiler expectedly panicked. this is not a bug.

Unfortunately there's no label for "inviting Rust programmers to see a cask of Amontillado".

@workingjubilee workingjubilee changed the title Internal compiler errors using std::intrinsics::wrapping_add on Playground rustc should not suggest #![feature(core_intrinsics)] Mar 11, 2023
@workingjubilee workingjubilee added the F-core_intrinsics Issue in the "core intrinsics" for internal usage only. label Mar 14, 2023
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
@bors bors closed this as completed in c98d704 Jul 25, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2024
Rollup merge of rust-lang#128173 - compiler-errors:misused-intrinsics, r=oli-obk

Remove crashes for misuses of intrinsics

All of these do not crash if the feature gate is removed. An ICE due *opting into* the intrinsics feature gate is not a bug that needs to be fixed, but instead a misuse of an internal-only API.

See rust-lang/compiler-team#620

The last two issues are already closed anyways, but:
Fixes rust-lang#97501
Fixes rust-lang#111699
Fixes rust-lang#101962
@RalfJung RalfJung reopened this Jul 25, 2024
@RalfJung
Copy link
Member

Reopening, since

Maybe the actual bug here is that we recommend #![feature(core_intrinsics)] in diagnostics?

@RalfJung
Copy link
Member

Though... on playground I do find this recommendation quite handy, when I have to craft some code that actually wants to call intrinsics. And we do emit this now:

warning: the feature `core_intrinsics` is internal to the compiler or standard library
 --> src/main.rs:1:12
  |
1 | #![feature(core_intrinsics)]
  |            ^^^^^^^^^^^^^^^
  |
  = note: using it is strongly discouraged
  = note: `#[warn(internal_features)]` on by default

But we also still say this, which we probably shouldn't:

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

@bors bors closed this as completed in 162db34 Jul 29, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 29, 2024
Rollup merge of rust-lang#128202 - compiler-errors:internal-lib-features, r=oli-obk

Tell users not to file a bug when using internal library features

Actually fixes rust-lang#97501. I don't think we should suppress the suggestion to add `#![feature(..)]`, though I guess I could be convinced otherwise.

r? `@Nilstrieb` cc `@RalfJung`

Didn't add a test b/c I don't think we test this for lang features either, but I can confirm it does work.

```
warning: the feature `core_intrinsics` is internal to the compiler or standard library
 --> /home/michael/test.rs:1:12
  |
1 | #![feature(core_intrinsics)]
  |            ^^^^^^^^^^^^^^^
  |
  = note: using it is strongly discouraged
  = note: `#[warn(internal_features)]` on by default

thread 'rustc' panicked at compiler/rustc_mir_transform/src/validate.rs:94:25:
broken MIR in Item(DefId(0:6 ~ test[42db]::{impl#0}::add)) (after phase change to runtime-optimized) at bb0[0]:
Cannot perform arithmetic Add on type WrapInt8
stack backtrace:
   0: begin_panic_handler
             at ./library/std/src/panicking.rs:665:5
   1: panic_fmt
             at ./library/core/src/panicking.rs:74:14
   2: fail<alloc::string::String>
             at ./compiler/rustc_mir_transform/src/validate.rs:146:9
   3: run_pass
             at ./compiler/rustc_mir_transform/src/validate.rs:94:13
   4: validate_body
             at ./compiler/rustc_mir_transform/src/pass_manager.rs:193:5
   5: run_passes_inner
             at ./compiler/rustc_mir_transform/src/pass_manager.rs:176:13
   6: rustc_mir_transform::pass_manager::run_passes
             at ./compiler/rustc_mir_transform/src/pass_manager.rs:87:5
   7: run_optimization_passes
             at ./compiler/rustc_mir_transform/src/lib.rs:561:5
   8: inner_optimized_mir
             at ./compiler/rustc_mir_transform/src/lib.rs:667:5
   9: optimized_mir
             at ./compiler/rustc_mir_transform/src/lib.rs:630:21
  10: {closure#0}
             at ./compiler/rustc_query_impl/src/plumbing.rs:285:13
      [... omitted 22 frames ...]
  11: query_get_at<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
             at ./compiler/rustc_middle/src/query/plumbing.rs:145:17
  12: instance_mir
  13: collect_items_of_instance
             at ./compiler/rustc_monomorphize/src/collector.rs:1203:16
  14: {closure#0}
             at ./compiler/rustc_monomorphize/src/collector.rs:447:17
  15: maybe_grow<(), rustc_monomorphize::collector::collect_items_rec::{closure_env#0}>
             at /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/stacker-0.1.15/src/lib.rs:55:9
  16: ensure_sufficient_stack<(), rustc_monomorphize::collector::collect_items_rec::{closure_env#0}>
             at ./compiler/rustc_data_structures/src/stack.rs:17:5
  17: collect_items_rec
             at ./compiler/rustc_monomorphize/src/collector.rs:446:13
  18: collect_items_rec
             at ./compiler/rustc_monomorphize/src/collector.rs:526:13
  19: {closure#0}
             at ./compiler/rustc_monomorphize/src/collector.rs:1597:17
  20: {closure#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>
             at ./compiler/rustc_data_structures/src/sync/parallel.rs:182:34
  21: call_once<(), rustc_data_structures::sync::parallel::enabled::par_for_each_in::{closure#0}::{closure#0}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at ./library/core/src/panic/unwind_safe.rs:272:9
  22: do_call<core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::enabled::par_for_each_in::{closure#0}::{closure#0}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>, ()>
             at ./library/std/src/panicking.rs:557:40
  23: try<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::enabled::par_for_each_in::{closure#0}::{closure#0}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>>
             at ./library/std/src/panicking.rs:521:19
  24: run<(), rustc_data_structures::sync::parallel::enabled::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at ./compiler/rustc_data_structures/src/sync/parallel.rs:28:9
  25: {closure#1}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>
             at ./compiler/rustc_data_structures/src/sync/parallel.rs:186:21
  26: {closure#0}<rustc_middle::mir::mono::MonoItem, rustc_data_structures::sync::parallel::enabled::par_for_each_in::{closure#0}::{closure_env#1}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at ./library/core/src/iter/traits/iterator.rs:815:29
  27: fold<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global, (), core::iter::traits::iterator::Iterator::for_each::call::{closure_env#0}<rustc_middle::mir::mono::MonoItem, rustc_data_structures::sync::parallel::enabled::par_for_each_in::{closure#0}::{closure_env#1}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>>
             at ./library/alloc/src/vec/into_iter.rs:317:25
  28: for_each<alloc::vec::into_iter::IntoIter<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_data_structures::sync::parallel::enabled::par_for_each_in::{closure#0}::{closure_env#1}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at ./library/core/src/iter/traits/iterator.rs:818:9
  29: {closure#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>
             at ./compiler/rustc_data_structures/src/sync/parallel.rs:185:17
  30: parallel_guard<(), rustc_data_structures::sync::parallel::enabled::par_for_each_in::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at ./compiler/rustc_data_structures/src/sync/parallel.rs:44:15
  31: par_for_each_in<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>
             at ./compiler/rustc_data_structures/src/sync/parallel.rs:178:9
  32: {closure#1}
             at ./compiler/rustc_monomorphize/src/collector.rs:1595:13
  33: run<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure_env#1}>
             at ./compiler/rustc_data_structures/src/profiling.rs:754:9
  34: time<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure_env#1}>
             at ./compiler/rustc_session/src/utils.rs:16:9
  35: collect_crate_mono_items
             at ./compiler/rustc_monomorphize/src/collector.rs:1594:9
  36: collect_and_partition_mono_items
             at ./compiler/rustc_monomorphize/src/partitioning.rs:1124:30
  37: {closure#0}
             at ./compiler/rustc_query_impl/src/plumbing.rs:281:9
      [... omitted 22 frames ...]
  38: query_get_at<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>>
             at ./compiler/rustc_middle/src/query/plumbing.rs:145:17
  39: collect_and_partition_mono_items
             at ./compiler/rustc_middle/src/query/plumbing.rs:423:31
  40: collect_and_partition_mono_items
             at ./compiler/rustc_middle/src/query/plumbing.rs:414:17
  41: codegen_crate<rustc_codegen_llvm::LlvmCodegenBackend>
             at ./compiler/rustc_codegen_ssa/src/base.rs:596:25
  42: codegen_crate
             at ./compiler/rustc_codegen_llvm/src/lib.rs:361:18
  43: {closure#0}
             at ./compiler/rustc_interface/src/passes.rs:1027:9
  44: run<alloc::boxed::Box<dyn core::any::Any, alloc::alloc::Global>, rustc_interface::passes::start_codegen::{closure_env#0}>
             at ./compiler/rustc_data_structures/src/profiling.rs:754:9
  45: time<alloc::boxed::Box<dyn core::any::Any, alloc::alloc::Global>, rustc_interface::passes::start_codegen::{closure_env#0}>
             at ./compiler/rustc_session/src/utils.rs:16:9
  46: start_codegen
             at ./compiler/rustc_interface/src/passes.rs:1026:19
  47: codegen_and_build_linker
             at ./compiler/rustc_interface/src/queries.rs:128:31
  48: {closure#6}
             at ./compiler/rustc_driver_impl/src/lib.rs:451:25
  49: {closure#1}<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure_env#6}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
             at ./compiler/rustc_middle/src/ty/context.rs:1336:37
  50: {closure#0}<rustc_middle::ty::context::{impl#19}::enter::{closure_env#1}<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure_env#6}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
             at ./compiler/rustc_middle/src/ty/context/tls.rs:82:9
  51: try_with<core::cell::Cell<*const ()>, rustc_middle::ty::context::tls::enter_context::{closure_env#0}<rustc_middle::ty::context::{impl#19}::enter::{closure_env#1}<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure_env#6}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
             at ./library/std/src/thread/local.rs:283:12
  52: with<core::cell::Cell<*const ()>, rustc_middle::ty::context::tls::enter_context::{closure_env#0}<rustc_middle::ty::context::{impl#19}::enter::{closure_env#1}<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure_env#6}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
             at ./library/std/src/thread/local.rs:260:9
  53: enter_context<rustc_middle::ty::context::{impl#19}::enter::{closure_env#1}<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure_env#6}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
             at ./compiler/rustc_middle/src/ty/context/tls.rs:79:5
  54: enter<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure_env#6}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
             at ./compiler/rustc_middle/src/ty/context.rs:1336:9
  55: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#6}>
             at ./compiler/rustc_interface/src/queries.rs:64:9
  56: {closure#1}
             at ./compiler/rustc_driver_impl/src/lib.rs:450:13
  57: enter<rustc_driver_impl::run_compiler::{closure#0}::{closure_env#1}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
             at ./compiler/rustc_interface/src/queries.rs:209:19
  58: {closure#0}
             at ./compiler/rustc_driver_impl/src/lib.rs:388:22
  59: {closure#1}<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure_env#0}>
             at ./compiler/rustc_interface/src/interface.rs:502:27
  60: {closure#0}<rustc_interface::interface::run_compiler::{closure_env#1}<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure_env#0}>, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             at ./compiler/rustc_interface/src/util.rs:154:13
  61: {closure#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure_env#0}>, core::result::Result<(), rustc_span::ErrorGuaranteed>>, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             at ./compiler/rustc_interface/src/util.rs:106:21
  62: set<rustc_span::SessionGlobals, rustc_interface::util::run_in_thread_with_globals::{closure#0}::{closure#0}::{closure_env#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure_env#0}>, core::result::Result<(), rustc_span::ErrorGuaranteed>>, core::result::Result<(), rustc_span::ErrorGuaranteed>>, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             at /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-1.0.1/src/lib.rs:137:9
  63: create_session_globals_then<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::util::run_in_thread_with_globals::{closure#0}::{closure#0}::{closure_env#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure_env#0}>, core::result::Result<(), rustc_span::ErrorGuaranteed>>, core::result::Result<(), rustc_span::ErrorGuaranteed>>>
             at ./compiler/rustc_span/src/lib.rs:134:5
  64: {closure#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure_env#0}>, core::result::Result<(), rustc_span::ErrorGuaranteed>>, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             at ./compiler/rustc_interface/src/util.rs:105:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

note: using internal features is not supported and expected to cause internal compiler errors when used incorrectly

note: rustc 1.82.0-dev running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [optimized_mir] optimizing MIR for `<impl at /home/michael/test.rs:9:1: 9:32>::add`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-intrinsics Area: Intrinsics A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. F-core_intrinsics Issue in the "core intrinsics" for internal usage only. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
8 participants