Repository navigation
cxx-qt-gen: do not forward unsafe extern "RustQt" to methods - #1500
Open
wehrwolfmann wants to merge 2 commits into
Open
wehrwolfmann wants to merge 2 commits into
wehrwolfmann wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1500 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 75 75
Lines 13929 13921 -8
=========================================
- Hits 13929 13921 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
Are you able to rebase these changes when you have a chance :-) |
An extern "RustQt" block becomes an extern "Rust" block for CXX, where the unsafe of the block is not forwarded to the functions and CXX rejects an unsafe extern "Rust" block. Follow the same rule for methods and invokables, so only the unsafe on the fn itself is used and methods taking a raw pointer need to be an unsafe fn. The unsafe of the block is still used for #[inherit] methods and signals, as they are C++ functions in a generated extern "C++" block.
Methods follow the rules of extern "Rust" in CXX, so only the unsafe on the fn itself is used, while #[inherit] methods and signals follow the rules of extern "C++" and need an unsafe extern "RustQt" block when they are safe to call.
wehrwolfmann
force-pushed
the
rustqt-unsafe-consistent
branch
from
October 29, 2026 21:44
821dcef to
d2f90bd
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As discussed in #1490, methods and invokables in an
extern "RustQt"blocknow follow the same rules as an
extern "Rust"block in CXX: only theunsafeon the fn itself is used. Previously a safe method inside anunsafe extern "RustQt"block was declared as anunsafe fnfor CXX(
unsafe_callingenerator/rust/method.rs, from #1199), which silentlyskipped the CXX check that a method taking a raw pointer must be
unsafe.The
unsafeof the block is still used where it means something:safe-to-call
#[inherit]methods and#[inherit]signals, as they call intothe C++ base class (same as
unsafe extern "C++"in CXX). The generation ofsignals and inherit is unchanged.
Changes:
ParsedMethod::unsafe_blockand the forwarding ingenerate_rust_methods, update the expected outputs, and add anunsafe fninvokable taking a raw pointer to the invokables testextern_rustqt.mdand a note ininheritance.mdThis is a breaking change, only for safe methods in an
unsafe extern "RustQt"block:error[cxx]: pointer argument requires that the function be marked unsafeunsafe fnnow fails witherror[E0133]: call to unsafe function ... is unsafeTo migrate, declare these methods as
unsafe fnin the bridge. No example ortest in this repository needed changes, the existing methods taking raw
pointers (e.g.
CustomParentClass::paint) are alreadyunsafe fn.