Skip to content

Syntax to apply only machine-applicable fixes #351

@smoelius

Description

@smoelius

I am try to add two suggestions to Clippy's return_self_not_must_use lint:

  • a suggestion to add #[must_use] to the function, which should be machine applicable
  • a suggestion to add #[must_use] to Self, which should be unspecified

The problem I face is that ui_test applies both suggestions. How do I get it to apply just the machine applicable suggestion?

I found this code in ui_test:

fn post_test_action(
&self,
config: &TestConfig,
output: &Output,
build_manager: &BuildManager,
) -> Result<(), Errored> {
let global_rustfix = match config.exit_status()? {
Some(Spanned {
content: 101 | 0, ..
}) => RustfixMode::Disabled,
_ => *self,
};
let output = output.clone();
let no_run_rustfix = config.find_one_custom("no-rustfix")?;
let fixes = if no_run_rustfix.is_none() && global_rustfix.enabled() {

Adding a dbg!(*self) suggests that *self is Everything. But I cannot figure out how to set *self to something else.

Also, Clippy's redundant_clone ui test has the following line, but I'm not sure it does anything: https://github.com/rust-lang/rust-clippy/blob/cb56d63b8853fc052df6539da14c2c1a7e2be96e/tests/ui/redundant_clone.rs#L1

If I change that line to // rustfix-only-machine-applicablexxx and run TESTNAME=redundant_clone cargo uibless, the corresponding line in the .fixed file changes, but nothing else does.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions