Repository navigation
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.fixed-by-const-genericsEnabling feature `const_generics` fixes the issue.Enabling feature `const_generics` fixes the issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
Description
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
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.fixed-by-const-genericsEnabling feature `const_generics` fixes the issue.Enabling feature `const_generics` fixes the issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
Activity
lcnr commentedon May 5, 2020
blocked on lazy normalization #67890.
Probably a duplicate of #69913
Rollup merge of rust-lang#71973 - lcnr:lazy-norm, r=nikomatsakis
Rollup merge of rust-lang#71973 - lcnr:lazy-norm, r=nikomatsakis
lcnr commentedon Jun 30, 2020
This issue still isn't fixed 🤔 It seems like I made a mistake in #71973
Rollup merge of rust-lang#73898 - lcnr:issue61383, r=jonas-schievink
Rollup merge of rust-lang#73898 - lcnr:issue61383, r=jonas-schievink
Rollup merge of rust-lang#73898 - lcnr:issue61383, r=jonas-schievink
Rollup merge of rust-lang#73898 - lcnr:issue61383, r=jonas-schievink
Rollup merge of rust-lang#73898 - lcnr:issue61383, r=jonas-schievink
Rollup merge of rust-lang#77439 - varkor:min_const_generics-tests, r=…
JohnTitor commentedon Dec 30, 2020
Triage: This is no longer ICE (even with
const_generics) on the latest nightly: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=f0afc6e029354b7b4e933cb00c9b0cbalcnr commentedon Dec 30, 2020
we already have a bunch of similar tests, closing without adding an additional one