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

assert_once_ever!() macro #7748

Closed
bblum opened this issue Jul 12, 2013 · 1 comment
Closed

assert_once_ever!() macro #7748

bblum opened this issue Jul 12, 2013 · 1 comment
Labels
A-concurrency Area: Concurrency A-syntaxext Area: Syntax extensions E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@bblum
Copy link
Contributor

bblum commented Jul 12, 2013

Some places in the task code are commented with "only one task should ever do this". Now that we have unsafe global variables, we can implement a safe convenience macro that can assert this at runtime instead of at comment-time.

It should expand to something like:

unsafe {
    static mut __gensymed__thing_already_happened: bool = false;
    // "double-check locking" to avoid doing an xchg all the time
    if __gensymed__thing_already_happened == false {
        if atomic_xchg(&mut __gensymed__thing_already_happened, true, Relaxed) == true {
            fail!($provided_message);
        }
    }
}
@bblum
Copy link
Contributor Author

bblum commented Aug 8, 2013

I got dis.

@bblum bblum closed this as completed in dd40636 Aug 23, 2013
@bblum bblum removed their assignment Jun 16, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 21, 2021
…=flip1995

Add undocumented_unsafe_blocks lint

changelog: Added a new lint [`undocumented_unsafe_blocks`]

Fixes rust-lang#7464, rust-lang#7238 (?)
flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 30, 2021
Fix `SAFETY` comment tag casing in undocumented_unsafe_blocks

This changes the lint introduced in rust-lang#7748 to suggest adding a `SAFETY` comment instead of a `Safety` comment.

Searching for `// Safety:` in rust-lang/rust yields 67 results while `// SAFETY:` yields 1072.
I think it's safe to say that this comment tag is written in upper case, just like `TODO`, `FIXME` and so on are. As such I would expect this lint to follow the official convention as well.

Note that I intentionally introduced some casing diversity in `tests/ui/undocumented_unsafe_blocks.rs` to test more cases than just `Safety:`.

changelog: Capitalize `SAFETY` comment in [`undocumented_unsafe_blocks`]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-concurrency Area: Concurrency A-syntaxext Area: Syntax extensions 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

1 participant