In the current GitHub Actions CI/CD setup, the `deploy` job is not
triggered when a PR is enqueued in the merge queue but only when it is
merged. Since concurrency is not configured for this job, deployments
may fail for later PRs if multiple PRs are merged in quick succession.
(e.g. the deployment for [this
commit](c418714518)
was successful, but the deployment for [this
commit](0a141ab7b8)
that was pushed to `main` immediately afterward failed. (edit: the
latter deployment seems to be rerun))
changelog: none
r? flip1995
Replace the use of `Sugg::ast()` which prevented combining `if` together
when they contained comments by span manipulation.
A new configuration option `lint_commented_code`, which is `true` by
default, allows opting out from this behavior.
If reviewed on GitHub, the second commit of this PR is best looked at
side by side, with whitespace differences turned off.
changelog: [`collapsible_if`]: lint more cases
In #14116 we added a benchmarking option for Lintcheck, this commit adds
a new chapter to the book AND improves that option into a more usable
state.
It's recommended to review one commit at a time.
- **Document how to benchmark with lintcheck --perf**
- **Several improvements on lintcheck perf (desc.)**
- Now lintcheck perf deletes target directory after benchmarking,
benchmarking with a cache isn't very useful or telling of any
precise outcome.
- Support for benchmarking several times without having to do
a cargo clean.
- Compress perf.data
changelog: none
#2597 appears to be already resolved, so the applicability of `op_ref`
can be set to `MachineApplicable`.
close#2597
changelog: [`op_ref`]: set the applicability to `MachineApplicable`
Replace the use of `Sugg::ast()` which prevented combining `if`
together when they contained comments by span manipulation.
A new configuration option `lint_commented_code`, which is `true` by
default, opts out from this behavior.
Closes#11346.
Partially fix#9905. The first case in this issue is a little tricky as
the coerce does not happen in the borrowing.
changelog: [`borrow_deref_ref`]: fix wrong suggestions when coerce to
mut
By default, lintcheck will use the `clippy.toml` file found at the
toplevel of the repository (`CARGO_MANIFEST_DIR`). This file is meant
for configuration of Clippy applied to Clippy sources.
This creates a new `lintcheck/ci-config/clippy.toml` file which is used
by the CI when running lintcheck. By default this uses the default
Clippy configuration.
changelog: none
Closes#11617Closes#14368
Clippy gives wrong suggestions when the filter and then cannot be put
into closure directly. Since trying to transform these can be too
complicated, Clippy will simply warn but don't try to fix.
changelog: [`filter_map_bool_then`]: fix wrong suggestions when the
closure cannot be decompose directly
The configuration of the toolchain using `rust-toolchain` is only
retained for backward compatibility, and it is recommended to explicitly
specify the TOML format, as in `rust-toolchain.toml`.
r? flip1995
(This is because the change affects the sync process, and you are the
one responsible for sync (I believe).)
changelog: none
The applicability of `never_loop` is currently set to `Unspecified`, but
if the loop block does not contain `break` or `continue`, it can be
`MachineApplicable`.
changelog: [`never_loop`]: the applicability is now `MachineApplicable`
when the loop block contains neither `break` nor `continue`
fixes#13964
The lint `option_map_unwrap_or` used to have a similar issue in #10579,
so I borrowed its solution to fix this one.
changelog: [`option_if_let_else`]: fix FP when value partially moved
TLDR
```diff
- /// 01234
+ /// 01234
12345
```
Sometimes, in doc comments, there are 3 spaces + 1 instead of 4 spaces +
1.
To make it coherent with the rest of the clippy codebase, I `fd -t f -X
sed -E -i 's,///\s{4}(\S),/// \1,g'` and manually verified and fixed the
relevant part of code that had bad indentation.
### Example
```rs
/// fn a() {
/// 01234
/// }
```
Becomes
```rs
/// fn a() {
/// 01234
/// }
```
changelog: none
Commit efe3fe9b8c removed the ability for
`single_match` and `single_match_else` to trigger if comments were
present outside of the arms, as those comments would be lost while
rewriting the `match` expression.
This reinstates the lint, but prevents the suggestion from being applied
automatically in the presence of comments by using the `MaybeIncorrect`
applicability. Also, a note is added to the lint message to warn the
user about the need to preserve the comments if acting upon the
suggestion.
changelog: [`single_match`, `single_match_else`]: reinstate lint when
comments are inside the `match` but do not autofix the code
Fix#14418
I love this project but I (again) don't have the time nor energy at the
moment. Will go through my current assignments over time and still
review occasionally.
PS: sorry about the branch on upstream!
changelog: none
Fixes https://github.com/rust-lang/rust-clippy/issues/14175.
There are two "big" cases to handle: `.map(|x| x.to_string())` and
`.map(String::to_string)`. If the closure has more than one expression,
we should not suggest `.cloned()`.
changelog: Improve `string_to_string` lint in case it is in a map call
r? @samueltardieu
Rollup of 7 pull requests
Successful merges:
- #138384 (Move `hir::Item::ident` into `hir::ItemKind`.)
- #138508 (Clarify "owned data" in E0515.md)
- #138531 (Store test diffs in job summaries and improve analysis formatting)
- #138533 (Only use `DIST_TRY_BUILD` for try jobs that were not selected explicitly)
- #138556 (Fix ICE: attempted to remap an already remapped filename)
- #138608 (rustc_target: Add target feature constraints for LoongArch)
- #138619 (Flatten `if`s in `rustc_codegen_ssa`)
r? `@ghost`
`@rustbot` modify labels: rollup
I love this project but I (again) don't have the time nor energy at the moment. Will go through my current assignments over time and still review occasionally.
`hir::Item` has an `ident` field.
- It's always non-empty for these item kinds: `ExternCrate`, `Static`,
`Const`, `Fn`, `Macro`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`,
Trait`, TraitAalis`.
- It's always empty for these item kinds: `ForeignMod`, `GlobalAsm`,
`Impl`.
- For `Use`, it is non-empty for `UseKind::Single` and empty for
`UseKind::{Glob,ListStem}`.
All of this is quite non-obvious; the only documentation is a single
comment saying "The name might be a dummy name in case of anonymous
items". Some sites that handle items check for an empty ident, some
don't. This is a very C-like way of doing things, but this is Rust, we
have sum types, we can do this properly and never forget to check for
the exceptional case and never YOLO possibly empty identifiers (or
possibly dummy spans) around and hope that things will work out.
The commit is large but it's mostly obvious plumbing work. Some notable
things.
- A similar transformation makes sense for `ast::Item`, but this is
already a big change. That can be done later.
- Lots of assertions are added to item lowering to ensure that
identifiers are empty/non-empty as expected. These will be removable
when `ast::Item` is done later.
- `ItemKind::Use` doesn't get an `Ident`, but `UseKind::Single` does.
- `lower_use_tree` is significantly simpler. No more confusing `&mut
Ident` to deal with.
- `ItemKind::ident` is a new method, it returns an `Option<Ident>`. It's
used with `unwrap` in a few places; sometimes it's hard to tell
exactly which item kinds might occur. None of these unwraps fail on
the test suite. It's conceivable that some might fail on alternative
input. We can deal with those if/when they happen.
- In `trait_path` the `find_map`/`if let` is replaced with a loop, and
things end up much clearer that way.
- `named_span` no longer checks for an empty name; instead the call site
now checks for a missing identifier if necessary.
- `maybe_inline_local` doesn't need the `glob` argument, it can be
computed in-function from the `renamed` argument.
- `arbitrary_source_item_ordering::check_mod` had a big `if` statement
that was just getting the ident from the item kinds that had one. It
could be mostly replaced by a single call to the new `ItemKind::ident`
method.
- `ItemKind` grows from 56 to 64 bytes, but `Item` stays the same size,
and that's what matters, because `ItemKind` only occurs within `Item`.
Commit efe3fe9b8c removed the ability for
`single_match` and `single_match_else` to trigger if comments were
present outside of the arms, as those comments would be lost while
rewriting the `match` expression.
This reinstates the lint, but prevents the suggestion from being applied
automatically in the presence of comments by using the `MaybeIncorrect`
applicability. Also, a note is added to the lint message to warn the
user about the need to preserve the comments if acting upon the
suggestion.