Skip to content

ICE with const generics and GATs #79666

Closed
@cynecx

Description

@cynecx

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


Metadata

Metadata

Assignees

Labels

A-GATsArea: Generic associated types (GATs)A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-const_generics`#![feature(const_generics)]`F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATsI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions