Skip to content

Suppress "unused import" for abstract param/return types #1486

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tchebb
Copy link
Contributor

@tchebb tchebb commented Jun 9, 2025

When we generate a non-wrapped function or method binding that takes or returns an abstract (i.e. pure virtual) type not referenced elsewhere, we get an erroneous "unused import" warning for the user-visible re-export of that abstract type. This happens because the only use of the type is emitted by cxx and thus references the binding in cxxbridge instead of the re-export in output. [See the unqualify_params_minisyn() and unqualify_ret_type() calls in codegen_rs::fun_codegen::gen_function().]

The warning is erroneous because the re-export is the only way for users to name the type, and we don't want to generate an API that takes or returns types the user can't name. So let's just suppress it, like we did for non-abstract types in #1345.

When we generate a non-wrapped function or method binding that takes or
returns an abstract (i.e. pure virtual) type not referenced elsewhere,
we get an erroneous "unused import" warning for the user-visible
re-export of that abstract type. This happens because the only use of
the type is emitted by cxx and thus references the binding in
"cxxbridge" instead of the re-export in "output". [See the
unqualify_params_minisyn() and unqualify_ret_type() calls in
codegen_rs::fun_codegen::gen_function().]

The warning is erroneous because the re-export is the only way for users
to name the type, and we don't want to generate an API that takes or
returns types the user can't name. So let's just suppress it, like we
did for non-abstract types in commit 5dd9a00 ("Fix unused import
warnings.").
tchebb added a commit to tchebb/openwv that referenced this pull request Jun 10, 2025
Since autocxx subclasses don't support multiple inheritance, we have to
subclass all the ContentDecryptionModule_NN versions in C++ and then
subclass a second time in Rust. This means we do now have some C++ in
our tree (hence the Chromium-derived .clang-format), but it's cleaner
than the other options. For Host_NN, we can do dynamic dispatch in Rust.
I've added a macro to reduce the boilerplate, but there's still some.
Even though the code's not the cleanest, I think this feature is
important enough to justify the added complexity.

The new C++ header exposed a bug in autocxx, which I've fixed in [1] and
incorporated into our fork.

Note that, while Chromium parses the "x-cdm-*-versions" manifest keys as
comma-separated lists, Firefox parses each as a single number. I've put
the comma-separated versions in the Firefox manifest too because the bug
might get fixed by the time Firefox drops interface 10 support.

[1] google/autocxx#1486
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant