generic_const_exprs and a (non const generic) array size expression allow recursive generic type parameters #108725
Labels
C-bug
Category: This is a bug.
F-generic_const_exprs
`#![feature(generic_const_exprs)]`
requires-incomplete-features
This issue requires the use of incomplete features.
requires-nightly
This issue requires a nightly compiler in some way.
The following does compile (surprisingly - as opposed to #53191):
However, the same code (without comments), and with the only change being in the array size changed from a (const) expression
0*0
to a literal0
, then fails to compile:The problem reported here is not whether this should compile or not. Rather, it's the inconsistency depending on the array size's being an expression vs. literal.
But while you're at it, please also shed some light on the the intended behavior, or planned behavior.
Side note: Putting the array size within braces makes it compile, too:
Motivation: This took hours to pinpoint/minimize (while I was hoping to minimize another issue, so that I can progress with co-allocation in library/alloc). So I hope this will save people's time.
Update: The above minimization is not fully narrowed down - beyond my current bandwidth. Under some circumstances, recursive types with a generic parameter that is used solely for recursion (that is, not in any
PhantomData
-based field) do compile even withoutgeneric_const_exprs
. SeeLeafNode
andInternalNode
in BTreeMap's internals: it compiles, even thoughlibrary/alloc/src/lib.rs
does not usegeneric_const_exprs
. (NodeRef
itself does usePhantomData
, but the (indirectly) recursive typesLeafNode
andInternalNode
themselves do not.)However, that doesn't affect the inconsistency reported in this ticket.
The text was updated successfully, but these errors were encountered: