Skip to content
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

Support elided lifetime in member function receiver #657

Closed
dtolnay opened this issue Jan 3, 2021 · 0 comments · Fixed by #660
Closed

Support elided lifetime in member function receiver #657

dtolnay opened this issue Jan 3, 2021 · 0 comments · Fixed by #660

Comments

@dtolnay
Copy link
Owner

dtolnay commented Jan 3, 2021

// include/example.h

#pragma once
#include <memory>

struct Object {
  void f() const {}
};
// src/main.rs

#[cxx::bridge]
mod ffi {
    unsafe extern "C++" {
        include!("repro/include/example.h");

        type Object<'a>;

        fn f(self: &Object);
    }
}

fn main() {}

The above should work (with an elided lifetime on Object but currently doesn't.

error[E0726]: implicit elided lifetime not allowed here
 --> src/main.rs:8:21
  |
8 |         fn f(self: &Object);
  |                     ^^^^^^- help: indicate the anonymous lifetime: `<'_>`

Writing fn f(self: &Object<'_>) instead makes it work but shouldn't be necessary.

Lifetime elision is already support in non-member functions, e.g. fn f(obj: &Object).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant