-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix clashing_extern_declarations stack overflow for recursive types. #75554
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
Fix clashing_extern_declarations stack overflow for recursive types. #75554
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Could someone else review this? I don't have the capacity. |
src/librustc_lint/builtin.rs
Outdated
structurally_same_type_impl(seen_types, cx, a_ty, b_ty, ckind) | ||
} | ||
(RawPtr(a_tymut), RawPtr(b_tymut)) => { | ||
a_tymut.mutbl == b_tymut.mutbl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while not part of this PR I would expect *const T
and *mut T
to be structurally equal.
To my knowledge they only differ in variance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. My reasoning for having them not equal is because I want this case to clash:
mod a {
extern "C" {
fn take(_: *const S);
}
}
mod b {
extern "C" {
fn take(_: *mut S);
}
}
Specifically, I want to guard against the case where take
actually mutates the data underneath, but a::take
is called with data that was supposed to be immutable -- a conflicting declaration of the mutability of some data should ring some alarm bells.
@rustbot modify labels to -S-waiting-on-author, +S-waiting-on-review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nits, otherwise this is looking good 👍
0e28346
to
af0fb0e
Compare
Cool, this is good to go. @rustbot modify labels to -S-waiting-on-author, +S-waiting-on-review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, r=me after the comment by @nagisa is resolved
Adds a seen set to structurally_same_type to avoid recursing indefinitely when a reference or pointer member introduces a cycle in the visited types.
That cache is unlikely to be particularly useful within a single invocation of structurally_same_type, especially compared to memoizing results across _all_ invocations of that function.
af0fb0e
to
bc15dd6
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit bc15dd6 with merge 6f54fb4d9fd2b0e3b6dec01b4b67bd2692cbb454... |
☀️ Try build successful - checks-actions, checks-azure |
Queued 6f54fb4d9fd2b0e3b6dec01b4b67bd2692cbb454 with parent b97e9b5, future comparison URL. |
Finished benchmarking try commit (6f54fb4d9fd2b0e3b6dec01b4b67bd2692cbb454): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
perf looks neutral to me @bors r+ rollup=always |
📌 Commit bc15dd6 has been approved by |
…erflow, r=lcnr Fix clashing_extern_declarations stack overflow for recursive types. Fixes rust-lang#75512. Adds a seen set to `structurally_same_type` to avoid recursing indefinitely for types which contain values of the same type through a pointer or reference.
…erflow, r=lcnr Fix clashing_extern_declarations stack overflow for recursive types. Fixes rust-lang#75512. Adds a seen set to `structurally_same_type` to avoid recursing indefinitely for types which contain values of the same type through a pointer or reference.
…erflow, r=lcnr Fix clashing_extern_declarations stack overflow for recursive types. Fixes rust-lang#75512. Adds a seen set to `structurally_same_type` to avoid recursing indefinitely for types which contain values of the same type through a pointer or reference.
…erflow, r=lcnr Fix clashing_extern_declarations stack overflow for recursive types. Fixes rust-lang#75512. Adds a seen set to `structurally_same_type` to avoid recursing indefinitely for types which contain values of the same type through a pointer or reference.
…erflow, r=lcnr Fix clashing_extern_declarations stack overflow for recursive types. Fixes rust-lang#75512. Adds a seen set to `structurally_same_type` to avoid recursing indefinitely for types which contain values of the same type through a pointer or reference.
Rollup of 9 pull requests Successful merges: - rust-lang#75038 (See also X-Link mem::{swap, take, replace}) - rust-lang#75049 (docs(marker/copy): provide example for `&T` being `Copy`) - rust-lang#75499 (Fix documentation error) - rust-lang#75554 (Fix clashing_extern_declarations stack overflow for recursive types.) - rust-lang#75646 (Move to intra doc links for keyword documentation) - rust-lang#75652 (Resolve true and false as booleans) - rust-lang#75658 (Don't emit "is not a logical operator" error outside of associative expressions) - rust-lang#75665 (Add doc examples coverage) - rust-lang#75685 (Switch to intra-doc links in /src/sys/unix/ext/*.rs) Failed merges: r? @ghost
Fixes #75512.
Adds a seen set to
structurally_same_type
to avoid recursing indefinitely for types which contain values of the same type through a pointer or reference.