Commit Graph

13649 Commits

Author SHA1 Message Date
Fridtjof Stoldt
3bd0ac7a8d
Update lint description of clippy::manual_bits to include the as usize cast 2022-04-14 07:02:59 +02:00
xFrednet
ba15cdd3c1
Add usize cast to clippy::manual_bits suggestion 2022-04-13 19:31:24 +02:00
bors
190f0deac8 Auto merge of #8450 - Jarcho:unsafe_blocks_8449, r=giraffate
Rework `undocumented_unsafe_blocks`

fixes: #8264
fixes: #8449

One thing came up while working on this. Currently comments on the same line are supported like so:

```rust
/* SAFETY: reason */ unsafe {}
```

Is this worth supporting at all? Anything other than a couple of words doesn't really fit well.

edit: [zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/.60undocumented_unsafe_blocks.60.20same.20line.20comment)

changelog: Don't lint `undocumented_unsafe_blocks` when the unsafe block comes from a proc-macro.
changelog: Don't lint `undocumented_unsafe_blocks` when the preceding line has a safety comment and the unsafe block is a sub-expression.
2022-04-04 13:07:26 +00:00
bors
1cec8b30fa Auto merge of #8594 - FoseFx:unit_like_struct_brackets, r=giraffate
add `empty_structs_with_brackets`

<!-- Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only includes internal changes, you can just write
`changelog: none`. Otherwise, please write a short comment
explaining your change. Also, it's helpful for us that
the lint name is put into brackets `[]` and backticks `` ` ` ``,
e.g. ``[`lint_name`]``.

