-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsI-cycleIssue: A query cycle occurred while none was expectedIssue: A query cycle occurred while none was expectedT-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.
Description
Code
fn foo<const N: usize, const K: usize>(_data: [u32; N]) -> [u8; { foo(N); 5 }] {
[0; K]
}
fn main() {
}
Current output
error: generic parameters may not be used in const operations
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:71
|
3 | ...> [u8; { foo(N); 5 }] {
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0391]: cycle detected when caching mir of `foo::{constant#1}` for CTFE
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
|
note: ...which requires elaborating drops for `foo::{constant#1}`...
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
note: ...which requires borrow-checking `foo::{constant#1}`...
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
note: ...which requires promoting constants in MIR for `foo::{constant#1}`...
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
note: ...which requires const checking `foo::{constant#1}`...
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
note: ...which requires preparing `foo::{constant#1}` for borrow checking...
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
note: ...which requires unsafety-checking `foo::{constant#1}`...
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
note: ...which requires building MIR for `foo::{constant#1}`...
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
note: ...which requires match-checking `foo::{constant#1}`...
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
note: ...which requires type-checking `foo::{constant#1}`...
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
note: ...which requires evaluating type-level constant...
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `foo::{constant#1}`...
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `foo::{constant#1}`...
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
= note: ...which again requires caching mir of `foo::{constant#1}` for CTFE, completing the cycle
note: cycle used when const-evaluating + checking `foo::{constant#1}`
--> F2BA3E4A1C6EA7961BA8BFE1032468BB5A186D391F3B27D22A1638859E663E15.rs:3:65
|
3 | ... -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error: aborting due to 2 previous errors
Desired output
We should have a proper diagnostic here and not talk about CTFE or mir
Rationale and extra context
cc #119321
Other cases
No response
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsI-cycleIssue: A query cycle occurred while none was expectedIssue: A query cycle occurred while none was expectedT-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.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity