Skip to content

ICE when running an associated function with a const generic parameter #74255

Closed
@beepster4096

Description

@beepster4096

Code

#![feature(const_generics)]
#![allow(dead_code, incomplete_features)]

#[derive(PartialEq, Eq)]
enum IceEnum {
    Variant
}

struct IceStruct;

impl IceStruct {
	fn ice_struct_fn<const I: IceEnum>() {}
}

fn ice_fn() {
	IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
}

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (daecab3a7 2020-07-10)
binary: rustc
commit-hash: daecab3a784f28082df90cebb204998051f3557d
commit-date: 2020-07-10
host: x86_64-pc-windows-msvc
release: 1.46.0-nightly
LLVM version: 10.0

Error output

error: internal compiler error: unexpected const parent path Expr(Expr { hir_id: HirId { owner: DefId(0:8 ~ icetest[e2da]::ice_fn[0]), local_id: 10 }, kind: Path(TypeRelative(Ty { hir_id: HirId { owner: DefId(0:8 ~ icetest[e2da]::ice_fn[0]), local_id: 2 }, kind: Path(Resolved(None, Path { span: src\lib.rs:16:2: 16:48 (#0), res: 
Def(Struct, DefId(0:3 ~ icetest[e2da]::IceStruct[0])), segments: [PathSegment { ident: IceStruct#0, hir_id: Some(HirId { owner: DefId(0:8 ~ icetest[e2da]::ice_fn[0]), local_id: 1 }), res: Some(Err), args: None, infer_args: true }] })), span: src\lib.rs:16:2: 16:48 (#0) }, PathSegment { ident: ice_struct_fn#0, hir_id: Some(HirId 
{ owner: DefId(0:8 ~ icetest[e2da]::ice_fn[0]), local_id: 9 }), res: Some(Err), args: Some(GenericArgs { args: [Const(ConstArg { value: AnonConst { hir_id: HirId { owner: DefId(0:8 ~ icetest[e2da]::ice_fn[0]), local_id: 3 }, body: BodyId { hir_id: HirId { owner: DefId(0:8 ~ icetest[e2da]::ice_fn[0]), local_id: 8 } } }, span: src\lib.rs:16:29: 16:47 (#0) })], bindings: [], parenthesized: false }), infer_args: false })), attrs: ThinVec(None), span: src\lib.rs:16:2: 16:48 (#0) })
  |
  = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: cat_expr Errd
  --> src\lib.rs:16:29
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |                                ^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: `ErrorReported` without an error
  --> src\lib.rs:16:29
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |                                ^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: cat_expr Errd
  --> src\lib.rs:15:13
   |
15 |   fn ice_fn() {
   |  _____________^
16 | |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
17 | | }
   | |_^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: cat_expr Errd
  --> src\lib.rs:16:2
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: PromoteTemps: MIR had errors
  --> src\lib.rs:15:1
   |
15 | / fn ice_fn() {
16 | |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
17 | | }
   | |_^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: broken MIR in DefId(0:8 ~ icetest[e2da]::ice_fn[0]) ("return type"): bad type [type error]
  --> src\lib.rs:15:1
   |
15 | / fn ice_fn() {
16 | |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
17 | | }
   | |_^
   |
   = note: delayed at src\librustc_mir\borrow_check\type_check\mod.rs:258:27

error: internal compiler error: broken MIR in DefId(0:8 ~ icetest[e2da]::ice_fn[0]) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: src\lib.rs:15:1: 17:2 (#0), scope: scope[0] } }): bad type [type error]
  --> src\lib.rs:15:1
   |
15 | / fn ice_fn() {
16 | |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
17 | | }
   | |_^
   |
   = note: delayed at src\librustc_mir\borrow_check\type_check\mod.rs:258:27

error: internal compiler error: mir_const_qualif: MIR had errors
  --> src\lib.rs:16:29
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |                                ^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: PromoteTemps: MIR had errors
  --> src\lib.rs:16:29
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |                                ^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: broken MIR in DefId(0:9 ~ icetest[e2da]::ice_fn[0]::{{constant}}[0]) ("return type"): bad type [type error]
  --> src\lib.rs:16:29
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |                                ^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at src\librustc_mir\borrow_check\type_check\mod.rs:258:27

error: internal compiler error: broken MIR in DefId(0:9 ~ icetest[e2da]::ice_fn[0]::{{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\lib.rs:16:29: 16:47 (#0), scope: scope[0] } }): bad type [type error]     
  --> src\lib.rs:16:29
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |                                ^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at src\librustc_mir\borrow_check\type_check\mod.rs:258:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src\librustc_errors\lib.rs:367:17
note: run with `RUST_BACKTRACE=1` environment variable to display a 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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.46.0-nightly (daecab3a7 2020-07-10) running on x86_64-pc-windows-msvc

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

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

error: could not compile `icetest`.

To learn more, run the command again with --verbose.
Backtrace

error: internal compiler error: unexpected const parent path Expr(Expr { hir_id: HirId { owner: DefId(0:8 ~ icetest[e2da]::ice_fn[0]), local_id: 10 }, kind: Path(TypeRelative(Ty { hir_id: HirId { owner: DefId(0:8 ~ icetest[e2da]::ice_fn[0]), local_id: 2 }, kind: Path(Resolved(None, Path { span: src\lib.rs:16:2: 16:48 (#0), res: 
Def(Struct, DefId(0:3 ~ icetest[e2da]::IceStruct[0])), segments: [PathSegment { ident: IceStruct#0, hir_id: Some(HirId { owner: DefId(0:8 ~ icetest[e2da]::ice_fn[0]), local_id: 1 }), res: Some(Err), args: None, infer_args: true }] })), span: src\lib.rs:16:2: 16:48 (#0) }, PathSegment { ident: ice_struct_fn#0, hir_id: Some(HirId 
{ owner: DefId(0:8 ~ icetest[e2da]::ice_fn[0]), local_id: 9 }), res: Some(Err), args: Some(GenericArgs { args: [Const(ConstArg { value: AnonConst { hir_id: HirId { owner: DefId(0:8 ~ icetest[e2da]::ice_fn[0]), local_id: 3 }, body: BodyId { hir_id: HirId { owner: DefId(0:8 ~ icetest[e2da]::ice_fn[0]), local_id: 8 } } }, span: src\lib.rs:16:29: 16:47 (#0) })], bindings: [], parenthesized: false }), infer_args: false })), attrs: ThinVec(None), span: src\lib.rs:16:2: 16:48 (#0) })
  |
  = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: cat_expr Errd
  --> src\lib.rs:16:29
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |                                ^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: `ErrorReported` without an error
  --> src\lib.rs:16:29
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |                                ^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: cat_expr Errd
  --> src\lib.rs:15:13
   |
15 |   fn ice_fn() {
   |  _____________^
16 | |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
17 | | }
   | |_^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: cat_expr Errd
  --> src\lib.rs:16:2
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: PromoteTemps: MIR had errors
  --> src\lib.rs:15:1
   |
15 | / fn ice_fn() {
16 | |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
17 | | }
   | |_^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: broken MIR in DefId(0:8 ~ icetest[e2da]::ice_fn[0]) ("return type"): bad type [type error]
  --> src\lib.rs:15:1
   |
15 | / fn ice_fn() {
16 | |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
17 | | }
   | |_^
   |
   = note: delayed at src\librustc_mir\borrow_check\type_check\mod.rs:258:27

error: internal compiler error: broken MIR in DefId(0:8 ~ icetest[e2da]::ice_fn[0]) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: src\lib.rs:15:1: 17:2 (#0), scope: scope[0] } }): bad type [type error]
  --> src\lib.rs:15:1
   |
15 | / fn ice_fn() {
16 | |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
17 | | }
   | |_^
   |
   = note: delayed at src\librustc_mir\borrow_check\type_check\mod.rs:258:27

error: internal compiler error: mir_const_qualif: MIR had errors
  --> src\lib.rs:16:29
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |                                ^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: PromoteTemps: MIR had errors
  --> src\lib.rs:16:29
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |                                ^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at /rustc/daecab3a784f28082df90cebb204998051f3557d\src\librustc_session\session.rs:436:27

error: internal compiler error: broken MIR in DefId(0:9 ~ icetest[e2da]::ice_fn[0]::{{constant}}[0]) ("return type"): bad type [type error]
  --> src\lib.rs:16:29
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |                                ^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at src\librustc_mir\borrow_check\type_check\mod.rs:258:27

error: internal compiler error: broken MIR in DefId(0:9 ~ icetest[e2da]::ice_fn[0]::{{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\lib.rs:16:29: 16:47 (#0), scope: scope[0] } }): bad type [type error]     
  --> src\lib.rs:16:29
   |
16 |     IceStruct::ice_struct_fn::<{IceEnum::Variant}>();
   |                                ^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at src\librustc_mir\borrow_check\type_check\mod.rs:258:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src\librustc_errors\lib.rs:367:17
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: <std::io::IoSliceMut as core::fmt::Debug>::fmt
   3: std::panicking::take_hook
   4: std::panicking::take_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: <rustc_errors::styled_buffer::StyledBuffer as core::fmt::Debug>::fmt
   8: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   9: <rustc_driver::DEFAULT_HOOK as core::ops::deref::Deref>::deref
  10: <rustc_driver::DEFAULT_HOOK as core::ops::deref::Deref>::deref
  11: <rustc_span::def_id::CrateNum as rustc_middle::ty::query::keys::Key>::default_span
  12: <rustc_expand::config::StripUnconfigured as rustc_ast::mut_visit::MutVisitor>::visit_mac
  13: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  14: <rustc_driver::DEFAULT_HOOK as core::ops::deref::Deref>::deref
  15: <rustc_driver::DEFAULT_HOOK as core::ops::deref::Deref>::deref
  16: <rustc_span::def_id::CrateNum as rustc_middle::ty::query::keys::Key>::default_span
  17: std::sys::windows::thread::Thread::new
  18: BaseThreadInitThunk
  19: RtlUserThreadStart
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.46.0-nightly (daecab3a7 2020-07-10) running on x86_64-pc-windows-msvc

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

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

query stack during panic:
end of query stack
error: could not compile `icetest`.

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-const_generics`#![feature(const_generics)]`I-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.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions