You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pubtraitMax{constMAX:usize;}pubstructSomething();implMaxforSomething{constMAX:usize = 10;}structData<M:Max>{storage:[u8; <MasMax>::MAX],// alternatively you could define `storage` as the following and a similar error will result.// storage: [u8; M::MAX],_marker: std::marker::PhantomData<M>,}fnmain(){println!("{}", std::mem::size_of::<Data<Something>>());}
I expected to see this happen: it compile and the size of the type to be 10.
Instead, this happened: it did not compile and it reported the following confusing/wrong error message:
error[E0277]: the trait bound `M: Max` is not satisfied
--> src/main.rs:12:19
|
2 | const MAX: usize;
| ----------------- required by `Max::MAX`
...
12 | storage: [u8; <M as Max>::MAX],
| ^^^^^^^^^^^^^^^ the trait `Max` is not implemented for `M`
|
help: consider further restricting this bound
|
11 | struct Data<M: Max + Max> {
| ^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
It asks for the trait bound that is currently present to be added (and adding it produces the same error again).
Meta
I checked this on the playground and it happens on:
I tried this code (playground):
I expected to see this happen: it compile and the size of the type to be 10.
Instead, this happened: it did not compile and it reported the following confusing/wrong error message:
It asks for the trait bound that is currently present to be added (and adding it produces the same error again).
Meta
I checked this on the playground and it happens on:
stable
(1.46.0)beta
(1.47.0-beta.5 2020-09-29 9f0e6fa...)nightly
(1.48.0-nightly 2020-09-28 fc2daaa...)stable
andnightly
also produced the same error on my personal computer.rustc --version --verbose
:The text was updated successfully, but these errors were encountered: