-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Nonsensical error message with const generics and std::mem::sized_of #62645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have run into this issue several times, here's a case I wouldn't even consider const generics, it is a const eval problem in a generic context instead const fn batch_size<T: Sized>() -> usize {
32 / std::mem::size_of::<T>()
}
fn x<T: Sized>() {
[1; batch_size::<T>()];
}
|
This seems to have been fixed on the new nightlies: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=16495147fbcdd34da629b2ee40e6072b |
Cool! Although if I extend your example to actually test the associated type: fn needs_zst<T>(_: T) where T: IsZst<ZST=ZstHelper<{true}>> {} I get some nice errors:
|
The cycle appears to be due to eger normalization when constructing the |
The example in OP now gets the cycle error, but my case still fails with the nonsensical one. |
Isn't this just a duplicate of #43408? (I mean, yeah, that issue is about this not working, while this issue is about the terrible error message; but many of the closed duplicates are also about the error message. The fact that this error message is still here gives me the impression that fixing the message must be as difficult as making it compile!) |
I agree with @ExpHP here, since when those issues are fixed the error message is going to change. Closing this as duplicate. |
The following code:
produces the following error:
despite the fact that we have that
T: Sized
. If there's another reason why this code shouldn't compile, the error message should clearly state it.The text was updated successfully, but these errors were encountered: