invariant detection for recursive generic types incorrect with generic_const_exprs #108751
Labels
A-variance
Area: Variance (https://doc.rust-lang.org/nomicon/subtyping.html)
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 fails to compile, incorrectly/inconsistently reporting
ResursiveGenCovariant<T>
as invariant overT
:Error:
However, the following alternatives do compile (in the order respective to the changes listed in the comment above; the middle one fails with both
1.69.0-nightly (44cfafe2f 2023-03-03)
andstable 1.67.1 (d5a82bbd2 2023-02-07)
). Same code as above (without the above comments), with changes marked with new comments:Alternative 1:
Alternative 2:
Alternative 3:
Motivation: Based on indirect recursion between
LeafNode
andInternalNode
in BTreeMap's internals, andassert_covariance()
inlibrary/alloc/src/collections/btree/map/tests.rs
andlibrary/alloc/src/collections/btree/set/tests.rs
. It means that addinggeneric_const_exprs
tolibrary/alloc/src/lib.rs
breaks its compilation.Related to #108725.
The text was updated successfully, but these errors were encountered: