Open
Description
The following code snippet does not show the T::ASSERT
site unless the const_err
lint is allowed or set to warn only.
I'm guessing the error on T::ASSERT
is happening during codegen.
trait ZstAssert: Sized {
const ASSERT: () = [()][(std::mem::size_of::<Self>() != 0) as usize];
}
impl<T> ZstAssert for T {}
fn foo<T>() {
#[allow(path_statements)]
{
T::ASSERT
}
}
fn main() {
foo::<u32>();
}
Errors:
Compiling playground v0.0.1 (/playground)
error: any use of this value will cause an error
--> src/main.rs:2:24
|
2 | const ASSERT: () = [()][(std::mem::size_of::<Self>() != 0) as usize];
| -------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
| |
| index out of bounds: the len is 1 but the index is 1
|
= note: `#[deny(const_err)]` on by default
error: aborting due to previous error
error: could not compile `playground`.
To learn more, run the command again with --verbose.