-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Division by NonZero* checks for zero #76960
Comments
we can make |
I'm preparing a PR for that. |
I can add the assume after that's done. |
Duplicate of #49572 |
RalfJung
added a commit
to RalfJung/rust
that referenced
this issue
Sep 25, 2020
…-obk Unstably allow assume intrinsic in const contexts Not sure much about this usage because there are concerns about [blocking optimization][1] and [slowing down LLVM][2] when using `assme` intrinsic in inline functions. But since Oli suggested in rust-lang#76960 (comment), here we are. [1]: rust-lang#54995 (comment) [2]: rust-lang#49572 (comment)
RalfJung
added a commit
to RalfJung/rust
that referenced
this issue
Sep 25, 2020
…-obk Unstably allow assume intrinsic in const contexts Not sure much about this usage because there are concerns about [blocking optimization][1] and [slowing down LLVM][2] when using `assme` intrinsic in inline functions. But since Oli suggested in rust-lang#76960 (comment), here we are. [1]: rust-lang#54995 (comment) [2]: rust-lang#49572 (comment)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://rust.godbolt.org/z/eTPzE6
Technically, NonZero* types are not meant to be used for optimizing arithmetic, but people (like myself) may or may not know that or may assume otherwise.
It is possible to create a NonZero* object with 0 inner value, but since that is a misuse of the type and deliberate violation of the safety guarantees, I think it would make sense to teach the compiler that
get()
can't return 0.Edit: unfortunately, since NonZero* methods are const, it's not as simple as adding an assume.
The text was updated successfully, but these errors were encountered: