Skip to content

Show a better error on wrong struct size#62

Open
hecatia-elegua wants to merge 1 commit into
mainfrom
assert-size
Open

Show a better error on wrong struct size#62
hecatia-elegua wants to merge 1 commit into
mainfrom
assert-size

Conversation

@hecatia-elegua
Copy link
Copy Markdown
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
Copy Markdown
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.

@pickx pickx self-requested a review July 23, 2023 15:43
@hecatia-elegua
Copy link
Copy Markdown
Owner Author

image
image

????
now it's apparently a note

@pickx
Copy link
Copy Markdown
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
Copy Markdown
Owner Author

Comment thread src/lib.rs
/// 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
Copy Markdown

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