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

Allow unsafe statements #12261

Closed
lexs opened this issue Feb 14, 2014 · 3 comments
Closed

Allow unsafe statements #12261

lexs opened this issue Feb 14, 2014 · 3 comments

Comments

@lexs
Copy link

lexs commented Feb 14, 2014

When writing a lot of unsafe code you often find yourself having to make just some parts of your functions unsafe, however the requirement to use unsafe blocks often makes it nicer to just wrap the function body in unsafe {}.

I want to propose allowing bracketless unsafe for making a single expression unsafe, for example retrieving a global variable require code like this:

let a = unsafe { global.get() };

This could be rewritten to:

let a = unsafe global.get();

It also becomes usefule when matching on globals:

match unsafe { global } {
    ...
}
// vs
match unsafe global {
    ...
}
@reem
Copy link
Contributor

reem commented Sep 3, 2014

Triage. @lexs If you really want this feature you can write up an RFC and get further community feedback.

@thestinger
Copy link
Contributor

A formal RFC is required for a language change like this to move forwards.

@thestinger
Copy link
Contributor

flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 26, 2024
Don't lint `incompatible_msrv` in test code

fixes rust-lang#12257

changelog: `incompatible_msrv`: Don't lint in test code
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