wf: check foreign fn decls for well-formedness#73323
Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
|
Does this also fix #73253? If so, this is a breaking change (which we should still land IMO) and may require a crater run 😅 Even this PR doesn't change its output, can you still add this as a test? pub trait Unsatisfied {}
#[repr(transparent)]
pub struct Foo<T: Unsatisfied>(T);
extern "C" {
pub fn foo() -> Foo<u32>;
} |
c83d10f to
9fc57fb
Compare
This also fixes #73253, I've added that to the test.
Probably, I'll wait to see what the reviewer thinks - not entirely sure what the protocol is here. |
lcnr
left a comment
There was a problem hiding this comment.
impl looks good 👍 requires crater run IMO
|
@bors try Crater seems borked at the moment, but we can prepare a build. |
|
⌛ Trying commit 9fc57fb950edf74e880a1348a2860f41d481def1 with merge aef0c51c752d86410f02b64fbda721f083f33c39... |
|
☀️ Try build successful - checks-azure |
|
Sorry. I seem to have missed this one. The implementation looks good, and it seems like something that we clearly want to do. I would be surprised if this broke real code, but I feel a bit uncomfortable approving unilaterally since the possibility exists. @rust-lang/compiler, does anyone object to this PR? Otherwise, r=me if there are no crater regressions. |
|
Code looks good and this is a clear fix of invalid code, but having tried something similar out for |
|
Definitely do a crater run. We should be able to manage a future-compatibility warning. We may want to do it anyway, but a crater run is a good first step. |
9fc57fb to
822fe7f
Compare
|
Rebased this to make sure it was still working - will do a try build then crater run. @bors try |
|
⌛ Trying commit 822fe7f00cc35bdaae86add5fe18de20631a2cfd with merge 85cc1486e1f000dce4bb8e1b3cfab2b654b102a8... |
|
☀️ Try build successful - checks-actions, checks-azure |
|
@craterbot check |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🎉 Experiment
|
|
It looks like all regressions are spurious to me. |
This commit extends current well-formedness checking to apply to foreign function declarations, re-using the existing machinery for regular functions. In doing this, later parts of the compiler (such as the `improper_ctypes` lint) can rely on being operations not failing as a result of invalid code which would normally be caught earlier. Signed-off-by: David Wood <david@davidtw.co>
822fe7f to
ceac273
Compare
|
Rebased this PR; I agree with @lcnr that the crater report looks good, so I'll r=ecstatic-morse after CI passes. |
|
@bors r=ecstatic-morse |
|
📌 Commit ceac273 has been approved by |
…arth Rollup of 13 pull requests Successful merges: - rust-lang#72714 (Fix debug assertion in typeck) - rust-lang#73197 (Impl Default for ranges) - rust-lang#73323 (wf: check foreign fn decls for well-formedness) - rust-lang#74051 (disallow non-static lifetimes in const generics) - rust-lang#74376 (test caching opt_const_param_of on disc) - rust-lang#74501 (Ayu theme: Use different background color for Run button) - rust-lang#74505 (Fix search input focus in ayu theme) - rust-lang#74522 (Update sanitizer docs) - rust-lang#74546 (Fix duplicate maybe_uninit_extra attribute) - rust-lang#74552 (Stabilize TAU constant.) - rust-lang#74555 (Improve "important traits" popup display on mobile) - rust-lang#74557 (Fix an ICE on an invalid `binding @ ...` in a tuple struct pattern) - rust-lang#74561 (update backtrace-rs) Failed merges: r? @ghost
Fixes #73252 and fixes #73253.
This PR extends current well-formedness checking to apply to foreign function declarations, re-using the existing machinery for regular functions. In doing this, later parts of the compiler (such as the
improper_ctypeslint) can rely on being operations not failing as a result of invalid code which would normally be caught earlier.