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

Static asserts #1146

Closed
nikomatsakis opened this Issue Jun 2, 2015 · 3 comments

Comments

Projects
None yet
4 participants
@nikomatsakis
Copy link
Contributor

nikomatsakis commented Jun 2, 2015

It would be useful to be able to specify static expressions which must be evaluated to true or else compilation will fail. This can be particularly useful in checking assumptions that are baked into unsafe code, such as that the size of two structs is equal.

Relevant RFCs:

  • RFC #1096 removed the older #[static_assert] attribute.
@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Oct 7, 2018

The only thing needed to get this working is rust-lang/rust#51999 so I am closing this in favor of that issue.

@Centril Centril closed this Oct 7, 2018

@DoumanAsh

This comment has been minimized.

Copy link

DoumanAsh commented Dec 5, 2018

@Centril Small question because I have use case for static_assert outside of const fn, there is no plan to have static assertion outside of const fn context?

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Dec 5, 2018

@DoumanAsh With #2526 you can define const _ = $expr;. That way, you can statically assert things outside a const fn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.