Skip to content

extern functions can't be declared unsafe #2952

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
jdm opened this issue Jul 18, 2012 · 5 comments
Closed

extern functions can't be declared unsafe #2952

jdm opened this issue Jul 18, 2012 · 5 comments

Comments

@jdm
Copy link
Contributor

jdm commented Jul 18, 2012

unsafe extern fn foo() {}

/Users/jdm/src/servo/src/servo/dom/bindings/document.rs:124:7: 124:13 error: expecting fn, found extern

extern unsafe fn foo() {}

/Users/jdm/src/servo/src/servo/dom/bindings/document.rs:124:7: 124:13 error: expecting mod, found unsafe

extern fn unsafe foo() {}

/Users/jdm/src/servo/src/servo/dom/bindings/document.rs:124:10: 124:16 error: found unsafe in restricted position

@bblum
Copy link
Contributor

bblum commented Jul 18, 2012

I don't think this is a problem - making a function unsafe means what whoever calls it must surround it with an unsafe block or be unsafe themself, but extern functions are never called, only passed.

Try extern fn foo { unsafe { } }

@jdm
Copy link
Contributor Author

jdm commented Jul 18, 2012

I use the unsafe marker as a way to reduce the visual complexity of a function in which there are a number of unsafe blocks, or the whole body of the function belongs in an unsafe block.

@bblum
Copy link
Contributor

bblum commented Jul 18, 2012

You can also write extern fn foo() unsafe { ... }.

@jdm
Copy link
Contributor Author

jdm commented Jul 18, 2012

Curses, the one permutation I did not try.

@bblum
Copy link
Contributor

bblum commented Jul 18, 2012

It's equivalent to the one I said above, just with fewer braces.

@bblum bblum closed this as completed Jul 18, 2012
RalfJung pushed a commit to RalfJung/rust that referenced this issue Jul 8, 2023
cronjob auto-PR: try to fix setting the remote branch
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
The "CBMC latest" workflow is composed of two jobs (`regression` and
`perf`) which perform testing with the most recent development version
of CBMC. At present, the `regression` jobs are not actually testing with
the CBMC that we build from source, but the CBMC installed through the
setup scripts, as revealed in rust-lang#2954.

This PR changes the `regression` jobs so that they use `cmake` to build.
This allows the runner to pick up the recently-built CBMC development
version instead of the one installed through setup scripts, as it's done
in the `perf` jobs. Unfortunately, [this CI
run](https://github.com/adpaco-aws/rmc/actions/runs/7390380572) doesn't
demonstrate the fix as it should due to an unrelated breaking change in
the latest CBMC version. However, rust-lang#2952 provides more context in case
you need it.
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