Add allow-by-default lint for unit bindings

This lint is not triggered if any of the following conditions are met:

- The user explicitly annotates the binding with the `()` type.
- The binding is from a macro expansion.
- The user explicitly wrote `let () = init;`
- The user explicitly wrote `let pat = ();`. This is allowed for local
  lifetimes.
This commit is contained in:
许杰友 Jieyou Xu (Joe)
2023-06-14 00:19:09 +08:00
parent 4f3da903a4
commit 8da09aed94
6 changed files with 88 additions and 2 deletions

View File

@@ -1845,3 +1845,10 @@ impl<'a> DecorateLint<'a, ()> for AsyncFnInTraitDiag {
fluent::lint_async_fn_in_trait
}
}
#[derive(LintDiagnostic)]
#[diag(lint_unit_bindings)]
pub struct UnitBindingsDiag {
#[label]
pub label: Span,
}