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

Tracking issue for #[ffi_const] #58328

Open
gnzlbg opened this issue Feb 9, 2019 · 2 comments
Open

Tracking issue for #[ffi_const] #58328

gnzlbg opened this issue Feb 9, 2019 · 2 comments
Labels
A-FFI Area: Foreign function interface (FFI) B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC S-tracking-needs-summary Status: It's hard to tell what's been done and what hasn't! Someone should do some investigation. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-opsem Relevant to the opsem team

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 9, 2019

Annotates an extern C function with C const attribute.

https://doc.rust-lang.org/beta/unstable-book/language-features/ffi-const.html

@jonas-schievink jonas-schievink added B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC labels Feb 9, 2019
@nagisa
Copy link
Member

nagisa commented Feb 9, 2019

This corresponds to the LLVM readnone attribute.

@Centril Centril added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Feb 11, 2019
@jonas-schievink jonas-schievink added the A-FFI Area: Foreign function interface (FFI) label Aug 5, 2020
@joshtriplett joshtriplett added the S-tracking-needs-summary Status: It's hard to tell what's been done and what hasn't! Someone should do some investigation. label Jun 15, 2022
@joshtriplett
Copy link
Member

Is this fully implemented and ready for potential stabilization, or is there any blocker?

bors added a commit to rust-lang-ci/rust that referenced this issue Feb 1, 2023
…twco

Strengthen validation of FFI attributes

Previously, `codegen_attrs` validated the attributes `#[ffi_pure]`, `#[ffi_const]`, and `#[ffi_returns_twice]` to make sure that they were only used on foreign functions. However, this validation was insufficient in two ways:

1. `codegen_attrs` only sees items for which code must be generated, so it was unable to raise errors when the attribute was incorrectly applied to macros and the like.
2. the validation code only checked that the item with the attr was foreign, but not that it was a foreign function, allowing these attributes to be applied to foreign statics as well.

This PR moves the validation to `check_attr`, which sees all items. It additionally changes the validation to ensure that the attribute's target is `Target::ForeignFunction`, only allowing the attributes on foreign functions and not foreign statics. Because these attributes are unstable, there is no risk for backwards compatibility. The changes also ending up making the code much easier to read.

This PR is best reviewed commit by commit. Additionally, I was considering moving the tests to the `attribute` subdirectory, to get them out of the general UI directory. I could do that as part of this PR or a follow-up, as the reviewer prefers.

CC: rust-lang#58328, rust-lang#58329
@workingjubilee workingjubilee added the T-opsem Relevant to the opsem team label May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-FFI Area: Foreign function interface (FFI) B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC S-tracking-needs-summary Status: It's hard to tell what's been done and what hasn't! Someone should do some investigation. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-opsem Relevant to the opsem team
Projects
None yet
Development

No branches or pull requests

6 participants