Skip to content

FP empty_structs_with_brackets #9887

Closed
@matthiaskrgr

Description

@matthiaskrgr

Summary

.

Lint Name

empty_structs_with_brackets.

Reproducer

I tried this code:

#![feature(box_syntax, fn_traits, unboxed_closures)]

struct GreetStruct2();

impl FnOnce<(&str,)> for GreetStruct2 {
    type Output = ();

    extern "rust-call" fn call_once(self, (who,): (&str,)) -> Self::Output {
        println!("hello {}", who);
    }
}


fn main() {
    GreetStruct2()("world");
}

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

    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[E0057]: this struct takes 1 argument but 0 arguments were supplied
  --> src/main.rs:15:5
   |
15 |     GreetStruct2()("world");
   |     ^^^^^^^^^^^^-- an argument of type `&str` is missing
   |
help: provide the argument
   |
15 |     GreetStruct2(/* &str */)("world");
   |                 ~~~~~~~~~~~~

error[E0618]: expected function, found `()`
  --> src/main.rs:15:5
   |
3  | struct GreetStruct2;
   | ------------------- `GreetStruct2` defined here returns `()`
...
15 |     GreetStruct2()("world");
   |     ^^^^^^^^^^^^^^---------
   |     |
   |     call expression requires function

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0057, E0618.
For more information about an error, try `rustc --explain E0057`.
Original diagnostics will follow.

warning: found empty brackets on struct declaration
 --> src/main.rs:3:20
  |
3 | struct GreetStruct2();
  |                    ^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_structs_with_brackets
  = note: requested on the command line with `-W clippy::empty-structs-with-brackets`
  = help: remove the brackets

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

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

Metadata

Metadata

Assignees

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