You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SmallVec<[T; N]> is invariant over T.
Although [T; N] is covariant over T as expected.
This is due to SmallVec<A> having field of type <A as Array>::Item in underlying union.
I propose to change that field type to A and remove A: Array bound from type declaration.
I just spent a few hours debugging a lifetime compilation error related to this after replacing Vec with SmallVec. It took me a long time to figure out that the error originated in SmallVec. This can be really a tricky issue.
ramosbugs, estaban, jkugelman, jcrevier and tesujimath
Having stumbled upon a lifetime problem caused by this, I found the very new 2.0.0-alpha.1 version, tried it, and found it fixed my problem, so yay! And thanks!
min_const_generics was stabilized 3 years ago: rust-lang/rust#79135, are there any plans to provide a SmallVec<T, N> alternative that has the right variance?
Activity
mbrubeck commentedon Apr 16, 2019
For reference, this is similar to bluss/arrayvec#96, and is caused by rust-lang/rust#21726.
Nadrieril commentedon Nov 28, 2019
The following trick (can't remember where I found it):
fixes the variance issue (playground link).
Would that be possible to use or would it be a breaking change to the API ?
bkolobara commentedon Nov 23, 2020
I just spent a few hours debugging a lifetime compilation error related to this after replacing
Vec
withSmallVec
. It took me a long time to figure out that the error originated in SmallVec. This can be really a tricky issue.mbrubeck commentedon Nov 23, 2020
Fortunately, I expect this issue will be fixed in smallvec 2.0 when we replace the
Array
trait with const generics (#240).That work depends on the
min_const_generics
feature, which the Rust team is planning to ship in early 2021: rust-lang/rust#79135tesujimath commentedon Nov 13, 2023
Having stumbled upon a lifetime problem caused by this, I found the very new
2.0.0-alpha.1
version, tried it, and found it fixed my problem, so yay! And thanks!Nadrieril commentedon Dec 11, 2023
min_const_generics
was stabilized 3 years ago: rust-lang/rust#79135, are there any plans to provide aSmallVec<T, N>
alternative that has the right variance?Nadrieril commentedon Dec 11, 2023
Oh wait, it looks like
master
has that already, I guess it's not finalized yet?QualifiedName
forImported::call_path
astral-sh/ruff#10214refactor: Use `QualifiedName` for `Imported::call_path` (#10214)
refactor: Use `QualifiedName` for `Imported::call_path` (astral-sh#10214