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

internal compiler error: min_const_generics resolve check didn't stop compilation #96654

Closed
mareksom opened this issue May 2, 2022 · 1 comment · Fixed by #96830
Closed
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been 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.

Comments

@mareksom
Copy link

mareksom commented May 2, 2022

Code

src/main.rs

struct A<const M: u32> {}

struct B<const M: u32> {}

impl<const M: u32> B<M> {
  const M: u32 = M;
}

struct C<const M: u32> {
  a: A<{B::<1>::M}>,
}

fn main() {}

Cargo.toml

[package]
name = "bug"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

Meta

rustc --version --verbose:

rustc 1.60.0 (7737e0b5c 2022-04-04)
binary: rustc
commit-hash: 7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c
commit-date: 2022-04-04
host: x86_64-unknown-linux-gnu
release: 1.60.0
LLVM version: 14.0.0

Error output

$ cargo build

   Compiling bug v0.1.0 (/home/mareksom/lab/bug)
warning: struct is never constructed: `A`
 --> src/main.rs:1:8
  |
1 | struct A<const M: u32> {}
  |        ^
  |
  = note: `#[warn(dead_code)]` on by default

warning: struct is never constructed: `B`
 --> src/main.rs:3:8
  |
3 | struct B<const M: u32> {}
  |        ^

warning: associated constant is never used: `M`
 --> src/main.rs:6:3
  |
6 |   const M: u32 = M;
  |   ^^^^^^^^^^^^^^^^^

warning: struct is never constructed: `C`
 --> src/main.rs:9:8
  |
