Skip to content

rust: implement static_assert! in a more idiomatic way #778

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

Merged
merged 2 commits into from
May 25, 2022
Merged

Conversation

alex
Copy link
Member

@alex alex commented May 25, 2022

Signed-off-by: Alex Gaynor [email protected]

@alex
Copy link
Member Author

alex commented May 25, 2022

Hmmm, the doctest code relies on overriding assert! with an assertion that's not usable in const contexts.

I don't see an obvious way to work around this, but it also seems unfortunate to be stuck with this kludgy implementation of static_assert! for forever.

Copy link
Member

@bjorn3 bjorn3 left a comment

Choose a reason for hiding this comment

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

Now that assert!() is supported in const contexts that is definitively much clearer!

@bjorn3
Copy link
Member

bjorn3 commented May 25, 2022

Hmmm, the doctest code relies on overriding assert! with an assertion that's not usable in const contexts.

You could refer to core::panic!() rather than panic!() I think.

@nbdd0121
Copy link
Member

core::assert! will generate fully qualified use of panic!, so core::assert! should be sufficient.

@ojeda
Copy link
Member

ojeda commented May 25, 2022

Much better, thanks all!

@ojeda ojeda merged commit d3ddae3 into rust May 25, 2022
@ojeda ojeda deleted the alex-patch-1 branch May 25, 2022 17:15
@nbdd0121
Copy link
Member

The commits are not signed off.

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

Successfully merging this pull request may close these issues.

4 participants