Skip to content

missing lifetime specifier when taking self_ and &Zval and returning self_ #506

@kakserpom

Description

@kakserpom

Related to #502

Note that it compiles without -> &mut ZendClassObject<Example>.

use ext_php_rs::{prelude::*, types::ZendClassObject};
use ext_php_rs::types::Zval;

#[php_class]
pub struct Example {}

#[php_impl]
impl Example {
    pub fn __construct() -> Example {
        Example {}
    }
    pub fn some_method(
        self_: &mut ZendClassObject<Example>,
        zval: &Zval,
    ) -> &mut ZendClassObject<Example> {
        self_
    }
}

#[php_module]
pub fn get_module(module: ModuleBuilder) -> ModuleBuilder {
    module.class::<Example>()
}
error[E0106]: missing lifetime specifier
  --> src/lib.rs:15:10
   |
13 |         self_: &mut ZendClassObject<Example>,
   |                -----------------------------
14 |         zval: &Zval,
   |               -----
15 |     ) -> &mut ZendClassObject<Example> {
   |          ^ expected named lifetime parameter
   |
   = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `self_` or `zval`
help: consider introducing a named lifetime parameter
   |
12 ~     pub fn some_method<'a>(
13 ~         self_: &'a mut ZendClassObject<Example>,
14 ~         zval: &'a Zval,
15 ~     ) -> &'a mut ZendClassObject<Example> {
   |

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmacrosRelated to macros

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions