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

ICE: None in compiler/rustc_passes/src/check_const.rs #102156

Closed
matthiaskrgr opened this issue Sep 22, 2022 · 6 comments · Fixed by #102361
Closed

ICE: None in compiler/rustc_passes/src/check_const.rs #102156

matthiaskrgr opened this issue Sep 22, 2022 · 6 comments · Fixed by #102361
Assignees
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. 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.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Sep 22, 2022

Code

code from rustc_codegen_cranelift/build_sysroot/sysroot_src/library/alloc/src/boxed.rs

#![feature(allocator_api)]

#![feature(const_trait_impl)]
use core::convert::{From, TryFrom};
use std::pin::Pin;
use std::alloc::Allocator;
impl<T: ?Sized, A: Allocator> const From<Box<T, A>> for Pin<Box<T, A>>
where
    A: 'static,
{}

pub fn main() {}

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (e7119a030 2022-09-22)
binary: rustc
commit-hash: e7119a0300b87a3d670408ee8e847c6821b3ae80
commit-date: 2022-09-22
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.0

Error output

error[E0433]: failed to resolve: maybe a missing crate `core`?
 --> ./alloc/src/boxed.rs:4:5
  |
4 | use core::convert::{From, TryFrom};
  |     ^^^^ maybe a missing crate `core`?
  |
  = help: consider adding `extern crate core` to use the `core` crate
Backtrace

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_passes/src/check_const.rs:202:26
stack backtrace:
   0:     0x7fe48be4aff0 - std::backtrace_rs::backtrace::libunwind::trace::hf4e04b2e4313927b
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7fe48be4aff0 - std::backtrace_rs::backtrace::trace_unsynchronized::h2771cf061d4680d1
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fe48be4aff0 - std::sys_common::backtrace::_print_fmt::h2e413508900ead1c
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fe48be4aff0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb886319318f6b897
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fe48bea5e1e - core::fmt::write::hd7350cb51945e18c
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/core/src/fmt/mod.rs:1202:17
   5:     0x7fe48be3baf5 - std::io::Write::write_fmt::ha7bc763f922fc662
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/io/mod.rs:1679:15
   6:     0x7fe48be4dd73 - std::sys_common::backtrace::_print::h7ad0003e1b032609
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fe48be4dd73 - std::sys_common::backtrace::print::h6f247b59322d4826
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fe48be4dd73 - std::panicking::default_hook::{{closure}}::h71a394bfa368bc38
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/panicking.rs:267:22
   9:     0x7fe48be4da5f - std::panicking::default_hook::h353829743ca9a29f
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/panicking.rs:286:9
  10:     0x7fe48e663ef1 - <rustc_driver[7857f239df018eab]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[cde1ce9e21f08391]::ops::function::FnOnce<(&core[cde1ce9e21f08391]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7fe48be4e5ab - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h5c7ac9f6a4be07e2
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/alloc/src/boxed.rs:1954:9
  12:     0x7fe48be4e5ab - std::panicking::rust_panic_with_hook::h6ad4960c15699d95
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/panicking.rs:673:13
  13:     0x7fe48be4e3c1 - std::panicking::begin_panic_handler::{{closure}}::h21fce9af2d027685
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/panicking.rs:558:13
  14:     0x7fe48be4b49c - std::sys_common::backtrace::__rust_end_short_backtrace::h218f1ce3892987af
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys_common/backtrace.rs:138:18
  15:     0x7fe48be4e122 - rust_begin_unwind
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/panicking.rs:556:5
  16:     0x7fe48bea29f3 - core::panicking::panic_fmt::h06680f628054808f
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/core/src/panicking.rs:142:14
  17:     0x7fe48bea283d - core::panicking::panic::he9930d5c71b64ea9
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/core/src/panicking.rs:48:5
  18:     0x7fe48d967b48 - <rustc_middle[33a3dc3ec8228005]::hir::map::Map>::visit_item_likes_in_module::<rustc_passes[de3676249625e36f]::check_const::CheckConstVisitor>
  19:     0x7fe48d967a1c - rustc_passes[de3676249625e36f]::check_const::check_mod_const_bodies
  20:     0x7fe48d602996 - rustc_query_system[d3b2657d85679091]::query::plumbing::try_execute_query::<rustc_query_impl[542bbd4b66bfb449]::plumbing::QueryCtxt, rustc_query_system[d3b2657d85679091]::query::caches::DefaultCache<rustc_span[4a0a9e8ceb64f0f4]::def_id::LocalDefId, ()>>
  21:     0x7fe48e0e93d9 - rustc_query_system[d3b2657d85679091]::query::plumbing::get_query::<rustc_query_impl[542bbd4b66bfb449]::queries::check_mod_const_bodies, rustc_query_impl[542bbd4b66bfb449]::plumbing::QueryCtxt>
  22:     0x7fe48da432ea - <core[cde1ce9e21f08391]::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures[bf19c7e493ef6519]::sync::par_for_each_in<&[rustc_span[4a0a9e8ceb64f0f4]::def_id::LocalDefId], <rustc_middle[33a3dc3ec8228005]::hir::map::Map>::par_for_each_module<rustc_interface[f2560d97934cc6f6]::passes::analysis::{closure#0}::{closure#1}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}> as core[cde1ce9e21f08391]::ops::function::FnOnce<()>>::call_once
  23:     0x7fe48da42c48 - rustc_data_structures[bf19c7e493ef6519]::sync::par_for_each_in::<&[rustc_span[4a0a9e8ceb64f0f4]::def_id::LocalDefId], <rustc_middle[33a3dc3ec8228005]::hir::map::Map>::par_for_each_module<rustc_interface[f2560d97934cc6f6]::passes::analysis::{closure#0}::{closure#1}::{closure#0}>::{closure#0}>
  24:     0x7fe48da42ad2 - <core[cde1ce9e21f08391]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[f2560d97934cc6f6]::passes::analysis::{closure#0}::{closure#1}> as core[cde1ce9e21f08391]::ops::function::FnOnce<()>>::call_once
  25:     0x7fe48da420d9 - <rustc_session[fa757ff4c2b8954a]::session::Session>::time::<(), rustc_interface[f2560d97934cc6f6]::passes::analysis::{closure#0}>
  26:     0x7fe48da4103e - rustc_interface[f2560d97934cc6f6]::passes::analysis
  27:     0x7fe48e432e34 - rustc_query_system[d3b2657d85679091]::query::plumbing::try_execute_query::<rustc_query_impl[542bbd4b66bfb449]::plumbing::QueryCtxt, rustc_query_system[d3b2657d85679091]::query::caches::DefaultCache<(), core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>>
  28:     0x7fe48e432b67 - rustc_query_system[d3b2657d85679091]::query::plumbing::get_query::<rustc_query_impl[542bbd4b66bfb449]::queries::analysis, rustc_query_impl[542bbd4b66bfb449]::plumbing::QueryCtxt>
  29:     0x7fe48d3fa0c3 - <rustc_interface[f2560d97934cc6f6]::passes::QueryContext>::enter::<rustc_driver[7857f239df018eab]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>
  30:     0x7fe48d3f4a0c - rustc_interface[f2560d97934cc6f6]::interface::create_compiler_and_run::<core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>, rustc_driver[7857f239df018eab]::run_compiler::{closure#1}>
  31:     0x7fe48d3f3342 - <scoped_tls[8ee1aa185b4607e2]::ScopedKey<rustc_span[4a0a9e8ceb64f0f4]::SessionGlobals>>::set::<rustc_interface[f2560d97934cc6f6]::interface::run_compiler<core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>, rustc_driver[7857f239df018eab]::run_compiler::{closure#1}>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>
  32:     0x7fe48d3f302f - std[35bb8192b5670ad2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f2560d97934cc6f6]::util::run_in_thread_pool_with_globals<rustc_interface[f2560d97934cc6f6]::interface::run_compiler<core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>, rustc_driver[7857f239df018eab]::run_compiler::{closure#1}>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>
  33:     0x7fe48e4c8980 - <<std[35bb8192b5670ad2]::thread::Builder>::spawn_unchecked_<rustc_interface[f2560d97934cc6f6]::util::run_in_thread_pool_with_globals<rustc_interface[f2560d97934cc6f6]::interface::run_compiler<core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>, rustc_driver[7857f239df018eab]::run_compiler::{closure#1}>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>::{closure#1} as core[cde1ce9e21f08391]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7fe48be58393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbe492c93bea3125c
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/alloc/src/boxed.rs:1940:9
  35:     0x7fe48be58393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1c6cb812ee67c431
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/alloc/src/boxed.rs:1940:9
  36:     0x7fe48be58393 - std::sys::unix::thread::Thread::new::thread_start::hcd53b5f11cecf106
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys/unix/thread.rs:108:17
  37:     0x7fe48bbb078d - <unknown>
  38:     0x7fe48bc318e4 - clone
  39:                0x0 - <unknown>

error: internal compiler error: unexpected panic

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.66.0-nightly (e7119a030 2022-09-22) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_mod_const_bodies] checking consts in top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Sep 22, 2022
@matthiaskrgr
Copy link
Member Author

couple of files from the repo that reproduce this:

./library/alloc/src/borrow.rs
./library/alloc/src/boxed.rs
./library/alloc/tests/boxed.rs
./library/alloc/tests/lib.rs
./library/core/src/array/mod.rs
./library/core/src/convert/mod.rs
./library/core/src/convert/num.rs
./library/core/src/lib.rs
./library/core/src/mem/manually_drop.rs
./library/core/src/mem/mod.rs
./library/core/src/num/mod.rs
./library/core/src/num/nonzero.rs
./library/core/src/num/wrapping.rs
./library/core/src/option.rs
./library/core/src/ptr/mod.rs
./library/core/src/ptr/non_null.rs
./library/core/src/ptr/unique.rs
./library/core/src/slice/index.rs
./library/core/src/slice/mod.rs
./library/core/src/str/mod.rs
./library/core/src/str/traits.rs
./src/test/ui/rfc-2632-const-trait-impl/staged-api.rs

@matthiaskrgr
Copy link
Member Author

This regressed in 7a8636c cc @fee1-dead

@fee1-dead
Copy link
Member

fee1-dead commented Sep 23, 2022

Thanks for the bisection. This should be a simple fix:

Replace

let def_id = trait_ref.trait_def_id().unwrap();

with

let Some(def_id) = trait_ref.trait_def_id() else { return; };

And add a test as well :)

@rustbot label E-easy

@mucinoab
Copy link
Contributor

@rustbot claim

@fee1-dead
Copy link
Member

@mucinoab Are you still working on this? If not, I would like to fix this as soon as possible.

@mucinoab
Copy link
Contributor

@fee1-dead Sorry for the delay, no problem. Thanks.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Sep 30, 2022
@bors bors closed this as completed in 27b280e Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants