declare_clippy_lint! {
/// ### What it does
- /// Checks for `let _ = <expr>`
- /// where expr is #[must_use]
+ /// Checks for `let _ = <expr>` where expr is `#[must_use]`
///
/// ### Why is this bad?
- /// It's better to explicitly
- /// handle the value of a #[must_use] expr
+ /// It's better to explicitly handle the value of a `#[must_use]`
+ /// expr
///
/// ### Example
/// ```rust
/// // is_ok() is marked #[must_use]
/// let _ = f().is_ok();
/// ```
+ #[clippy::version = "1.42.0"]
pub LET_UNDERSCORE_MUST_USE,
restriction,
"non-binding let on a `#[must_use]` expression"
declare_clippy_lint! {
/// ### What it does
- /// Checks for `let _ = sync_lock`
+ /// Checks for `let _ = sync_lock`.
+ /// This supports `mutex` and `rwlock` in `std::sync` and `parking_lot`.
///
/// ### Why is this bad?
/// This statement immediately drops the lock instead of
/// `std::mem::drop` conveys your intention better and is less error-prone.
///
/// ### Example
- ///
- /// Bad:
/// ```rust,ignore
/// let _ = mutex.lock();
/// ```
///
- /// Good:
+ /// Use instead:
/// ```rust,ignore
/// let _lock = mutex.lock();
/// ```
+ #[clippy::version = "1.43.0"]
pub LET_UNDERSCORE_LOCK,
correctness,
"non-binding let on a synchronization lock"
/// better and is less error-prone.
///
/// ### Example
- ///
- /// Bad:
- /// ```rust,ignore
- /// struct Droppable;
- /// impl Drop for Droppable {
- /// fn drop(&mut self) {}
- /// }
+ /// ```rust
+ /// # struct DroppableItem;
/// {
- /// let _ = Droppable;
- /// // ^ dropped here
+ /// let _ = DroppableItem;
+ /// // ^ dropped here
/// /* more code */
/// }
/// ```
///
- /// Good:
- /// ```rust,ignore
+ /// Use instead:
+ /// ```rust
+ /// # struct DroppableItem;
/// {
- /// let _droppable = Droppable;
+ /// let _droppable = DroppableItem;
/// /* more code */
/// // dropped at end of scope
/// }
/// ```
+ #[clippy::version = "1.50.0"]
pub LET_UNDERSCORE_DROP,
pedantic,
"non-binding let on a type that implements `Drop`"
declare_lint_pass!(LetUnderscore => [LET_UNDERSCORE_MUST_USE, LET_UNDERSCORE_LOCK, LET_UNDERSCORE_DROP]);
-const SYNC_GUARD_PATHS: [&[&str]; 3] = [
+const SYNC_GUARD_PATHS: [&[&str]; 6] = [
&paths::MUTEX_GUARD,
&paths::RWLOCK_READ_GUARD,
&paths::RWLOCK_WRITE_GUARD,
+ &paths::PARKING_LOT_MUTEX_GUARD,
+ &paths::PARKING_LOT_RWLOCK_READ_GUARD,
+ &paths::PARKING_LOT_RWLOCK_WRITE_GUARD,
];
impl<'tcx> LateLintPass<'tcx> for LetUnderscore {