Uh oh!
There was an error while loading. Please reload this page.
Lint for the reserved ABI of bool - #46176
Conversation
rust-highfive
commented
Nov 21, 2017
(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...
hsivonen
commented
Nov 22, 2017
As someone who has (successfully, AFAICT, on multiple platforms—the ones Firefox 56+ runs on) used |
michaelwoerister
commented
Nov 22, 2017
Nominating for discussion in the @rust-lang/compiler team meeting. |
hsivonen
commented
Nov 22, 2017
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. |
est31
commented
Nov 22, 2017
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 |
est31
commented
Nov 24, 2017
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. |
bluss
commented
Nov 24, 2017
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. |
hsivonen
commented
Nov 24, 2017
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. |
est31
commented
Nov 24, 2017
@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. |
hsivonen
commented
Nov 24, 2017
What's the right place to discuss the policy? |
hsivonen
commented
Nov 26, 2017
I posted to the internals forum. |
est31
commented
Nov 27, 2017
@hsivonen thanks for the post! |
arielb1
commented
Nov 30, 2017
This is being discussed in the internals thread and needs more research. |
hanna-kruppe
commented
Jan 22, 2018
Why that way around and not the alternative? (Specify how bool currently behaves, and document that this matches _Bool on all platforms we support) |
withoutboats
commented
Jan 22, 2018
People could come to the conclusion that they need a |
est31
commented
Jan 22, 2018
@withoutboats do I understand you correctly that this "close" FCP also functions as a "merge" FCP for #46156 ? |
withoutboats
commented
Jan 22, 2018
I think we should merge that PR and also somewhere (the reference?) clarify precisely that it has the same representation as |
nikomatsakis
commented
Jan 23, 2018
@withoutboats agreed; I was going to propose the same. @cuviper thanks, just what I wanted to know |
est31
commented
Feb 1, 2018
friendly ping @jseyfried , your mark is missing. |
nikomatsakis
commented
Feb 1, 2018
I took the libery of tagging for @jseyfried |
rfcbot
commented
Feb 1, 2018
🔔 This is now entering its final comment period, as per the review above. 🔔 |
est31
commented
Feb 2, 2018
Closing in favour of #46156 |
luke-jr
commented
Aug 13, 2020
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:
boolis compatible with the_BoolC 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...