Skip to content

Commit

Permalink
Ensure references to opaque structs are qualified for `std::fmt::Debu…
Browse files Browse the repository at this point in the history
…g` (#361)

* Ensure references to opaque structs are qualified for `std::fmt::Debug`

* Test on newer magnus head
  • Loading branch information
ianks authored Apr 18, 2024
1 parent e13de89 commit 9270f1a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
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

0 comments on commit 9270f1a

Please # to comment.