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 with const generics and GATs #79666

Closed
cynecx opened this issue Dec 3, 2020 · 3 comments · Fixed by #81911
Closed

ICE with const generics and GATs #79666

cynecx opened this issue Dec 3, 2020 · 3 comments · Fixed by #81911
Assignees
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs glacier ICE tracked in rust-lang/glacier. 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

@cynecx
Copy link
Contributor

cynecx commented Dec 3, 2020

Code

#![feature(const_generics)]
#![feature(generic_associated_types)]

trait A {
    type B<const N: usize>;
    
    fn foo<const N: usize>(&self) -> Self::B<{N}>;
}

Playground

Meta

rustc 1.50.0-nightly (1c389ffef 2020-11-24)
binary: rustc
commit-hash: 1c389ffeff814726dec325f0f2b0c99107df2673
commit-date: 2020-11-24
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly

Error output

warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
 --> src/main.rs:1:12
  |
1 | #![feature(const_generics)]
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
  = help: consider using `min_const_generics` instead, which is more stable and complete

warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
 --> src/main.rs:2:12
  |
2 | #![feature(generic_associated_types)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information

warning: Error finalizing incremental compilation session directory `/home/cynecx/dev/rust-ice/target/debug/incremental/rust_ice-2od6n63huil2c/s-ftn1ij8uum-1wj4523-working`: No such file or directory (os error 2)

warning: 3 warnings emitted

