some fixes for clashing_extern_declarations lint#130301
Merged
bors merged 1 commit intorust-lang:masterfrom Sep 13, 2024
Merged
some fixes for clashing_extern_declarations lint#130301bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
Collaborator
|
rustbot has assigned @petrochenkov. Use |
795ee23 to
e842eec
Compare
RalfJung
commented
Sep 13, 2024
| b_layout, | ||
| a_layout == b_layout | ||
| ); | ||
| Ok(a_layout == b_layout) |
Member
Author
There was a problem hiding this comment.
I ended up removing this logic entirely. It is never sound to do this, and none of the tests relied on this, so the motivation is unclear.
If this warns for too many real-world cases, people will tell us. :)
e842eec to
f362a59
Compare
compiler-errors
approved these changes
Sep 13, 2024
| ) | ||
| } | ||
| (Array(a_ty, a_const), Array(b_ty, b_const)) => { | ||
| // For arrays, we also check the constness of the type. |
Contributor
|
Thanks for fixing this and I agree with the changes, even if they cause the lint to fire more aggressively it's like... objectively more correct. @bors r+ |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Sep 13, 2024
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#129320 (Fix crash when labeling arguments for call_once and friends) - rust-lang#130266 (target: default to the medium code model on LoongArch targets) - rust-lang#130297 (Dataflow cleanups) - rust-lang#130299 (Add set_dcx to ParseSess) - rust-lang#130301 (some fixes for clashing_extern_declarations lint) - rust-lang#130305 (Clippy: consider msrv for const context for const_float_bits_conv) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Sep 13, 2024
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#129320 (Fix crash when labeling arguments for call_once and friends) - rust-lang#130266 (target: default to the medium code model on LoongArch targets) - rust-lang#130297 (Dataflow cleanups) - rust-lang#130299 (Add set_dcx to ParseSess) - rust-lang#130301 (some fixes for clashing_extern_declarations lint) - rust-lang#130305 (Clippy: consider msrv for const context for const_float_bits_conv) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Sep 13, 2024
Rollup merge of rust-lang#130301 - RalfJung:clashing_extern_declarations, r=compiler-errors some fixes for clashing_extern_declarations lint There were two issues with the clashing_extern_declarations lint: - It would accept non-`repr(C)` structs as compatible with each other by comparing their fields in declaration order, but the fields could have different memory order (and with `-Zrandomize-layout`, this can really happen). - It would accept two types as compatible if `compare_layouts` returns `true`, but that function actually just compared the *ABI*, not the fully layout -- and all sized structs with more than 2 fields have the same ABI (`Abi::Aggregate`), so this missed a *lot* of cases. We don't currently have a clear spec for what we *want* to consider "clashing" and what is fine, so I otherwise kept the original logic. I hope to have a t-lang discussion about this at some point. But meanwhile, these changes seem like clear bugfixes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There were two issues with the clashing_extern_declarations lint:
repr(C)structs as compatible with each other by comparing their fields in declaration order, but the fields could have different memory order (and with-Zrandomize-layout, this can really happen).compare_layoutsreturnstrue, but that function actually just compared the ABI, not the fully layout -- and all sized structs with more than 2 fields have the same ABI (Abi::Aggregate), so this missed a lot of cases.We don't currently have a clear spec for what we want to consider "clashing" and what is fine, so I otherwise kept the original logic. I hope to have a t-lang discussion about this at some point. But meanwhile, these changes seem like clear bugfixes.