Skip to content
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

Show a better error on wrong struct size #62

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hecatia-elegua
Copy link
Owner

Should be tested on a free standing project with both stable and nightly, since in-project I sometimes just saw "evaluation of constant value failed", which is not that helpful.

@pickx
Copy link
Collaborator

pickx commented Jul 23, 2023

nice. I love that the location of the error ends up being the bitsize attribute, which shows the number, that's very cool.

@hecatia-elegua
Copy link
Owner Author

image
image

????
now it's apparently a note

@pickx
Copy link
Collaborator

pickx commented Jul 24, 2023

???? now it's apparently a note

seeing the same thing here. I guess the location does not end up being the attribute.strange that when consts are used in this position, they generate "erroneous constant" info instead of an error.

@hecatia-elegua
Copy link
Owner Author

/// This is used in `bitsize.rs` gen, for showing a compile error.
/// Only needed because const contexts can't use `format!` and `COMPUTED_SIZE` is not a plain number.
/// `evaluation of `bilge::AssertEquals::<19, 18>::EQUAL` failed` will tell you what's wrong.
pub struct AssertEquals<const COMPUTED_SIZE: usize, const DECLARED_SIZE: usize>;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider #[doc(hidden)] :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants