Skip to content

Unsafe blocks make their contents pure? #1210

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

Closed
brson opened this issue Nov 22, 2011 · 2 comments
Closed

Unsafe blocks make their contents pure? #1210

brson opened this issue Nov 22, 2011 · 2 comments

Comments

@brson
Copy link
Contributor

brson commented Nov 22, 2011

This came from a pull request recently:

pure fn ln(n: float) -> float { unsafe { libc::ln(n) } }

I would expect that 'unsafe' block to be an 'unchecked' block.

@nikomatsakis
Copy link
Contributor

purity and unsafety are not orthogonal. At first I thought they ought to be but it made a lot of things harder and I couldn't think of a good reason to support it. So functions are either normal, pure, or unsafe. As a side effect, an unsafe block is like an unchecked block but stronger. I am not sure this is how it should be, but it's not an accident per se.

@brson
Copy link
Contributor Author

brson commented Nov 24, 2011

Yes, I remember that decision now. Closing.

@brson brson closed this as completed Nov 24, 2011
bors pushed a commit to rust-lang-ci/rust that referenced this issue Dec 20, 2021

Unverified

This user has not yet uploaded their public signing key.
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
* Add "fixme" testcase for rust-lang#1208

I also added an override for the `unreachable!()` macro to print nicer
error message.

* Document override + test
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

No branches or pull requests

2 participants