Closed
Description
I tried this code:
pub trait Const {
const C: u8;
}
impl Const for u8 {
const C: u8 = 3;
}
pub struct Wrapper<T>(T);
impl<T: Const> Const for Wrapper<T> {
const C: u8 = T::C;
}
const fn foo<T>() -> u8
where
Wrapper<T>: Const,
{
<Wrapper<T>>::C
}
fn main(){
const D: u8 = foo::<u8>();
dbg!(D);
}
I expected to see this code not compile, because it bounds types by non-auto traits in const fn
s.
Instead, this happened: The code compiles without errors, and prints 3
This does error with T: Const
bounds as expected.
Meta
rustc --version --verbose
:
rustc 1.53.0-nightly (673d0db5e 2021-03-23)
binary: rustc
commit-hash: 673d0db5e393e9c64897005b470bfeb6d5aec61b
commit-date: 2021-03-23
host: i686-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0