The main issue with having three lets one after the other, is that it's not
clear if the lifetime created due to `let x` is the one before or after this
line. Assuming I understood correctly what's going on, this example will clarify
that the lifetime is created after the let. I also add a note stating what the
usual notation is and warning that this longer explicit lifetime name is used
only once for the sake of being as clear as possible.
Other solutions I considered would be to add a "print" between two lets, this
will ensure that the lifetime introduction is near a single "let", hence making
it clear which "let" is concerned by the lifetime.
If I got it wrong and actually the scope is introduced before the let statement,
I guess at least this confirms that clarification may be helpful.
This was a bit confusing for me to read, as it was using an old style of rust that I am not used to
Unfortunately, this lint group isn't on by default, but I think `elided_lifetimes_in_paths` may be on track to be deny-by-default in edition 2021?
Currently, the lifetime elision doc only documents function definitions, but lifetime elision is also allowed in the following other locations:
* `fn` types, such as `fn(&T)`
* `Fn`/`FnMut`/`FnOnce`, such as `Fn(&T)`
* `impl` headers
To demo this up, I made some type aliases for `fn`/`Fn` which you can pass `&T` as a parameter to (to follow the lifetime rules of the surrounding context), and compared what you get with that instead of using `fn`/`Fn` directly, where lifetime elision takes on the rules from `fn`/`Fn`/etc.
I also demoed up an `impl` header that used lifetime elision twice, although the error message in that case is broken (filed https://github.com/rust-lang/rust/issues/87763)
The demo was half for this change description, and half just to make sure I understand Rust -- in particular, I really had to reverse engineer it for `impl` because I wasn't sure, and it didn't seem to be documented anywhere (at least not here!)
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f82b280de4b992f225bc32121f333e96