Skip to content

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Aug 9, 2025

dtolnay added 13 commits August 9, 2025 16:46
    error: extern blocks should be unsafe
       --> tests/ffi/lib.rs:109:48
        |
    109 |         fn c_return_shared_ptr() -> SharedPtr<C>;
        |                                                ^
        |                                                |
        |                                                help: needs `unsafe` before the extern keyword: `unsafe`
        |
        = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024!
        = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/unsafe-extern.html>
    note: the lint level is defined here
       --> tests/ffi/lib.rs:16:9
        |
     16 | #![deny(warnings)] // Check that expansion of `cxx::bridge` doesn't trigger warnings.
        |         ^^^^^^^^
        = note: `#[deny(missing_unsafe_on_extern)]` implied by `#[deny(warnings)]`

    error[E0133]: call to unsafe function `<ffi::C as cxx::memory::SharedPtrTarget>::__from_unmanaged::__from_unmanaged` is unsafe and requires unsafe block
       --> tests/ffi/lib.rs:109:48
        |
    109 |         fn c_return_shared_ptr() -> SharedPtr<C>;
        |                                                ^ call to unsafe function
        |
        = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/unsafe-op-in-unsafe-fn.html>
        = note: consult the function's documentation for information on how to avoid undefined behavior
    note: an unsafe function restricts its caller, but its body is safe by default
       --> tests/ffi/lib.rs:109:48
        |
    109 |         fn c_return_shared_ptr() -> SharedPtr<C>;
        |                                                ^
    note: the lint level is defined here
       --> tests/ffi/lib.rs:15:11
        |
     15 | #![forbid(unsafe_op_in_unsafe_fn)]
        |           ^^^^^^^^^^^^^^^^^^^^^^
This matches standard library's Box::from_raw.
    warning: borrow as raw pointer
       --> tests/test.rs:297:15
        |
    297 |     let ptr = &*unique as *const _;
        |               ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of!(*unique)`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr
        = note: `-W clippy::borrow-as-ptr` implied by `-W clippy::pedantic`
        = help: to override `-W clippy::pedantic` add `#[allow(clippy::borrow_as_ptr)]`

    warning: borrow as raw pointer
       --> tests/test.rs:299:16
        |
    299 |     assert_eq!(&*shared as *const _, ptr);
        |                ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of!(*shared)`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr

    warning: borrow as raw pointer
       --> tests/test.rs:306:15
        |
    306 |     let ptr = &*unique as *const _;
        |               ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of!(*unique)`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr

    warning: borrow as raw pointer
       --> tests/test.rs:308:16
        |
    308 |     assert_eq!(&*shared as *const _, ptr);
        |                ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of!(*shared)`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr
@dtolnay dtolnay linked an issue Aug 9, 2025 that may be closed by this pull request
@dtolnay dtolnay merged commit a5f1357 into master Aug 9, 2025
45 checks passed
@dtolnay dtolnay deleted the uniq2shared branch August 9, 2025 23:56
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.

Add conversion form UniquePtr<T> to SharedPtr<T>
1 participant