Skip to content

Doc: "unsafe turns off safety checks" is misleading #14489

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
SimonSapin opened this issue May 28, 2014 · 3 comments
Closed

Doc: "unsafe turns off safety checks" is misleading #14489

SimonSapin opened this issue May 28, 2014 · 3 comments

Comments

@SimonSapin
Copy link
Contributor

http://doc.rust-lang.org/intro.html#a-footnote:-unsafe currently says:

Within an unsafe block, Rust turns off many of its safety checks.

This is misleading and should not be in the documentation. For example, unsafe {} does not let you use a moved value. Instead, it lets you use features (such as raw pointers and transmute) that are otherwise forbidden.

@steveklabnik
Copy link
Member

I agree we should be more clear that only a few restrictions are technically lifted, it's not like you drop straight into assembly or something in unsafe blocks.

@thestinger
Copy link
Contributor

you only have to audit what you've done inside unsafe, and not the entire program itself.

This isn't true. You have to audit all code inside unsafe and all safe code trusted by unsafe code. For example, unsafe blocks in Vec<T> methods implicitly trust all safe code in the module (since it can modify the fields incorrectly) along with all safe code they call directly. The existence of a clear safety boundary in Rust is overstated.

@steveklabnik
Copy link
Member

This language has been removed with the merger of #16641

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

3 participants