Sorry! I was mostly offline over the holidays. On Sat Dec 21, 2024 at 3:01 AM CET, Kent Gibson wrote: > On Fri, Dec 20, 2024 at 05:25:16PM +0100, Bartosz Golaszewski wrote: > > Hi Viresh et al, > > > > I noticed the following warning when building libgpiod rust bindings > > with rust 1.83: > > > > warning: elided lifetime has a name > > --> libgpiod/src/line_request.rs:234:26 > > | > > 231 | pub fn read_edge_events<'a>( > > | -- lifetime `'a` declared here > > ... > > 234 | ) -> Result<request::Events> { > > | ^^^^^^ this elided lifetime gets resolved as `'a` > > | > > = note: `#[warn(elided_named_lifetimes)]` on by default > > > > Could you please take a look as I have no idea what that means? > > > > clippy is complaining that the lifetime of the returned object is implicit. > > Try: > > --- a/bindings/rust/libgpiod/src/line_request.rs > +++ b/bindings/rust/libgpiod/src/line_request.rs > @@ -231,7 +231,7 @@ impl Request { > pub fn read_edge_events<'a>( > &'a self, > buffer: &'a mut request::Buffer, > - ) -> Result<request::Events> { > + ) -> Result<request::Events<'a>> { > buffer.read_edge_events(self) > } > } > > to make it explicit. Thats overall correct. Though this is an actual compiler warning and not coming from clippy. But looking in a bit more detail I think the 'a on &self is wrong: --- a/bindings/rust/libgpiod/src/line_request.rs +++ b/bindings/rust/libgpiod/src/line_request.rs @@ -230,7 +230,7 @@ impl Request { /// This function will block if no event was queued for the line. pub fn read_edge_events<'a>( - &'a self, + &self, buffer: &'a mut request::Buffer, - ) -> Result<request::Events> { + ) -> Result<request::Events<'a>> { buffer.read_edge_events(self) } The lifetime is needed because the returned event reference is linked to the lifetime of the buffer. With the &'a self the compiler will add a <'a> to the return value. But there is no dependency on the Request reference that extends longer than this function call. Instead we want to explicitly break up the tie to the &self and tie it to the buffer instead! Sent a patch: https://lore.kernel.org/r/20250102-lifetime-fix-v1-1-313a6bc806c4@xxxxxxxxxx/ - Erik