Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ensure references to opaque structs are qualified for std::fmt::Debug #361

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,11 @@ jobs:
run: cargo test
- name: "matsadler/magnus"
slug: magnus-head
ref: "05359fcd2369f014570f1e417c7c2d462625af5e"
ref: "627755429885eb1a84929e4d876f8cd8ec7303cf"
run: cargo test
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
rust: ["stable"]
ruby: ["2.7", "3.2", "3.3"]
exclude:
- os: windows-latest
ruby: "3.3" # remove this once 3.3 binaries are available for windows
repo:
name: "matsadler/magnus"
slug: magnus-head
ref: "05359fcd2369f014570f1e417c7c2d462625af5e"
run: cargo test
- os: windows-latest
ruby: "3.3" # remove this once 3.3 binaries are available for windows
repo:
name: "matsadler/magnus"
slug: magnus-0.5
ref: "0.5.5"
run: cargo test

runs-on: ${{ matrix.os }}
steps:
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace :test do
cargo_test_task "rb-sys-tests"
cargo_test_task "rb-sys-env"
cargo_test_task "rb-sys-test-helpers"
cargo_test_task "rb-sys", "--all-targets", "--features", "bindgen-impl-debug,link-ruby" # Cover debian use case

desc "Test against all installed Rubies"
task :rubies do
Expand Down
16 changes: 16 additions & 0 deletions crates/rb-sys-build/src/bindings/stable_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ pub fn categorize_bindings(syntax: &mut syn::File) {
excluded_items.push(item);
}
}

// Perform a pass on all std::fmt::Debug implementations to fully qualify opaque structs
for item in excluded_items.iter_mut() {
if let syn::Item::Impl(ref mut impl_item) = item {
if let Some((_, syn::Path { segments, .. }, _)) = impl_item.trait_.as_ref() {
if segments.iter().any(|segment| segment.ident == "Debug") {
if let syn::Type::Path(ref mut path) = *impl_item.self_ty {
if opaque_idents_to_swap.contains(&path.to_token_stream().to_string()) {
*impl_item.self_ty = syn::parse_quote! { crate::internal::#path };
}
}
}
}
}
}

*syntax = syn::parse_quote! {
/// Contains all items that are not yet categorized by ABI stability.
/// These items are candidates for promotion to `stable` or `unstable`
Expand Down
Loading