Skip to content

Improper QueryBuilderImpl::expr lifetime #292

@dubrowgn

Description

@dubrowgn

QueryBuilderImpl<'a>::expr improperly ties the lifetime of the expr argument to the lifetime of the QueryBuilderImpl instance, despite not accessing the argument outside the scope of the function. This makes using the API with non-static query expressions difficult/impossible. E.g. this:

pub trait QueryBuilderImpl<'a>: TermBuilderImpl<'a> {
    fn expr(&mut self, expr: &'a str) -> &mut Self { // <-- improper use of &'a
        let expr = ManuallyDrop::new(format!("{expr}\0"));
        ...
    }
}

Should be:

pub trait QueryBuilderImpl<'a>: TermBuilderImpl<'a> {
    fn expr(&mut self, expr: &str) -> &mut Self { // <-- 
        let expr = ManuallyDrop::new(format!("{expr}\0"));
        ...
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions