Closed
Description
#![feature(const_generics)]
#![feature(const_evaluatable_checked)]
#![allow(incomplete_features)]
trait Foo {}
fn f<T: Foo>() {}
impl<T> Foo for T
where
[(); std::mem::size_of::<T>()]:
{}
Note that the above code compiles without the function f
, so the trait impl itself is valid. Also, obviously, it compiles without
the impl
. Adding an impl
should not be a breaking change like that. While adding a blanket impl is a breaking change, AFAIR it isn’t for sealed traits; and anyways, a similar error occurs when T
is replaced by Struct<T>
, like this.
Errors:
Compiling playground v0.0.1 (/playground)
error: unconstrained generic constant
--> src/lib.rs:7:9
|
7 | fn f<T: Foo>() {}
| ^^^
|
help: try adding a `where` bound using this expression: `where [u8; std::mem::size_of::<T>()]: Sized`
--> src/lib.rs:11:10
|
11 | [(); std::mem::size_of::<T>()]:
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error: could not compile `playground`
To learn more, run the command again with --verbose.
@rustbot modify labels: F-const_evaluatable_checked, T-compiler, C-bug, requires-nightly, F-const_generics
Metadata
Metadata
Assignees
Labels
Area: Constant evaluation, covers all const contexts (static, const fn, ...)Area: const generics (parameters and arguments)Category: This is a bug.`#![feature(const_generics)]``#![feature(generic_const_exprs)]`Relevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.