Document `cargo-clippy` feature
It is possible to use conditional compilation to prevent Clippy from evaluating certain code at all. Unfortunately, it was no longer documented anywhere. This adds a brief explanation of how to use the feature with conditional compilation, and mentions a few downsides.
Fixes#10220 — Ability to skip files or blocks entirely
changelog: none
<!-- changelog_checked -->
Update subtree sync docs for changes in rustc-dev-guide
Companion PR to https://github.com/rust-lang/rustc-dev-guide/pull/1653. That still keeps a `contributing.html` with an "External Contributions" section, so hopefully it won't be too disruptive.
changelog: none
Partial no-op refactoring of #9948
This contains some prep work for #9948 to keep that change to the minimum, and make it easier to review it.
This should be a noop, but it has some tests from that PR discussion, and should help in the future with the corner case format handling.
cc: `@Alexendoo` `@llogiq` `@xFrednet` as the 3 people who reviewed the parent PR
----
changelog: none
[arithmetic_side_effects] Fix#10583Fixes#10583
```
changelog: [`arithmetic_side_effects`]: Correctly handle division and module when the right-hand-side is unknown
```
Add suggestions to `extra_unused_type_parameters`
Change the `extra_unused_type_parameters` lint to provide machine applicable suggestions rather than just help messages. Exception to this are cases when any unused type parameters appear bounded in where clauses - for now I've deemed these cases unfixable and separated them out. Future work might be able to provide suggestions in these cases.
Also, added a test case for the `avoid_breaking_exported_api` config option.
r? `@flip1995`
changelog: [`extra_unused_type_parameters`]: Now provides fixable suggestions.
Gramar, and spelin kleanup
A few minor cleanups in various markdown files, mostly focusing on spelling and ignoring non-compilable codeblocks. Also a few markdown tables, etc.
P.S. I'm no grammar expert, do take with a grain of salt.
changelog: none
Ignore `file!()` macro in `print_literal`, `write_literal`
changelog: [`print_literal`], [`write_literal`]: Ignore the `file!()` macro
`file!()` expands to a string literal with its span set to that of the `file!()` callsite, but isn't marked as coming from an expansion. To fix this we make sure we actually find a string/char literal instead of assuming it's one and slicing
It would also ignore any other macros that result in the same situation, but that shouldn't be common as `proc_macro::Span::call_site()` returns a span that is marked as from expansion
Fixes#10544
Added the `[unnecessary_box_returns]` lint
fixes#5
I'm not confident in the name of this lint. Let me know if you can think of something better
---
changelog: New lint: ``[`unnecessary_box_returns`]``
[#9102](https://github.com/rust-lang/rust-clippy/pull/9102)
<!-- changelog_checked -->
In uninit checking, add fallback for polymorphic types
After #10520, we always assumed that polymorphic types do not allow to be left uninitialized. But we can do better, by peeking into polymorphic types and adding a few special cases for going through tuples, arrays (because the length may be polymorphic) and blanket allowing all unions (like MaybeUninit).
fixes#10551
changelog: [uninit_vec]: fix false positive for polymorphic types
changelog: [uninit_assumed_init]: fix false positive for polymorphic types
Fix allow attribute, items from macros in `items_after_statements`
Fixes#10540
changelog: [`items_after_statements`]: Fixes `#[allow(clippy::items_after_statements)]` when applied to an item, and ignores items after statements from different macro contexts
Move unnecessary_struct_initialization to nursery
changelog: none, assuming it makes into the same release as #10489
Mostly because of #10547 but there is also #10548
Make this function work with signed integer types by extracting the
underlying type and finding the min and max values.
Change the signature to make it more consistent:
- The range is now given as an `Expr` in order to extract the type
- The container's path is now passed, and only as an `Option` so that
the function can be called in the general case without a container
fix [`cast_possible_truncation`] offering wrong suggestion for casting float to integer
fixes: #10366
---
changelog: [`cast_possible_truncation`] Fix incorrect suggestions when casting from float types or to `_`
Add explanation on how to run `cargo-clippy` and `clippy-driver`
I don't know how this would be done on Windows or MacOS, feedback appreciated.
I did find this snippet for MacOS but it seems a little sketchy.
1d1e72308e/.github/workflows/clippy_bors.yml (L98-L102)
changelog: none
Wrap `transmutes_expressible_as_ptr_casts` suggestions in parentheses
changelog: [`transmutes_expressible_as_ptr_casts`]: Fix suggestion missing wrapping parentheses
Fixes#10449
r? `@Jarcho`
Is this the best way to go about this? `unused_parens` will catch the unnecessary ones but emitting them in the first place isn't ideal
suggest `try_into` when casting to wildcard type;
fix [`cast_possible_truncation`] suggesting useless parenthesis;
remove suggesting for float to float conversion in [`cast_possible_truncation`]
style nit
docs fix: unknown field `allowed-locales`
changelog: [`DISALLOWED_SCRIPT_IDENTS`]: Replace the nonexistent `allowed-locales` in the docs with `allowed-scripts`.
Use `split-debuginfo = "unpacked"` for debug builds
On Windows this has no effect as it's unsupported. On macOS the default set by cargo is already unpacked so no effect there either
For Linux it shaves a bit off the rebuild time, for me in the case of a simple `touch` + `cargo build` it goes from 12s to 10s
It saves a good amount of disk space too, on `aarch64-unknown-linux-gnu` it saves 1.2GB for a plain `cargo build`, 3GB when also running `cargo dev` and `cargo test --no-run -F internal`
r? `@flip1995`
changelog: none