anonymous constants are overly restrictive wrt variance #90629
Labels
A-const-generics
Area: const generics (parameters and arguments)
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)]`
cc #89829 (comment)
this currently causes an error as
'a
is considered invariant because it is used in an anonymous constant.This shouldn't actually be needed for
std::mem::size_of
as it doesn't care about variance.Once stuff like the following causes an error (instead of a future imcompat lint, cc #56105), subtyping should not be able to influence const eval, so we could allow lifetimes used in constants to remain bivariant. It is not clear that we should do that, as this restriction on subtyping is definitely not obvious or even necessarily desirable.
The text was updated successfully, but these errors were encountered: