a6f80fccb1
This pull request adds a lint against single character lifetime names, as they might not divulge enough information about the purpose of the lifetime. This can make code harder to understand. I placed this in `restriction` rather than `pedantic` (as suggested in #8233) since most of the Rust ecosystem already uses single character lifetime names (to my knowledge, at least) and since single character lifetime names aren't incorrect. I'd be happy to change this upon request, however. Fixes #8233. - [x] Followed lint naming conventions - [x] Added passing UI tests (including committed `.stderr` file) - [x] `cargo test` passes locally - [x] Executed `cargo dev update_lints` - [x] Added lint documentation - [x] Run `cargo dev fmt` changelog: new lint: [`single_char_lifetime_names`]
44 lines
1.2 KiB
Plaintext
44 lines
1.2 KiB
Plaintext
error: single-character lifetime names are likely uninformative
|
|
--> $DIR/single_char_lifetime_names.rs:4:22
|
|
|
|
|
LL | struct DiagnosticCtx<'a, 'b>
|
|
| ^^
|
|
|
|
|
= note: `-D clippy::single-char-lifetime-names` implied by `-D warnings`
|
|
= help: use a more informative name
|
|
|
|
error: single-character lifetime names are likely uninformative
|
|
--> $DIR/single_char_lifetime_names.rs:4:26
|
|
|
|
|
LL | struct DiagnosticCtx<'a, 'b>
|
|
| ^^
|
|
|
|
|
= help: use a more informative name
|
|
|
|
error: single-character lifetime names are likely uninformative
|
|
--> $DIR/single_char_lifetime_names.rs:13:6
|
|
|
|
|
LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> {
|
|
| ^^
|
|
|
|
|
= help: use a more informative name
|
|
|
|
error: single-character lifetime names are likely uninformative
|
|
--> $DIR/single_char_lifetime_names.rs:13:10
|
|
|
|
|
LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> {
|
|
| ^^
|
|
|
|
|
= help: use a more informative name
|
|
|
|
error: single-character lifetime names are likely uninformative
|
|
--> $DIR/single_char_lifetime_names.rs:33:15
|
|
|
|
|
LL | fn split_once<'a>(base: &'a str, other: &'_ str) -> (&'a str, Option<&'a str>) {
|
|
| ^^
|
|
|
|
|
= help: use a more informative name
|
|
|
|
error: aborting due to 5 previous errors
|
|
|