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

RFC: Disallow 'unsafe' keyword when opening a function body #2515

Closed
brson opened this issue Jun 6, 2012 · 8 comments
Closed

RFC: Disallow 'unsafe' keyword when opening a function body #2515

brson opened this issue Jun 6, 2012 · 8 comments
Labels
A-grammar Area: The grammar of Rust E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@brson
Copy link
Contributor

brson commented Jun 6, 2012

fn is_this() unsafe { }

It's an abomination!

@brson
Copy link
Contributor Author

brson commented Jun 6, 2012

unchecked and anything else that can sneak in there as well.

@catamorphism
Copy link
Contributor

Why? I can easily imagine writing a function whose entire body is unsafe...

@brson
Copy link
Contributor Author

brson commented Jun 6, 2012

It is useful and even a bit satisfying but unsafe fn foo() and fn foo() unsafe look very similar and act very different. It has caused confusion.

@pcwalton
Copy link
Contributor

pcwalton commented Jun 6, 2012

Marking as RFC.

I agree with this, and I'd even prefer bringing back, say, the auth keyword in front of unsafe blocks, since unsafe blocks and unsafe effects are very different.

@eholk
Copy link
Contributor

eholk commented Jun 6, 2012

Huh, I don't think I know the difference between these two...

@graydon
Copy link
Contributor

graydon commented Jun 6, 2012

I agree that it's currently the source of confusion and should go. Not sure what to do about unsafe blocks vs. auth keyword. I think it might make sense to look at Niko's proposal for fixing effect propagation through closures and changing the default fn item effect back to pure, with an impure keyword that works both as item qualifier and block qualifier. With or without auth as a prefix (or some other prefix). But I think that's a longer chain of bugs.

@brson
Copy link
Contributor Author

brson commented Jun 25, 2012

I converted core to not use this pattern, then started on std. The uv code has many large functions that are entirely unsafe and, under the new scheme, have 8-space indentation. Encountering that made me less enthusiastic about this change.

@pcwalton
Copy link
Contributor

pcwalton commented Jul 3, 2012

Closing this for now. Feel free to open a new bug about changing the keyword.

@pcwalton pcwalton closed this as completed Jul 3, 2012
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
dont rerun build script unnecessarily
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-grammar Area: The grammar of Rust E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

5 participants