error: internal compiler error: unexpected const parent path Ty(Ty { hir_id: HirId { owner: DefId(0:6 ~ rust_ice[b006]::A::foo), local_id: 7 }, kind: Path(TypeRelative(Ty { hir_id: HirId { owner: DefId(0:6 ~ rust_ice[b006]::A::foo), local_id: 9 }, kind: Path(Resolved(None, Path { span: src/main.rs:7:38: 7:50 (#0), res: SelfTy(Some(DefId(0:3 ~ rust_ice[b006]::A)), None), segments: [PathSegment { ident: Self#0, hir_id: Some(HirId { owner: DefId(0:6 ~ rust_ice[b006]::A::foo), local_id: 8 }), res: Some(SelfTy(Some(DefId(0:3 ~ rust_ice[b006]::A)), None)), args: None, infer_args: false }] })), span: src/main.rs:7:38: 7:50 (#0) }, PathSegment { ident: B#0, hir_id: Some(HirId { owner: DefId(0:6 ~ rust_ice[b006]::A::foo), local_id: 15 }), res: Some(Err), args: Some(GenericArgs { args: [Const(ConstArg { value: AnonConst { hir_id: HirId { owner: DefId(0:6 ~ rust_ice[b006]::A::foo), local_id: 10 }, body: BodyId { hir_id: HirId { owner: DefId(0:6 ~ rust_ice[b006]::A::foo), local_id: 14 } } }, span: src/main.rs:7:46: 7:49 (#0) })], bindings: [], parenthesized: false }), infer_args: false })), span: src/main.rs:7:38: 7:50 (#0) })
 --> src/main.rs:7:46
  |
7 |     fn foo<const N: usize>(&self) -> Self::B<{N}>;
  |                                              ^^^
  |
  = note: delayed at compiler/rustc_typeck/src/collect/type_of.rs:83:34

error: internal compiler error: unexpected const parent in type_of_def_id(): Ty(Ty { hir_id: HirId { owner: DefId(0:6 ~ rust_ice[b006]::A::foo), local_id: 7 }, kind: Path(TypeRelative(Ty { hir_id: HirId { owner: DefId(0:6 ~ rust_ice[b006]::A::foo), local_id: 9 }, kind: Path(Resolved(None, Path { span: src/main.rs:7:38: 7:50 (#0), res: SelfTy(Some(DefId(0:3 ~ rust_ice[b006]::A)), None), segments: [PathSegment { ident: Self#0, hir_id: Some(HirId { owner: DefId(0:6 ~ rust_ice[b006]::A::foo), local_id: 8 }), res: Some(SelfTy(Some(DefId(0:3 ~ rust_ice[b006]::A)), None)), args: None, infer_args: false }] })), span: src/main.rs:7:38: 7:50 (#0) }, PathSegment { ident: B#0, hir_id: Some(HirId { owner: DefId(0:6 ~ rust_ice[b006]::A::foo), local_id: 15 }), res: Some(Err), args: Some(GenericArgs { args: [Const(ConstArg { value: AnonConst { hir_id: HirId { owner: DefId(0:6 ~ rust_ice[b006]::A::foo), local_id: 10 }, body: BodyId { hir_id: HirId { owner: DefId(0:6 ~ rust_ice[b006]::A::foo), local_id: 14 } } }, span: src/main.rs:7:46: 7:49 (#0) })], bindings: [], parenthesized: false }), infer_args: false })), span: src/main.rs:7:38: 7:50 (#0) })
  |
  = note: delayed at compiler/rustc_typeck/src/collect/type_of.rs:334:26

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

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_typeck/src/check/fn_ctxt/checks.rs:707:27

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

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

error: internal compiler error: cat_expr Errd
 --> src/main.rs:7:46
  |
7 |     fn foo<const N: usize>(&self) -> Self::B<{N}>;
  |                                              ^^^
  |
  = note: delayed at compiler/rustc_typeck/src/check/regionck.rs:405:31

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

error: internal compiler error: mir_const_qualif: MIR had errors
 --> src/main.rs:7:46
  |
7 |     fn foo<const N: usize>(&self) -> Self::B<{N}>;
  |                                              ^^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/mod.rs:229:18

error: internal compiler error: PromoteTemps: MIR had errors
 --> src/main.rs:7:46
  |
7 |     fn foo<const N: usize>(&self) -> Self::B<{N}>;
  |                                              ^^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/promote_consts.rs:55:22

error: internal compiler error: broken MIR in DefId(0:8 ~ rust_ice[b006]::A::foo::{constant#0}) ("return type"): bad type [type error]
 --> src/main.rs:7:46
  |
7 |     fn foo<const N: usize>(&self) -> Self::B<{N}>;
  |                                              ^^^
  |
  = note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:253:27

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

error: internal compiler error: broken MIR in DefId(0:8 ~ rust_ice[b006]::A::foo::{constant#0}) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: src/main.rs:7:46: 7:49 (#0), scope: scope[0] } }): bad type [type error]
 --> src/main.rs:7:46
  |
7 |     fn foo<const N: usize>(&self) -> Self::B<{N}>;
  |                                              ^^^
  |
  = note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:253:27

Backtrace

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:974:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/1c389ffeff814726dec325f0f2b0c99107df2673/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/1c389ffeff814726dec325f0f2b0c99107df2673/library/std/src/panicking.rs:435:5
   2: rustc_errors::HandlerInner::flush_delayed
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place
   5: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   6: core::ptr::drop_in_place
   7: rustc_span::with_source_map
   8: scoped_tls::ScopedKey<T>::set
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.50.0-nightly (1c389ffef 2020-11-24) running on x86_64-unknown-linux-gnu


@cynecx cynecx 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 Dec 3, 2020
@jonas-schievink jonas-schievink added A-const-generics Area: const generics (parameters and arguments) F-const_generics `#![feature(const_generics)]` F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs labels Dec 3, 2020
@camelid
Copy link
Member

camelid commented Dec 9, 2020

rustbot added a commit to rustbot/glacier that referenced this issue Dec 9, 2020
camelid added a commit to camelid/glacier that referenced this issue Dec 9, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 9, 2020
@matthewjasper
Copy link
Contributor

cc #75415

@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 6, 2021

Guess I should claim this too since its likely a duplicate of that issue?
@rustbot claim

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Feb 11, 2021
…komatsakis

GAT/const_generics: Allow with_opt_const_param to return GAT param def_id

Fixes rust-lang#75415
Fixes rust-lang#79666
cc `@lcnr`

I've absolutely no idea who to r?  for this...
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Feb 12, 2021
…komatsakis

GAT/const_generics: Allow with_opt_const_param to return GAT param def_id

Fixes rust-lang#75415
Fixes rust-lang#79666
cc ``@lcnr``

I've absolutely no idea who to r?  for this...
@bors bors closed this as completed in b67be3a Feb 13, 2021
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-const_generics `#![feature(const_generics)]` F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs glacier ICE tracked in rust-lang/glacier. 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.

6 participants