Skip to content

[ICE] with const generics in subst.rs #71922

Closed
@leonardo-m

Description

@leonardo-m

This is wrong code because it lacks the const_generics feature request, and because currently calling a const function in this context isn't allowed:

const fn foo(n: usize) -> usize { n * 2 }
fn bar<const N: usize>() -> [u32; foo(N)] {
    [0; foo(N)]
}
fn main() {}

Gives:

error[E0658]: const generics are unstable
 --> ...\test.rs:2:14
  |
2 | fn bar<const N: usize>() -> [u32; foo(N)] {
  |              ^
  |
  = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
  = help: add `#![feature(const_generics)]` to the crate attributes to enable

error: internal compiler error: src\librustc_middle\ty\subst.rs:581: const parameter `N/#0` (Const { ty: usize, val: Param(N/#0) }/0) out of range when substituting substs=[]

thread 'rustc' panicked at 'Box<Any>', /rustc/2454a68cfbb63aa7b8e09fe05114d5f98b2f9740\src\libstd\macros.rs:13:23
stack backtrace:
  ...

note: rustc 1.45.0-nightly (2454a68cf 2020-05-04) running on x86_64-pc-windows-gnu

query stack during panic:
#0 [const_eval_raw] const-evaluating `bar::{{constant}}#0`
#1 [const_eval_validated] const-evaluating + checking `bar::{{constant}}#0`
#2 [const_eval_validated] const-evaluating + checking `bar::{{constant}}#0`
#3 [check_item_well_formed] processing `bar`
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

Activity

added
C-bugCategory: This is a bug.
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.
on May 5, 2020
added
A-const-genericsArea: const generics (parameters and arguments)
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)
on May 5, 2020
lcnr

lcnr commented on May 5, 2020

@lcnr
Contributor

blocked on lazy normalization #67890.

Probably a duplicate of #69913

added 2 commits that reference this issue on May 18, 2020

Rollup merge of rust-lang#71973 - lcnr:lazy-norm, r=nikomatsakis

9f59db5

Rollup merge of rust-lang#71973 - lcnr:lazy-norm, r=nikomatsakis

c6030c9
lcnr

lcnr commented on Jun 30, 2020

@lcnr
Contributor

This issue still isn't fixed 🤔 It seems like I made a mistake in #71973

reopened this on Jun 30, 2020

16 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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.fixed-by-const-genericsEnabling feature `const_generics` fixes the issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @jonas-schievink@varkor@leonardo-m@JohnTitor@lcnr

      Issue actions

        [ICE] with const generics in subst.rs · Issue #71922 · rust-lang/rust