Skip to content

ignored-unit-patterns ignores mutability #11754

Open

Description

@matthiaskrgr

EDIT

Using the following flags

--force-warn clippy::ignored-unit-patterns

this code:

//@ edition:2021
//@ check-pass
#![feature(coroutines, stmt_expr_attributes)]

fn main() {
    let x = &mut ();
    || {
        let _c = #[coroutine]
        || yield *&mut *x;
        || _ = &mut *x;
    };
}

caused the following diagnostics:

    Checking _issue-110929-coroutine-conflict-error-ice v0.1.0 (/tmp/icemaker_global_tempdir.EuHmIYit9wj1/icemaker_clippyfix_tempdir.wfNVWxul8RLV/_issue-110929-coroutine-conflict-error-ice)
warning: matching over `()` is more explicit
  --> src/main.rs:10:12
   |
10 |         || _ = &mut *x;
   |            ^ help: use `()` instead of `_`: `()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ignored_unit_patterns
   = note: requested on the command line with `--force-warn clippy::ignored-unit-patterns`

warning: `_issue-110929-coroutine-conflict-error-ice` (bin "_issue-110929-coroutine-conflict-error-ice") generated 1 warning (run `cargo clippy --fix --bin "_issue-110929-coroutine-conflict-error-ice"` to apply 1 suggestion)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s

However after applying these diagnostics, the resulting code:

//@ edition:2021
//@ check-pass
#![feature(coroutines, stmt_expr_attributes)]

fn main() {
    let x = &mut ();
    || {
        let _c = #[coroutine]
        || yield *&mut *x;
        || () = &mut *x;
    };
}

no longer compiled:

    Checking _issue-110929-coroutine-conflict-error-ice v0.1.0 (/tmp/icemaker_global_tempdir.EuHmIYit9wj1/icemaker_clippyfix_tempdir.wfNVWxul8RLV/_issue-110929-coroutine-conflict-error-ice)
error[E0308]: mismatched types
  --> src/main.rs:10:12
   |
10 |         || () = &mut *x;
   |            ^^   ------- this expression has type `&mut ()`
   |            |
   |            expected `&mut ()`, found `()`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `_issue-110929-coroutine-conflict-error-ice` (bin "_issue-110929-coroutine-conflict-error-ice") due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `_issue-110929-coroutine-conflict-error-ice` (bin "_issue-110929-coroutine-conflict-error-ice" test) due to 1 previous error

Version:

rustc 1.90.0-nightly (5e749eb66 2025-06-29)
binary: rustc
commit-hash: 5e749eb66f93ee998145399fbdde337e57cd72ef
commit-date: 2025-06-29
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7

Activity

  1. added
    C-bugCategory: Clippy is not doing the correct thing
    I-false-positiveIssue: The lint was triggered on code it shouldn't have
    on Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions