Closed tonywu6 closed 2 days ago
Thank you for reporting this!
The nuance is that it's possible for functions and impl blocks in Rust to have unused lifetimes, while it's not possible to have unused lifetimes in structs.
For example this compiles albeit with an unused_lifetimes
warning:
fn sut<'a, 'b>() {}
struct Sut;
impl<'a, 'b> Sut {}
I didn't think of this edge case. The builder's internal phantom data needs to capture all lifetime parameters as &'a
(), &'b (), ...
to make sure they all are used even when no function's parameter references it.
The fix was released in a 3.0.1 patch.
First of all thank you for this wonderful library!
Version
Description
The following doesn't compile:
As suggested by rustc, this could be worked around using
PhantomData
:Looking at the macro expansion:
The error (credit to this SO answer which explains it nicely) is expected: the borrow checker can't find anything in
SomeFuncBuilder
that is borrowing data for'a
, but it's confusing when appearing on function-like syntax (it certainly was for me!)It'd be great if bon can detect such "unused" lifetimes and put them somewhere in the builder struct.
A note for the community from the maintainers
Please vote on this issue by adding a 👍 reaction to help the maintainers with prioritizing it. You may add a comment describing your real use case related to this issue for us to better understand the problem domain.