enabling const-generics interferes with object safety #87551
Labels
A-const-generics
Area: const generics (parameters and arguments)
C-bug
Category: This is a bug.
F-generic_const_exprs
`#![feature(generic_const_exprs)]`
Summary: Enabling the
const_generics
feature makes an object safe trait with const generics unsafe.The following code compiles successfully as expected (note the angle brackets around 42):
However, when I enable the
const_generics
feature, compilation fails (note the angle brackets around 42):with the error that "
ObjectSafeTrait
cannot be made into an object".Full Error Message
You can also reproduce the behaviour on the playground:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=e083b7b2d1cb62e355201987e6076775
The same error can also be reproduced on stable 1.53.0, though rustc then also complains about the feature, of course.
It is also worth noting that when the angle brackets around 42 are removed, i.e.
TraitWithConstGeneric<42>
, the code compiles both with and without theconst_generics
feature.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: