-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Lint for the reserved ABI of bool #46176
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
I don't neccessarily endorse this PR myself. If the apparent inconsistency gets fixed by having |
The ABI of bool is reserved, see these links: * rust-lang/rfcs#954 (comment) * rust-lang#46156 (comment) * rust-lang/rfcs#992 Currently the improper_ctypes lint is inconsistent with that position by treating bools as if they had a specified ABI. To fix this inconsistency, this changes treatment of bools by the lint. This might break some code, so possibly it has to be phased in slowly...
As someone who has (successfully, AFAICT, on multiple platforms—the ones Firefox 56+ runs on) used |
Nominating for discussion in the @rust-lang/compiler team meeting. |
To elaborate: Not having a type that is equivalent to As for Rust As for weird embedded C compilers having weird |
New lints require an RFC. This kind of blurs the line. |
This is more a bugfix than a new lint addition or something like that ("feature change" etc). Unless I understood it wrongly, the purpose of the |
When |
It is established practice that something can be broken if it only works due to a bug. See this search. And the current behaviour is clearly a bug: the ABI of bool is not specified yet, even though the lint assumes that it is specified. Probably this change has to be phased in slowly, as the other breaking changes, I'll change my PR if the compiler team has deemed that they want to do the change. |
What you are saying is that this is not credible as a soundness bug fix, even of a lint. I understand the not credible part. On the other hand, ffi is unsafe code zone and there are many details the compiler can not check for you there. It should only be good if we get better at this approximate and pragmatic safety work of warning about portability and safety issues in code outside of safe rust. |
There's a big difference between a theoretical break to fix a soundness bug and withdrawing a practically working behavior that's in use in deployed code over a theoretical concern. As for FFI being unsafe, the use of a particular type in a signature is not the kind of unsafe that the compiler couldn't have checked, so I don't think FFI being unsafe makes it OK to make a breaking change. Withdrawing a working feature because it was not specified officially seems like the C approach of blaming the programmer for relying on what wasn't specified as reliable and not like Rust's stability story. |
As for it being just a lint: Either the lint is the first step towards breaking it, in which case it's not just a lint, or the existing stable behavior is going to continue to work in which case the lint would uselessly bother programmers on mainstream platforms. A lint that warns all programmers that their FFI code might not link with C code produced on some niche platform that Rust doesn't support yet would be a gross misbalancing of presently relevant mainstream needs vs. potential future niche concerns. |
@hsivonen this PR is only enacting the existing policy on this issue, which is that bool has an unspecified ABI. I think you should better talk to the lang team to get the policy specified. This would be the best outcome, and then this PR can be closed. |
What's the right place to discuss the policy? |
I posted to the internals forum. |
@hsivonen thanks for the post! |
This is being discussed in the internals thread and needs more research. |
Team member @withoutboats has proposed to close this. The next step is review by the rest of the tagged teams:
No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Why that way around and not the alternative? (Specify how bool currently behaves, and document that this matches _Bool on all platforms we support) |
People could come to the conclusion that they need a |
@withoutboats do I understand you correctly that this "close" FCP also functions as a "merge" FCP for #46156 ? |
I think we should merge that PR and also somewhere (the reference?) clarify precisely that it has the same representation as |
@withoutboats agreed; I was going to propose the same. @cuviper thanks, just what I wanted to know |
friendly ping @jseyfried , your mark is missing. |
I took the libery of tagging for @jseyfried |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Closing in favour of #46156 |
Just to answer a few years later: It's more of a detail of C++'s |
The ABI of bool is reserved, see these links:
bool
is compatible with the_Bool
C type. rfcs#954 (comment)Currently the improper_ctypes lint is inconsistent
with that position by treating bools as if they had
a specified ABI.
To fix this inconsistency, this changes treatment of
bools by the lint.
This might break some code, so possibly it has to
be phased in slowly...