9 | struct C<const M: u32> {
  |        ^

warning: Error finalizing incremental compilation session directory `/home/mareksom/lab/bug/target/debug/incremental/bug-3u769ve6liwcr/s-g9f1tqsdvi-1ke0t4i-working`: No such file or directory (os error 2)

error: internal compiler error: min_const_generics resolve check didn't stop compilation
  --> src/main.rs:10:9
   |
10 |   a: A<{B::<1>::M}>,
   |         ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_resolve/src/lib.rs:2886:46

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1176:13
stack backtrace:
   0:     0x7f7a074f886d - std::backtrace_rs::backtrace::libunwind::trace::hee598835bc88d35b
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7a074f886d - std::backtrace_rs::backtrace::trace_unsynchronized::h9cdc730ba5cf5d72
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7a074f886d - std::sys_common::backtrace::_print_fmt::h75aeaf7ed30e43fa
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f7a074f886d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h606862f787600875
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f7a075584ec - core::fmt::write::he803f0f418caf762
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/fmt/mod.rs:1190:17
   5:     0x7f7a074e8a98 - std::io::Write::write_fmt::h70bc45872f37e7bb
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/io/mod.rs:1657:15
   6:     0x7f7a074fc847 - std::sys_common::backtrace::_print::h64d038cf8ac3e13e
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f7a074fc847 - std::sys_common::backtrace::print::h359300b4a7fccf65
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f7a074fc847 - std::panicking::default_hook::{{closure}}::hf51be35e2f510149
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:295:22
   9:     0x7f7a074fc510 - std::panicking::default_hook::h03ca0f22e1d2d25e
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:314:9
  10:     0x7f7a07c882c1 - rustc_driver[6eeb127b85fe99ac]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f7a074fd124 - std::panicking::rust_panic_with_hook::h3b7380e99b825b63
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:702:17
  12:     0x7f7a074fcdd7 - std::panicking::begin_panic_handler::{{closure}}::h8e849d0710154ce0
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:588:13
  13:     0x7f7a074f8d34 - std::sys_common::backtrace::__rust_end_short_backtrace::hedcdaddbd4c46cc5
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f7a074fcae9 - rust_begin_unwind
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
  15:     0x7f7a074c5863 - core::panicking::panic_fmt::he1bbc7336d49a357
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
  16:     0x7f7a08d7133c - core[2734bb1f7d9ec6a5]::panicking::panic_display::<&str>
  17:     0x7f7a0a3c831d - <rustc_errors[bd800fb2a5e0b9f5]::HandlerInner>::flush_delayed
  18:     0x7f7a0a3c677a - <rustc_errors[bd800fb2a5e0b9f5]::HandlerInner as core[2734bb1f7d9ec6a5]::ops::drop::Drop>::drop
  19:     0x7f7a09ae7bb6 - core[2734bb1f7d9ec6a5]::ptr::drop_in_place::<rustc_session[95a8f1c94d15e5dc]::parse::ParseSess>
  20:     0x7f7a09aea45a - <alloc[9a009599db7253ec]::rc::Rc<rustc_session[95a8f1c94d15e5dc]::session::Session> as core[2734bb1f7d9ec6a5]::ops::drop::Drop>::drop
  21:     0x7f7a09acf2ec - core[2734bb1f7d9ec6a5]::ptr::drop_in_place::<rustc_interface[afc566840a941718]::interface::Compiler>
  22:     0x7f7a09ad7f1e - rustc_interface[afc566840a941718]::interface::create_compiler_and_run::<core[2734bb1f7d9ec6a5]::result::Result<(), rustc_errors[bd800fb2a5e0b9f5]::ErrorReported>, rustc_driver[6eeb127b85fe99ac]::run_compi
ler::{closure#1}>
  23:     0x7f7a09abd134 - std[cd3cf6af28dff6de]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[afc566840a941718]::util::run_in_thread_pool_with_globals<rustc_interface[afc566840a941718]::interface::run_comp
iler<core[2734bb1f7d9ec6a5]::result::Result<(), rustc_errors[bd800fb2a5e0b9f5]::ErrorReported>, rustc_driver[6eeb127b85fe99ac]::run_compiler::{closure#1}>::{closure#0}, core[2734bb1f7d9ec6a5]::result::Result<(), rustc_errors[bd800f
b2a5e0b9f5]::ErrorReported>>::{closure#0}, core[2734bb1f7d9ec6a5]::result::Result<(), rustc_errors[bd800fb2a5e0b9f5]::ErrorReported>>
  24:     0x7f7a09af03e9 - <<std[cd3cf6af28dff6de]::thread::Builder>::spawn_unchecked_<rustc_interface[afc566840a941718]::util::run_in_thread_pool_with_globals<rustc_interface[afc566840a941718]::interface::run_compiler<core[2734bb1
f7d9ec6a5]::result::Result<(), rustc_errors[bd800fb2a5e0b9f5]::ErrorReported>, rustc_driver[6eeb127b85fe99ac]::run_compiler::{closure#1}>::{closure#0}, core[2734bb1f7d9ec6a5]::result::Result<(), rustc_errors[bd800fb2a5e0b9f5]::Erro
rReported>>::{closure#0}, core[2734bb1f7d9ec6a5]::result::Result<(), rustc_errors[bd800fb2a5e0b9f5]::ErrorReported>>::{closure#1} as core[2734bb1f7d9ec6a5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f7a07508d03 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf70ac038171e3e1a
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/alloc/src/boxed.rs:1853:9
  26:     0x7f7a07508d03 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he6690128792365ad
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/alloc/src/boxed.rs:1853:9
  27:     0x7f7a07508d03 - std::sys::unix::thread::Thread::new::thread_start::ha07928d93d5a5ec9
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f7a0741d609 - start_thread
                               at /build/glibc-sMfBJT/glibc-2.31/nptl/pthread_create.c:477:8
  29:     0x7f7a07336163 - clone
  30:                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.60.0 (7737e0b5c 2022-04-04) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
end of query stack
warning: `bug` (bin "bug") generated 5 warnings
error: could not compile `bug`; 5 warnings emitted
Backtrace

$ RUST_BACKTRACE=1 cargo build

   Compiling bug v0.1.0 (/home/mareksom/lab/bug)
warning: struct is never constructed: `A`
 --> src/main.rs:1:8
  |
1 | struct A<const M: u32> {}
  |        ^
  |
  = note: `#[warn(dead_code)]` on by default

warning: struct is never constructed: `B`
 --> src/main.rs:3:8
  |
3 | struct B<const M: u32> {}
  |        ^

warning: associated constant is never used: `M`
 --> src/main.rs:6:3
  |
6 |   const M: u32 = M;
  |   ^^^^^^^^^^^^^^^^^

warning: struct is never constructed: `C`
 --> src/main.rs:9:8
  |
9 | struct C<const M: u32> {
  |        ^

warning: Error finalizing incremental compilation session directory `/home/mareksom/lab/bug/target/debug/incremental/bug-3u769ve6liwcr/s-g9f1uxo5u4-1eiyj2b-working`: No such file or directory (os error 2)

error: internal compiler error: min_const_generics resolve check didn't stop compilation
  --> src/main.rs:10:9
   |
10 |   a: A<{B::<1>::M}>,
   |         ^^^^^^^^^
   |
   = note: delayed at compiler/rustc_resolve/src/lib.rs:2886:46

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1176:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
   2: core::panicking::panic_display::<&str>
   3: <rustc_errors::HandlerInner>::flush_delayed
   4: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   5: core::ptr::drop_in_place::<rustc_session::parse::ParseSess>
   6: <alloc::rc::Rc<rustc_session::session::Session> as core::ops::drop::Drop>::drop
   7: core::ptr::drop_in_place::<rustc_interface::interface::Compiler>
   8: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.60.0 (7737e0b5c 2022-04-04) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
end of query stack
warning: `bug` (bin "bug") generated 5 warnings
error: could not compile `bug`; 5 warnings emitted

@mareksom mareksom 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 2, 2022
@matthiaskrgr matthiaskrgr added the A-incr-comp Area: Incremental compilation label May 3, 2022
@lqd
Copy link
Member

lqd commented May 4, 2022

Interestingly enough:

It's a bit unclear to me why that PR fixed it (and that ICE looks at least a year old), but in any case this piece of code will stop ICEing in 1.61, releasing in a couple weeks.

@JohnTitor JohnTitor added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed A-incr-comp Area: Incremental compilation labels May 5, 2022
JohnTitor added a commit to JohnTitor/rust that referenced this issue May 8, 2022
@bors bors closed this as completed in 4c162a1 May 8, 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-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants