Skip to content

Clippy Auto-fix causes error #8827

Open
@SkyfallWasTaken

Description

@SkyfallWasTaken

Summary

When running cargo clippy --fix, clippy changes this:
cli/src/run_script.rs

let status = run_in_shell::run(&script, shell);

to this:

let status = run_in_shell::run(script, shell);

which causes an error.

Full command log
    Checking run_in_shell v0.1.0 (E:\projects\vortex\run_in_shell)
    Checking validate_package_name v0.1.0 (E:\projects\vortex\validate_package_name)
    Checking install_npm v0.1.0 (E:\projects\vortex\install_npm)
    Checking vortex v0.1.0 (E:\projects\vortex\cli)
warning: failed to automatically apply fixes suggested by rustc to crate `vortex`      

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

  • cli\src\run_script.rs
  • cli\src\subcommands..\run_script.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: expected one of !, ), ,, ., ::, ?, {, or an operator, found shell
--> cli\src\run_script.rs:28:43
|
28 | let status = run_in_shell::run(script shell);
| -^^^^^ expected one of 8 possible tokens
| |
| help: missing ,

error: expected one of !, ), ,, ., ::, ?, {, or an operator, found shell
--> cli\src\subcommands..\run_script.rs:28:43
|
28 | let status = run_in_shell::run(script shell);
| -^^^^^ expected one of 8 possible tokens
| |
| help: missing ,

error: aborting due to 2 previous errors

Original diagnostics will follow.

warning: you seem to be trying to use match for destructuring a single pattern. Consider using if let
--> cli\src\main.rs:19:9
|
19 | / match color_eyre::install() {
20 | | Err() => {
21 | | eprintln!(
22 | | "{} failed to install {} panic hook, using release {}",
... |
29 | | _ => {}
30 | | }
| |
_______^
|
= note: #[warn(clippy::single_match)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try this
|
19 ~ if let Err(
) = color_eyre::install() {
20 + eprintln!(
21 + "{} failed to install {} panic hook, using release {}",
22 + "warn:".yellow().bold(),
23 + "color-eyre".italic(),
24 + "panic_hook".italic()
...

warning: vortex (bin "vortex" test) generated 1 warning
warning: vortex (bin "vortex") generated 1 warning (1 duplicate)
Finished dev [unoptimized + debuginfo] target(s) in 5.41s


also the space between "script shell" on this line:

28 |     let status = run_in_shell::run(script shell);

is what is in the output, but the comma is there

Reproducer

I tried this code: https://github.com/skyfallwastaken/vortex

I expected to see this happen:
No error

Instead, this happened:
Auto-derefs the argument, which causes errors

Version

rustc 1.60.0 (7737e0b5c 2022-04-04)
binary: rustc
commit-hash: 7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c
commit-date: 2022-04-04
host: x86_64-pc-windows-msvc
release: 1.60.0
LLVM version: 14.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-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