Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FP: unused_unit: closure lifetime binder #9883

Closed
matthiaskrgr opened this issue Nov 19, 2022 · 4 comments
Closed

FP: unused_unit: closure lifetime binder #9883

matthiaskrgr opened this issue Nov 19, 2022 · 4 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@matthiaskrgr
Copy link
Member

Summary

.

Lint Name

unused_unit

Reproducer

I tried this code:

#![feature(closure_lifetime_binder)]

fn main() {
    let _ = for<'a> || -> () {
        let _: &'a bool = &true;
    };
}

I saw this happen:
cargo clippy --fix -- -Aclippy::all -Wclippy::unused_unit

    Checking a v0.1.0 (/tmp/a)
warning: failed to automatically apply fixes suggested by rustc to crate `a`

after fixes were automatically applied the compiler reported errors within these files:

  * src/main.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

The following errors were reported:
error: implicit types in closure signatures are forbidden when `for<...>` is present
 --> src/main.rs:4:24
  |
4 |     let _ = for<'a> || {
  |             -------    ^
  |             |
  |             `for<...>` is here

error: aborting due to previous error

Original diagnostics will follow.

warning: unneeded unit return type
 --> src/main.rs:4:23
  |
4 |     let _ = for<'a> || -> () {
  |                       ^^^^^^ help: remove the `-> ()`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit
  = note: requested on the command line with `-W clippy::unused-unit`

warning: `a` (bin "a") generated 1 warning (run `cargo fix --bin "a"` to apply 1 s

Version

rustc 1.67.0-nightly (b833ad56f 2022-11-18)
binary: rustc
commit-hash: b833ad56f46a0bbe0e8729512812a161e7dae28a
commit-date: 2022-11-18
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4

Additional Labels

No response

@matthiaskrgr matthiaskrgr added C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied I-false-positive Issue: The lint was triggered on code it shouldn't have labels Nov 19, 2022
@matthiaskrgr matthiaskrgr changed the title FP: unused_unit FP: unused_unit: closure lifetime binder Nov 19, 2022
@y21
Copy link
Member

y21 commented Jul 19, 2023

There are no warnings in the reproducer anymore. #9849 probably fixed this?

@matthiaskrgr
Copy link
Member Author

we should have a test than to make sure this doesn't regress at some point :)

@y21
Copy link
Member

y21 commented Jul 19, 2023

I think such a test was already added by the PR:

mod issue9748 {
fn main() {
let _ = for<'a> |_: &'a u32| -> () {};
}
}

or do you think your case is different that it also deserves its own test? It looks like the same issue to me

@y21
Copy link
Member

y21 commented Mar 6, 2024

This was fixed in #9849 , and the test that was added there seems basically equivalent to the repro here, so I think it can be safely closed

@y21 y21 closed this as completed Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

No branches or pull requests

2 participants