-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Tracking Issue: Fixing broken lint suggestions #3630
Comments
I'm currently going through the list, writing down why each test doesn't work with |
Could you share what you write down here, for lints which you don't get to fix, so that future contributors have an easier start? |
@flip1995 Was already doing that, but I guess I can just edit my comment while I'm working through the list. Fixing this myself (PR: #3658)
Not yet fixed
Notes on the processThat's the whole list! Some of these are tricky cases:
|
…phansch Add several run rustfix annotations Adds `run-rustfix` to 18 of the tests from the tracking issue #3630. Each test has its own commit, to make reviewing easier (hopefully this is easier to review than 18 separate PRs). ## Changes - `cfg_attr_rustfmt`: Custom inner attributes are unstable. Let's disable the lint for inner attributes until [#54726](rust-lang/rust#54726) stabilizes - `collapsible_if`: unrelated cyclomatic_complexity warning that can be ignored - `duration_subsec`: Simply needed `#![allow(dead_code)]` - `excessive_precision`: Fixed by `#!allow(dead_code,unused_variables)` - `explicit_write`: Fixed by `#![allow(unused_imports)]` - `inconsistent_digit_grouping`: Avoid triggering `clippy::excessive_precision` lint - `infallible_destructuring_match`: Fixed by `#![allow(dead_code, unreachable_code, unused_variables)]` - `into_iter_on_ref`: Triggered unrelated `clippy::useless_vec` lint - `large_digit_groups`: Avoid triggering `clippy::excessive_precision` lint - `map_clone`: Fixed by `#![allow(clippy::iter_cloned_collect)]` - `mem_replace`: Suggestion causes import to be unused, fixed by `#![allow(unused_imports)]` - `precedence`: Allow some unrelated lints, and change out-of-range `0b1111_1111i8` literal - `redundant_field_names`: Allow dead code, and remove stabilized feature toggles - `replace_consts`: Fixed by `#![allow(unused_variables)]` - `starts_ends_with`: Fixed by `#![allow(unused_must_use)]` - `types`: Fixed by `#![allow(dead_code, unused_variables)]` - `unit_arg`: Fixed by `#[allow(unused_must_use)]` - `unnecessary_fold`: Fixed by adding type annotations and adding `#![allow(dead_code)]`
Sometimes this is unavoidable. If it is somehow possible we should maybe set all Clippy lints to warn/allow in the second pass, where the
If that's the case, the lint shouldn't be |
Fix `expect_fun_call` lint suggestions This commit corrects some bad suggestions produced by the `expect_fun_call` lint and enables `rust-fix` checking on the tests. Addresses #3630
This commit corrects some bad suggestions produced by the `expect_fun_call` lint and enables `rust-fix` checking on the tests. Addresses rust-lang#3630
This commit corrects some bad suggestions produced by the `expect_fun_call` lint and enables `rust-fix` checking on the tests. Addresses rust-lang#3630
Just a note. If the
to see. |
Enable rustfix for `useless_asref` lint tests cc #3630
Change while_let_loop applicability to HasPlaceholders The suggestion has been changed at some point to use `..` in the suggested code. Due to that we can't make the lint MachineApplicable anymore. cc #3630
Add run-rustfix for deref_addrof lint * renames `tests/ui/reference.{rs,stderr}` to `tests/ui/deref_addrof.{rs,stderr} * Moves small part of the testfile to a separate file as the lint triggered again on the fixed code (as intended) * Adds `// run-rustfix` to `tests/ui/deref_addrof.rs` cc #3630
Add run-rustfix for bool_comparison lint cc #3630
Posted #4558, will make more progress tomorrow on the plane. |
Add run-rustfix for wildcard_enum_match_arm lint cc #3630
Add run-rustfix for wildcard_enum_match_arm lint changelog: none cc #3630
Add run-rustfix for toplevel_ref_arg lint cc #3630
Add run-rustfix for toplevel_ref_arg lint changelog: none cc #3630
#4575 contains everything except op_ref. |
I updated #4575 to just mark op_ref as MaybeIncorrect for now. We're done! |
Awesome! thanks @Manishearth for finishing this up 🎉 |
Oh, as a next step, we could probably use the compiletest-rs rustfix coverage tracking to make sure all new |
It would be nice if compiletest had a mode that didn't force you to split files into rustfixable and non-rustfixable, where it tries to fix the code and then rechecks the file, only looking for errors which aren't fixable. We can also check in the |
Automatic Rustup
Now that we have rustfix integrated in our testsuite, we can use it to make sure that the suggestions we provide are valid rust code. This will also be useful once
cargo fix --clippy
is available to users.This tracking issue is meant to give an overview of how many lints currently provide incorrect suggestions.
Below is the list of tests that include
MachineApplicable
but incorrect suggestions. For this issue to be closed, we need to add// run-rustfix
to all of them and have the tests execute successfully.If you want to help out with this, feel free to select one file that is not fixed and leave a comment below. Smaller files are most likely easier to fix.
// run-rustfix
to the.rs
file runcargo test && tests/ui/update-all-references.sh && cargo test
. The tests for your file should fail and it should have generated a*.fixed
filerustc tests/ui/<your_test_file>.fixed
to see the exact compilation errorFiles that test lints which need to be fixed
tests/ui/assign_ops.rs
tests/ui/assign_ops2.rs
tests/ui/cmp_owned.rs
tests/ui/deref_addrof_double_trigger.rs
tests/ui/entry.rs
tests/ui/eq_op.rs
tests/ui/float_cmp.rs
tests/ui/float_cmp_const.rs
tests/ui/for_loop.rs
tests/ui/identity_conversion.rs
tests/ui/implicit_return.rs
tests/ui/inline_fn_without_body.rs
tests/ui/int_plus_one.rs
tests/ui/literals.rs
tests/ui/map_flatten.rs
tests/ui/mem_discriminant.rs
tests/ui/needless_borrow.rs
tests/ui/needless_borrowed_ref.rs
tests/ui/needless_collect.rs
tests/ui/needless_return.rs
tests/ui/non_copy_const.rs
tests/ui/op_ref.rs
(op_ref false positive with deref coercions when comparing #2597)tests/ui/option_map_unit_fn.rs
tests/ui/or_fun_call.rs
tests/ui/outer_expn_data.rs
tests/ui/range_plus_minus_one.rs
tests/ui/redundant_closure_call.rs
tests/ui/redundant_pattern_matching.rs
tests/ui/rename.rs
tests/ui/renamed_builtin_attr.rs
tests/ui/redundant_static_lifetimes.rs
tests/ui/result_map_unit_fn.rs
Add run-rustfix for result_map_unit_fn lint #4571tests/ui/short_circuit_statement.rs
tests/ui/strings.rs
tests/ui/toplevel_ref_arg.rs
Add run-rustfix for toplevel_ref_arg lint #4567tests/ui/unnecessary_clone.rs
tests/ui/unnecessary_operation.rs
tests/ui/wildcard_enum_match_arm.rs
Add run-rustfix for wildcard_enum_match_arm lint #4562tests/ui/useless_attribute.rs
The text was updated successfully, but these errors were encountered: