Skip to content

Regression in 1.0.40 handling of extern C++ return reference types #799

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

Closed
jlebon opened this issue Mar 30, 2021 · 2 comments · Fixed by #800
Closed

Regression in 1.0.40 handling of extern C++ return reference types #799

jlebon opened this issue Mar 30, 2021 · 2 comments · Fixed by #800

Comments

@jlebon
Copy link

jlebon commented Mar 30, 2021

With 1.0.40, this code:

    unsafe extern "C++" {
        include!("rpmostree-clientlib.h");
        fn client_require_root() -> Result<()>;
        type ClientConnection;
        fn new_client_connection() -> Result<UniquePtr<ClientConnection>>;
        fn get_connection<'a>(self: Pin<&'a mut ClientConnection>) -> Pin<&'a mut GDBusConnection>;
        fn transaction_connect_progress_sync(&self, address: &str) -> Result<()>;
    }

no longer compiles:

error[E0308]: mismatched types
   --> rust/src/lib.rs:26:1
    |
26  | #[cxx::bridge(namespace = "rpmostreecxx")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Pin`, found `&mut _`
...
381 |         fn get_connection<'a>(self: Pin<&'a mut ClientConnection>) -> Pin<&'a mut GDBusConnection>;
    |                                                                       ---------------------------- expected `Pin<&'a mut cxxrsutil::FFIGDBusConnection>` because of return type
    |
    = note:         expected struct `Pin<&'a mut cxxrsutil::FFIGDBusConnection>`
            found mutable reference `&mut _`
    = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

(Associated C++ code is here: https://github.com/coreos/rpm-ostree/blob/bef1fc792655e6a22cc8676949a6a5792686ee2b/src/app/rpmostree-clientlib.h#L37-L56)

It's not clear from the error message what exactly is wrong. It said it found a &mut _ but the underlined type matches exactly the expected type (GDBusConnection is the same type as cxxrsutil::FFIGDBusConnection).

@dtolnay
Copy link
Owner

dtolnay commented Mar 30, 2021

This was a poor interaction between #408 and #781. Sorry about the breakage! I've released a fix in 1.0.41.

jlebon added a commit to coreos/rpm-ostree that referenced this issue Mar 31, 2021
@jlebon
Copy link
Author

jlebon commented Mar 31, 2021

Thanks for the quick fix!

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 a pull request may close this issue.

2 participants