If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
your PR is merged.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- \[ ] Followed [lint naming conventions][lint_naming]
- \[ ] Added passing UI tests (including committed `.stderr` file)
- \[ ] `cargo test` passes locally
- \[ ] Executed `cargo dev update_lints`
- \[ ] Added lint documentation
- \[ ] Run `cargo dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

Delete this line and everything above before opening your PR.

--

*Please write a short comment explaining your change (or "none" for internal only changes)*
-->
Closes #8591

I'm already sorry for the massive diff 😅

changelog: New lint [`empty_structs_with_brackets`]
2022-04-04 07:28:36 +00:00
Max Baumann
58833e58a6
is_unit_like_struct -> has_brackets 2022-04-04 08:48:49 +02:00
bors
85b88be2a4 Auto merge of #8605 - Jarcho:remove-deps, r=xFrednet
Remove deps

This remove both `regex` and `cargo_metadata` as dependencies making `clippy_dev` compile ~3x faster (~46s -> ~16s locally). `cargo_metadata` was used to extract the `version` field from `Cargo.toml`, which is done trivially without that. `regex` was used to parse `define_clippy_lint` in `update_lints` which is now done using `rustc_lexer`. This isn't any simpler, but it compiles ~15s faster and runs ~3x faster (~2.1s -> ~0.7s locally).

The next biggest offenders to compile times are `clap` and `winapi` on windows. `clap` could be removed, but re-implementing enough is probably more work than it's worth. `winapi` is used by `opener` and `walkdir` so it's stuck there.

changelog: none
2022-04-02 10:42:12 +00:00
bors
baaddf2b84 Auto merge of #8611 - Alexendoo:module-files-relative-paths, r=llogiq
Handle relative paths in module_files lints

The problem being that when clippy is run in the project's directory `lp` would be a relative path, this wasn't caught by the tests as there `lp` is an absolute path. Being a relative path it did not start with `trim_src_path` and so was ignored

Also allowed the removal of some `.to_os_string`/`.to_owned`s

changelog: Fixes [`self_named_module_files`] and [`mod_module_files`] not linting

Fixes #8123, cc `@DevinR528`
2022-04-02 07:06:03 +00:00
Jason Newcomb
17c8bee95a Add a couple of examples to undocumented_unsafe_blocks 2022-04-02 00:46:45 -04:00
Jason Newcomb
ae5af0cd1a Remove cargo_metadata dependency from clippy 2022-04-01 23:18:47 -04:00
Jason Newcomb
7025283f3e Remove cargo_metadata dependency from clippy_dev 2022-04-01 23:18:47 -04:00
Jason Newcomb
b3f8415032 Remove regex dependency from clippy_dev 2022-04-01 23:18:47 -04:00
bors
f6b29923c6 Auto merge of #8616 - pitaj:single_element_loop_arrays, r=llogiq
single_element_loop: handle arrays for Edition2021

changelog: [`single_element_loop`] handle arrays in Edition 2021, handle `.iter_mut()` and `.into_iter()`, and wrap in parens if necessary
2022-04-01 18:45:49 +00:00
Peter Jaszkowiak
3bbb3e3329 single_element_loop: handle arrays for Edition2021
also handle `.iter_mut()`, `.into_iter()`,
and wrapping in parens if necessary
2022-04-01 00:04:19 -06:00
bors
db5739ac55 Auto merge of #8610 - SabrinaJewson:transmute-int-to-char-const, r=xFrednet
Don't warn int-to-char transmutes in const contexts

changelog: Don't warn ``[`transmute_int_to_char`]`` in const contexts

fixes: #8379
2022-03-30 20:23:03 +00:00
Max Baumann
0434b856ac pedantic -> restriction 2022-03-30 20:13:16 +02:00
Max Baumann
49a9740b09 update description
Co-authored-by: giraffate <f.seasons017@gmail.com>
2022-03-30 20:13:16 +02:00
Max Baumann
e552267db3 style -> pedantic 2022-03-30 20:13:16 +02:00
Max Baumann
2953cba116 unit_like_struct_brackets -> empty_structs_with_brackets 2022-03-30 20:13:16 +02:00
Max Baumann
37d5a6264c changes after review 2022-03-30 20:12:58 +02:00
Max Baumann
33383a418d use span_suggestion_hidden 2022-03-30 20:12:58 +02:00
Max Baumann
7192297c28 additional checks for conditionally compiled code 2022-03-30 20:12:58 +02:00
Max Baumann
1a5ff38f92 fix godfood test 2022-03-30 20:12:58 +02:00
Max Baumann
315521afc6 fix uitests 2022-03-30 20:12:58 +02:00
Max Baumann
9be3945be7 fix existing clippy tests 2022-03-30 20:12:58 +02:00
Max Baumann
528ada958b add unit_like_struct_brackets 2022-03-30 20:12:58 +02:00
SabrinaJewson
d6f05c6a89
Don't warn int-to-char transmutes in const contexts 2022-03-30 18:47:50 +01:00
Alex Macleod
10a6d872d4 Handle relative paths in module_files lints 2022-03-30 18:44:04 +01:00
bors
c0a5693abc Auto merge of #8602 - giraffate:fix_ice_for_iter_overeager_cloned, r=llogiq
Fix ICE for `iter_overeager_cloned`

Fix https://github.com/rust-lang/rust-clippy/issues/8527

changelog: Fix ICE for [`iter_overeager_cloned`]
2022-03-30 17:12:24 +00:00
bors
fe7254ff6f Auto merge of #8576 - smoelius:crate_in_macro_def, r=llogiq
Add `crate_in_macro_def` lint

This PR adds a lint to check for `crate` as opposed to `$crate` used in a macro definition.

I think this can close #4798. That issue focused on the case where the macro author "imports something into said macro."

But I think use of `crate` is likely to be a bug whether it appears in a `use` statement or not. There could be some use case I am failing to see, though. (cc: `@nilscript` `@flip1995)`

changelog: `crate_in_macro_def`
2022-03-30 16:57:24 +00:00
Samuel E. Moelius III
aaf04dc043 Fix error message in crate_in_macro_def.stderr 2022-03-30 12:52:31 -04:00
Samuel E. Moelius III
d6eb82c0a8 Move crate_in_macro_def to suspicious 2022-03-30 12:40:53 -04:00
Samuel Moelius
75dc406e84
Update clippy_lints/src/crate_in_macro_def.rs
Co-authored-by: llogiq <bogusandre@gmail.com>
2022-03-30 12:40:44 -04:00
Samuel Moelius
abc221e7f6
Update clippy_lints/src/crate_in_macro_def.rs
Co-authored-by: llogiq <bogusandre@gmail.com>
2022-03-30 12:40:25 -04:00
Samuel Moelius
9b304533ab
Update clippy_lints/src/crate_in_macro_def.rs
Co-authored-by: llogiq <bogusandre@gmail.com>
2022-03-30 12:40:16 -04:00
bors
df7c253d39 Auto merge of #8597 - giraffate:fix_changelog, r=xFrednet
Fix version in changelog

changelog: none
2022-03-30 16:25:42 +00:00
bors
0031f69999 Auto merge of #8592 - c410-f3r:stuff, r=flip1995
Do not fire `panic` in a constant environment

Let rustc handle panics in constant environments.

Since https://github.com/rust-lang/rust-clippy/issues/8348 I thought that such modification would require a lot of work but thanks to https://github.com/rust-lang/rust-clippy/pull/8588 I now know that it is not the case.

changelog: [`panic`]: No longer lint in constant context. `rustc` already handles this.
2022-03-30 16:04:14 +00:00
bors
e1ddf29ee3 Auto merge of #8586 - pitaj:fix-8378, r=flip1995
specify serde version compatible with codebase

fix #8378

changelog: none
2022-03-30 15:46:48 +00:00
bors
d9819c3b8d Auto merge of #8584 - Alexendoo:map-unit-fn-context, r=Manishearth
Provide suggestion context in map_unit_fn

Fixes #8569

changelog: Fix incorrect suggestion for `option_map_unit_fn` , `result_map_unit_fn`
2022-03-30 15:25:37 +00:00
Takayuki Nakata
c22b7b8814 Fix ICE for iter_overeager_cloned 2022-03-29 21:51:37 +09:00
Takayuki Nakata
e5fa22e350 Fix version in changelog 2022-03-28 21:48:34 +09:00
Samuel E. Moelius III
cb307bbfcd Address review comments 2022-03-28 04:48:12 -04:00
bors
6206086dd5 Auto merge of #8487 - dswij:8478, r=giraffate
[`map_identity`] checks for needless `map_err`

Closes #8478

changelog: [`map_identity`] checks for needless `map_err`
2022-03-28 00:25:45 +00:00
bors
59c0f29916 Auto merge of #8519 - tysg:redundant-modulo, r=giraffate
Check if lhs < rhs in modulos in `identity_op`

Fixes #8508

changelog: [`identity_op`] now checks for modulos, e.g. `1 % 3`
2022-03-28 00:11:32 +00:00
Tianyi Song
52b563b283 Emit lint when rhs is negative 2022-03-27 21:49:38 +08:00
Caio
af8ed04e09 Rustfmt 2022-03-26 15:48:17 -03:00
Caio
c687f6575f Do not fire panic in a constant environment 2022-03-26 15:39:21 -03:00
Peter Jaszkowiak
bca047dcea specify serde version compatible with codebase 2022-03-25 16:39:15 -06:00
Alex Macleod
610db04222 Provide suggestion context in map_unit_fn 2022-03-25 20:47:54 +00:00
bors
8ebe766695 Auto merge of #8582 - xFrednet:0000-changelog-1-60, r=Manishearth
Changelog for Rust 1.60.0 🦀 (Kudos to everyone who contributed!)

As always, I'm impressed by how much stuff happened in just one release. Seriously, kudos to everyone who contributed.

changelog: none
2022-03-25 17:05:05 +00:00
xFrednet
55feb4c4aa
Changelog for Rust 1.60.0 🦀 2022-03-25 17:58:39 +01:00