Closed
Description
Based on the example in #90455, which after the changes in #90529 would output an unconstrained generic constant
error. The following code, however, does not output such an error, although I believe it should.
Given the following code:
#![feature(generic_const_exprs, adt_const_params)]
const fn num_limbs(_: &str) -> usize {
5
}
fn foo<const N: &'static str>(_arr: [u64; num_limbs(N)]) where [u64; num_limbs(N)]: {}
fn main() {
let arr = [5; 5];
foo(arr);
}
The current output is:
error[E0284]: type annotations needed: cannot satisfy `the constant `foo::<{_: &'static str}>::{constant#0}` can be evaluated`
--> test2.rs:17:3
|
17 | foo(arr);
| ^^^ cannot satisfy `the constant `foo::<{_: &'static str}>::{constant#0}` can be evaluated`
|
note: required by a bound in `foo`
--> test2.rs:13:70
|
13 | fn foo<const N: &'static str>(_arr: [u64; num_limbs(N)]) where [u64; num_limbs(N)]: {}
| ^^^^^^^^^^^^ required by this bound in `foo`
error: aborting due to previous error; 2 warnings emitted
This only happens if the adt_const_params
is included. This also compiles if you don't include the call of foo
in main.
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Area: Messages for errors, warnings, and lintsCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.`#![feature(generic_const_exprs)]`Relevant to the compiler team, which will review and decide on the PR/issue.