refactor: enable elided_lifetimes_in_paths lint (#203)

Hiding the lifetimes is making the code less obvious.

That’s not a problem for types that I know about intimately such as
`ReadCursor` or `WriteCursor`, but I actually found myself surprised
more than once when reading code I didn’t authored, discovering  later
there was in fact a hidden lifetime parameter.
I expect this problem to be worse for someone not familiar with
our codebase.

I understand this lint is "allow" by default because in some cases
it leads to writing unergonomic ugly code when a type has many generic
lifetimes parameters:

```
TyCtxt<'_, '_, '_>
```

However we _never_ work with more than one generic lifetime parameter in
IronRDP codebase, so it seems to me that the tradeoff towards clarity is
worth it, in our case.
This commit is contained in:
Benoît Cortier 2023-10-04 12:14:36 -04:00 committed by GitHub
parent c670ab4331
commit 3d98cd1d94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 343 additions and 137 deletions

View file

@ -1,5 +1,6 @@
use crate::prelude::*;
// TODO: when 1.74 is released use `[lints]`: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#lints
const EXTRA_LINTS: &[&str] = &[
// == Safer unsafe == //
"unsafe_op_in_unsafe_fn",
@ -24,6 +25,7 @@ const EXTRA_LINTS: &[&str] = &[
// TODO: "clippy::unwrap_used", // lets either handle `None`, `Err` or use `expect` to give a reason
"clippy::large_stack_frames",
// == Style, readability == //
"elided_lifetimes_in_paths", // https://quinedot.github.io/rust-learning/dont-hide.html
"absolute_paths_not_starting_with_crate",
"single_use_lifetimes",
"unreachable_pub",
@ -92,6 +94,7 @@ pub fn fmt(sh: &Shell) -> anyhow::Result<()> {
pub fn lints(sh: &Shell) -> anyhow::Result<()> {
let _s = Section::new("LINTS");
// TODO: when 1.74 is released use `--keep-going`: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#keep-going
let cmd = cmd!(sh, "{CARGO} clippy --workspace --locked -- -D warnings");
EXTRA_LINTS.iter().fold(cmd, |cmd, lint| cmd.args(["-W", lint])).run()?;