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

ICEs galore with const-generic associated type in trait bound #102333

Closed
fmease opened this issue Sep 26, 2022 · 4 comments · Fixed by #102336
Closed

ICEs galore with const-generic associated type in trait bound #102333

fmease opened this issue Sep 26, 2022 · 4 comments · Fixed by #102336
Assignees
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fmease
Copy link
Member

fmease commented Sep 26, 2022

The following code produces several ICEs on both beta and nightly (no #![feature] necessary).

Code

#![crate_type = "lib"]

trait A {
    type T: B<U<1i32> = ()>;
}

trait B {
    type U<const C: i32>;
}

Meta

rustc -Vv:

rustc 1.66.0-nightly (9062b780b 2022-09-21)
binary: rustc
commit-hash: 9062b780b32d2eab060b4432863e085d9504ca5c
commit-date: 2022-09-21
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.0

Error output

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: Could not find associated const on trait
  |
  = note: delayed at compiler/rustc_typeck/src/collect/type_of.rs:442:27

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_typeck/src/check/coercion.rs:176:49

error: internal compiler error: `InferCtxt` incorrectly tainted by errors
  |
  = note: delayed at compiler/rustc_infer/src/infer/mod.rs:1281:27

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_mir_build/src/build/mod.rs:627:18

error: internal compiler error: mir_const_qualif: MIR had errors
 --> ice.rs:4:17
  |
4 |     type T: B<U<1i32> = ()>;
  |                 ^^^^
  |
  = note: delayed at compiler/rustc_mir_transform/src/lib.rs:252:18

error: internal compiler error: PromoteTemps: MIR had errors
 --> ice.rs:4:17
  |
4 |     type T: B<U<1i32> = ()>;
  |                 ^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/promote_consts.rs:52:22

error: internal compiler error: broken MIR in DefId(0:5 ~ ice[8829]::A::T::{constant#0}) ("return type"): bad type [type error]
 --> ice.rs:4:17
  |
4 |     type T: B<U<1i32> = ()>;
  |                 ^^^^
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:517:13

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:785:20

error: internal compiler error: broken MIR in DefId(0:5 ~ ice[8829]::A::T::{constant#0}) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: ice.rs:4:17: 4:21 (#0), scope: scope[0] } }): bad type [type error]
 --> ice.rs:4:17
  |
4 |     type T: B<U<1i32> = ()>;
  |                 ^^^^
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:517:13

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1530:13
Backtrace

stack backtrace:
   0:     0x7f897976e010 - std::backtrace_rs::backtrace::libunwind::trace::hb70cd2c4f10319c4
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f897976e010 - std::backtrace_rs::backtrace::trace_unsynchronized::h6a235690bde8066a
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f897976e010 - std::sys_common::backtrace::_print_fmt::hf423a9f93de17924
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f897976e010 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h81fafbb534b53ab7
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f89797c8e5e - core::fmt::write::h91215ed98af09b40
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f897975eb15 - std::io::Write::write_fmt::h9d32a42fc3233c10
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/std/src/io/mod.rs:1679:15
   6:     0x7f8979770d93 - std::sys_common::backtrace::_print::hebe110643c78e1a1
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f8979770d93 - std::sys_common::backtrace::print::h544b1b31fddff6eb
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f8979770d93 - std::panicking::default_hook::{{closure}}::hf97dcba6b32ea332
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/std/src/panicking.rs:267:22
   9:     0x7f8979770a7f - std::panicking::default_hook::h3f82dc02801e0576
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/std/src/panicking.rs:286:9
  10:     0x7f897bf748d1 - <rustc_driver[610c3dabcb482a3]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[c7389bc70673082e]::ops::function::FnOnce<(&core[c7389bc70673082e]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f89797715cb - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1442642a89018d6d
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/alloc/src/boxed.rs:1954:9
  12:     0x7f89797715cb - std::panicking::rust_panic_with_hook::hb8c8dca0bdad40db
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/std/src/panicking.rs:673:13
  13:     0x7f897d0917d1 - std[2c19137f19a9cec7]::panicking::begin_panic::<rustc_errors[275d4fb119ffacfb]::ExplicitBug>::{closure#0}
  14:     0x7f897d091536 - std[2c19137f19a9cec7]::sys_common::backtrace::__rust_end_short_backtrace::<std[2c19137f19a9cec7]::panicking::begin_panic<rustc_errors[275d4fb119ffacfb]::ExplicitBug>::{closure#0}, !>
  15:     0x7f897d0911d6 - std[2c19137f19a9cec7]::panicking::begin_panic::<rustc_errors[275d4fb119ffacfb]::ExplicitBug>
  16:     0x7f897d08e9b6 - std[2c19137f19a9cec7]::panic::panic_any::<rustc_errors[275d4fb119ffacfb]::ExplicitBug>
  17:     0x7f897ba92c4b - <rustc_errors[275d4fb119ffacfb]::HandlerInner as core[c7389bc70673082e]::ops::drop::Drop>::drop
  18:     0x7f897ad4f778 - core[c7389bc70673082e]::ptr::drop_in_place::<rustc_session[40303a05d79b8f9]::parse::ParseSess>
  19:     0x7f897ad0d6d8 - <alloc[9a4df20b0dad2694]::rc::Rc<rustc_session[40303a05d79b8f9]::session::Session> as core[c7389bc70673082e]::ops::drop::Drop>::drop
  20:     0x7f897ad0a2ed - core[c7389bc70673082e]::ptr::drop_in_place::<rustc_interface[121647ee48321f2a]::interface::Compiler>
  21:     0x7f897ad07b74 - rustc_interface[121647ee48321f2a]::interface::create_compiler_and_run::<core[c7389bc70673082e]::result::Result<(), rustc_errors[275d4fb119ffacfb]::ErrorGuaranteed>, rustc_driver[610c3dabcb482a3]::run_compiler::{closure#1}>
  22:     0x7f897ad06072 - <scoped_tls[d2720ff23ff3c466]::ScopedKey<rustc_span[d840d66cf15b0e9]::SessionGlobals>>::set::<rustc_interface[121647ee48321f2a]::interface::run_compiler<core[c7389bc70673082e]::result::Result<(), rustc_errors[275d4fb119ffacfb]::ErrorGuaranteed>, rustc_driver[610c3dabcb482a3]::run_compiler::{closure#1}>::{closure#0}, core[c7389bc70673082e]::result::Result<(), rustc_errors[275d4fb119ffacfb]::ErrorGuaranteed>>
  23:     0x7f897ad05d5f - std[2c19137f19a9cec7]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[121647ee48321f2a]::util::run_in_thread_pool_with_globals<rustc_interface[121647ee48321f2a]::interface::run_compiler<core[c7389bc70673082e]::result::Result<(), rustc_errors[275d4fb119ffacfb]::ErrorGuaranteed>, rustc_driver[610c3dabcb482a3]::run_compiler::{closure#1}>::{closure#0}, core[c7389bc70673082e]::result::Result<(), rustc_errors[275d4fb119ffacfb]::ErrorGuaranteed>>::{closure#0}, core[c7389bc70673082e]::result::Result<(), rustc_errors[275d4fb119ffacfb]::ErrorGuaranteed>>
  24:     0x7f897bdda9d0 - <<std[2c19137f19a9cec7]::thread::Builder>::spawn_unchecked_<rustc_interface[121647ee48321f2a]::util::run_in_thread_pool_with_globals<rustc_interface[121647ee48321f2a]::interface::run_compiler<core[c7389bc70673082e]::result::Result<(), rustc_errors[275d4fb119ffacfb]::ErrorGuaranteed>, rustc_driver[610c3dabcb482a3]::run_compiler::{closure#1}>::{closure#0}, core[c7389bc70673082e]::result::Result<(), rustc_errors[275d4fb119ffacfb]::ErrorGuaranteed>>::{closure#0}, core[c7389bc70673082e]::result::Result<(), rustc_errors[275d4fb119ffacfb]::ErrorGuaranteed>>::{closure#1} as core[c7389bc70673082e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f897977b3b3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he225f53d02ef001f
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/alloc/src/boxed.rs:1940:9
  26:     0x7f897977b3b3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1d16365b1f15b7b7
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/alloc/src/boxed.rs:1940:9
  27:     0x7f897977b3b3 - std::sys::unix::thread::Thread::new::thread_start::h91bd867cccfe281f
                               at /rustc/9062b780b32d2eab060b4432863e085d9504ca5c/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f897951f78d - <unknown>
  29:     0x7f89795a08e4 - 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.66.0-nightly (9062b780b 2022-09-21) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

@rustbot label F-generic_associated_types A-const-generics

@fmease fmease 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 Sep 26, 2022
@rustbot rustbot added A-const-generics Area: const generics (parameters and arguments) F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs labels Sep 26, 2022
@fmease fmease changed the title ICEs galore: ICEs galore with const generic bound Sep 26, 2022
@fmease fmease changed the title ICEs galore with const generic bound ICEs galore with const-generic associated type in trait bound Sep 26, 2022
@compiler-errors compiler-errors self-assigned this Sep 27, 2022
@compiler-errors

This comment was marked as off-topic.

@compiler-errors
Copy link
Member

Wait wrong issue

@est31
Copy link
Member

est31 commented Sep 27, 2022

As GATs are stable on beta but not on stable, similar to here:

@rustbot label regression-from-stable-to-beta

@rustbot rustbot added regression-from-stable-to-beta Performance or correctness regression from stable to beta. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Sep 27, 2022
@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Sep 28, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Sep 28, 2022
…ckh726

Fix associated type bindings with anon const in GAT position

The first commit formats `type_of.rs`, which is really hard to maintain since it uses a bunch of features like `let`-chains and `if let` match arm bindings. Best if you just review the second two diffs.

Fixes rust-lang#102333
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Sep 28, 2022
…ckh726

Fix associated type bindings with anon const in GAT position

The first commit formats `type_of.rs`, which is really hard to maintain since it uses a bunch of features like `let`-chains and `if let` match arm bindings. Best if you just review the second two diffs.

Fixes rust-lang#102333
@bors bors closed this as completed in 1be9ec5 Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. 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.

5 participants