]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #8619 - pitaj:fix-6973, r=giraffate
bors [Fri, 8 Apr 2022 00:37:56 +0000 (00:37 +0000)]
Auto merge of #8619 - pitaj:fix-6973, r=giraffate

ignore `&x | &y` in unnested_or_patterns

replacing it with `&(x | y)` is actually more characters

Fixes #6973

changelog: [`unnested_or_patterns`] ignore `&x | &y`, nesting would result in more characters

2 years agoAuto merge of #8657 - flip1995:raw_lint_desc, r=flip1995
bors [Thu, 7 Apr 2022 17:11:26 +0000 (17:11 +0000)]
Auto merge of #8657 - flip1995:raw_lint_desc, r=flip1995

Allow raw lint descriptions

update_lints now understands raw strings in declare_clippy_lint descriptions.

Supersedes  #8655

cc `@Alexendoo` thanks for addressing this so quickly. I build a little bit simpler version of your patch. I don't think it really matters what `Literal` we're trying to tokenize, since we assume later, that it is some sort of `str`.

changelog: none

2 years agoAllow raw lint descriptions
flip1995 [Thu, 7 Apr 2022 17:05:20 +0000 (18:05 +0100)]
Allow raw lint descriptions

update_lints now understands raw strings in declare_clippy_lint
descriptions.

Co-authored-by: Alex Macleod <alex@macleod.io>
2 years agoAuto merge of #8656 - flip1995:rustup, r=flip1995
bors [Thu, 7 Apr 2022 15:30:27 +0000 (15:30 +0000)]
Auto merge of #8656 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump changelog stable version -> 1.60
flip1995 [Thu, 7 Apr 2022 15:26:43 +0000 (16:26 +0100)]
Bump changelog stable version -> 1.60

2 years agoBump nightly version -> 2022-04-07
flip1995 [Thu, 7 Apr 2022 15:24:55 +0000 (16:24 +0100)]
Bump nightly version -> 2022-04-07

2 years agoBump Clippy Version -> 0.1.62
flip1995 [Thu, 7 Apr 2022 15:24:33 +0000 (16:24 +0100)]
Bump Clippy Version -> 0.1.62

2 years agoFix internal::INVALID_PATHS lint
flip1995 [Thu, 7 Apr 2022 15:24:10 +0000 (16:24 +0100)]
Fix internal::INVALID_PATHS lint

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 7 Apr 2022 14:44:37 +0000 (15:44 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #8635 - pbor:unsigned-abs, r=giraffate
bors [Thu, 7 Apr 2022 13:17:28 +0000 (13:17 +0000)]
Auto merge of #8635 - pbor:unsigned-abs, r=giraffate

Add a lint to detect cast to unsigned for abs() and suggest unsigned_…

…abs()

changelog: Add a [`cast_abs_to_unsigned`] that checks for uses of `abs()` that are cast to the corresponding unsigned integer type and suggest to replace them with `unsigned_abs()`.

2 years agoAuto merge of #8646 - Alexendoo:option-as-deref-mut, r=giraffate
bors [Thu, 7 Apr 2022 13:00:15 +0000 (13:00 +0000)]
Auto merge of #8646 - Alexendoo:option-as-deref-mut, r=giraffate

Fix `as_deref_mut` false positives in `needless_option_as_deref`

Also moves it into `methods/`

Fixes #7846
Fixes #8047

changelog: [`needless_option_as_deref`]: No longer lints for `as_deref_mut` on Options that cannot be moved

supersedes #8064

2 years agoFix `as_deref_mut` false positives in `needless_option_as_deref`
Alex Macleod [Wed, 6 Apr 2022 14:35:49 +0000 (15:35 +0100)]
Fix `as_deref_mut` false positives in `needless_option_as_deref`

Also moves the lint to the methods directory

2 years agoconf: fix lint name in comment
Paolo Borelli [Thu, 7 Apr 2022 09:29:02 +0000 (11:29 +0200)]
conf: fix lint name in comment

The lint name is ERR_EXPECT, not EXPECT_ERR

2 years agonew lint cast_abs_to_unsigned
Paolo Borelli [Mon, 4 Apr 2022 16:38:38 +0000 (18:38 +0200)]
new lint cast_abs_to_unsigned

Add a lint to detect cast to unsigned for abs() and suggest
unsigned_abs() to avoid panic when called on MIN.

2 years agoAuto merge of #8630 - Jarcho:forget_non_drop, r=Manishearth
bors [Wed, 6 Apr 2022 23:04:20 +0000 (23:04 +0000)]
Auto merge of #8630 - Jarcho:forget_non_drop, r=Manishearth

Add lints `drop_non_drop` and `forget_non_drop`

fixes #1897

changelog: Add lints `drop_non_drop` and `forget_non_drop`

2 years agoAuto merge of #8606 - InfRandomness:err()-expect()-lint, r=xFrednet
bors [Wed, 6 Apr 2022 18:07:56 +0000 (18:07 +0000)]
Auto merge of #8606 - InfRandomness:err()-expect()-lint, r=xFrednet

Add [`err_expect`] lint

[`expect_err`] lint

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

Fixes https://github.com/rust-lang/rust-clippy/issues/1435

changelog: Added a lint to detect usage of .err().expect()

2 years agoFix mistakes in documentation :
infrandomness [Wed, 6 Apr 2022 17:24:49 +0000 (19:24 +0200)]
Fix mistakes in documentation :

- err() was meant to be employed instead of ok()
- wraps comment

2 years agoAdd .err().expect() lint
InfRandomness [Tue, 29 Mar 2022 17:19:16 +0000 (19:19 +0200)]
Add .err().expect() lint

2 years agoAuto merge of #8549 - J-ZhengLi:issue8542, r=llogiq
bors [Wed, 6 Apr 2022 17:23:14 +0000 (17:23 +0000)]
Auto merge of #8549 - J-ZhengLi:issue8542, r=llogiq

fix FP in lint `[needless_match]`

fixes: #8542
fixes: #8551
fixes: #8595
fixes: #8599

---

changelog: check for more complex custom type, and ignore type coercion in [`needless_match`]

2 years agoAuto merge of #8644 - yoav-lavi:squashed-master, r=flip1995
bors [Wed, 6 Apr 2022 15:13:43 +0000 (15:13 +0000)]
Auto merge of #8644 - yoav-lavi:squashed-master, r=flip1995

update unnecessary_join documentation

changelog: none

Updates the description of `unnecessary_join` in accordance with https://github.com/rust-lang/rust-clippy/pull/8579#issuecomment-1089969859. I've also added a line regarding differences in assembly output, please let me know if it should also make it in.

2 years agoupdate unnecessary_join documentation
Yoav Lavi [Wed, 6 Apr 2022 13:59:38 +0000 (15:59 +0200)]
update unnecessary_join documentation

2 years agocode refractor for `[needless_match]`
J-ZhengLi [Wed, 6 Apr 2022 12:44:54 +0000 (20:44 +0800)]
code refractor for `[needless_match]`

2 years agoAuto merge of #8612 - SabrinaJewson:suggest-from-utf8-unchecked-in-const, r=flip1995
bors [Wed, 6 Apr 2022 09:32:51 +0000 (09:32 +0000)]
Auto merge of #8612 - SabrinaJewson:suggest-from-utf8-unchecked-in-const, r=flip1995

Suggest from_utf8_unchecked in const contexts

Unfortunately I couldn't figure out how to check whether a given expression is in an `unsafe` context or not, so I just unconditionally emit the wrapping `unsafe {}` block in the suggestion. If there is an easy way to get it to work better then I would love to hear it.

changelog: Suggest `from_utf8_unchecked` instead of `from_utf8` in const contexts for ``[`transmute_bytes_to_str`]``

refs: #8379

2 years agoReport `from_utf8` suggestion as maybe incorrect
Sabrina Jewson [Wed, 6 Apr 2022 09:14:20 +0000 (10:14 +0100)]
Report `from_utf8` suggestion as maybe incorrect

Co-authored-by: Philipp Krones <hello@philkrones.com>
2 years agoAuto merge of #8596 - Jaic1:unnecessary_cast, r=flip1995
bors [Wed, 6 Apr 2022 08:27:03 +0000 (08:27 +0000)]
Auto merge of #8596 - Jaic1:unnecessary_cast, r=flip1995

Fix unnecessary_cast suggestion for type aliasses

Fix #6923. The [`unnecessary_cast`] lint now will skip casting to non-primitive type.

changelog: fix lint [`unnecessary_cast `]

2 years agoAuto merge of #8588 - pitaj:fix-8348, r=flip1995
bors [Wed, 6 Apr 2022 08:13:26 +0000 (08:13 +0000)]
Auto merge of #8588 - pitaj:fix-8348, r=flip1995

`indexing_slicing` should not fire if a valid array index comes from a constant function that is evaluated at compile-time

fix #8348

changelog: [`indexing_slicing`] fewer false positives in `const` contexts and with `const` indices

2 years agoAuto merge of #8636 - flip1995:release_changelog_quick_update, r=xFrednet
bors [Tue, 5 Apr 2022 13:03:16 +0000 (13:03 +0000)]
Auto merge of #8636 - flip1995:release_changelog_quick_update, r=xFrednet

Add documentation on how to do a minimal changelog update

This ensures that the link to the Clippy version in the Rust release
blog post works correctly. The additional `(beta)` behind the previous
beta version breaks that link otherwise.

[Rendered](https://github.com/flip1995/rust-clippy/blob/release_changelog_quick_update/doc/release.md)

changelog: none

2 years agoAuto merge of #8403 - nerdypepper:fix/diagnostic-message-mispelling, r=flip1995,Manis...
bors [Tue, 5 Apr 2022 10:07:13 +0000 (10:07 +0000)]
Auto merge of #8403 - nerdypepper:fix/diagnostic-message-mispelling, r=flip1995,Manishearth

fix misspelling in diagnostic message of `bytes_nth`

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: fix misspelling in diagnostic message in ``[`bytes_nth`]``

2 years agofix mispelling in diagnostic message of bytes_nth
Akshay [Tue, 8 Feb 2022 11:21:02 +0000 (16:51 +0530)]
fix mispelling in diagnostic message of bytes_nth

2 years agoAuto merge of #8620 - Alexendoo:test-fmt-first, r=flip1995
bors [Tue, 5 Apr 2022 09:50:53 +0000 (09:50 +0000)]
Auto merge of #8620 - Alexendoo:test-fmt-first, r=flip1995

Run fmt test before compile-test/dogfood

I seem to always forget to run `cargo dev fmt` before doing a test. This lets it fail fast rather than going through the much longer compile-test/dogfood tests first

changelog: none

2 years agoAuto merge of #8607 - Alexendoo:cargo-dev-lint-dir, r=flip1995,giraffate
bors [Tue, 5 Apr 2022 09:33:38 +0000 (09:33 +0000)]
Auto merge of #8607 - Alexendoo:cargo-dev-lint-dir, r=flip1995,giraffate

Allow running `cargo dev lint` on a package directory

Allows you run the local clippy in a specified directory, e.g. allowing

```sh
# Lint a ui-cargo test
cargo dev lint tests/ui-cargo/wildcard_dependencies/fail

# Lint some other project
cargo dev lint ~/my-project
```

The `target` directory is set to a tempdir which isn't ideal for medium/large projects as it would be compiled from scratch. This is to avoid cached clippy messages where you `cargo dev lint dir`, change something in clippy, and run `cargo dev lint dir` again

changelog: Dev: `cargo dev lint` can now be run on a package directory

2 years agoAdd documentation on how to do a minimal changelog update
flip1995 [Tue, 5 Apr 2022 09:24:32 +0000 (10:24 +0100)]
Add documentation on how to do a minimal changelog update

This ensures that the link to the Clippy version in the Rust release
blog post works correctly. The additional `(beta)` behind the previous
beta version breaks that link otherwise.

2 years agosession: opt for enabling directionality markers
David Wood [Sun, 3 Apr 2022 03:53:01 +0000 (04:53 +0100)]
session: opt for enabling directionality markers

Add an option for enabling and disabling Fluent's directionality
isolation markers in output. Disabled by default as these can render in
some terminals and applications.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoerrors: implement sysroot/testing bundle loading
David Wood [Mon, 28 Mar 2022 08:36:20 +0000 (09:36 +0100)]
errors: implement sysroot/testing bundle loading

Extend loading of Fluent bundles so that bundles can be loaded from the
sysroot based on the language requested by the user, or using a nightly
flag.

Sysroot bundles are loaded from `$sysroot/share/locale/$locale/*.ftl`.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoerrors: implement fallback diagnostic translation
David Wood [Sat, 26 Mar 2022 07:27:43 +0000 (07:27 +0000)]
errors: implement fallback diagnostic translation

This commit updates the signatures of all diagnostic functions to accept
types that can be converted into a `DiagnosticMessage`. This enables
existing diagnostic calls to continue to work as before and Fluent
identifiers to be provided. The `SessionDiagnostic` derive just
generates normal diagnostic calls, so these APIs had to be modified to
accept Fluent identifiers.

In addition, loading of the "fallback" Fluent bundle, which contains the
built-in English messages, has been implemented.

Each diagnostic now has "arguments" which correspond to variables in the
Fluent messages (necessary to render a Fluent message) but no API for
adding arguments has been added yet. Therefore, diagnostics (that do not
require interpolation) can be converted to use Fluent identifiers and
will be output as before.

2 years agospan: move `MultiSpan`
David Wood [Thu, 24 Mar 2022 02:03:04 +0000 (02:03 +0000)]
span: move `MultiSpan`

`MultiSpan` contains labels, which are more complicated with the
introduction of diagnostic translation and will use types from
`rustc_errors` - however, `rustc_errors` depends on `rustc_span` so
`rustc_span` cannot use types like `DiagnosticMessage` without
dependency cycles. Introduce a new `rustc_error_messages` crate that can
contain `DiagnosticMessage` and `MultiSpan`.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoAuto merge of #8633 - xFrednet:8627-escape-mod-rs, r=Manishearth
bors [Mon, 4 Apr 2022 20:35:44 +0000 (20:35 +0000)]
Auto merge of #8633 - xFrednet:8627-escape-mod-rs, r=Manishearth

Escape `mod.rs` file mentions to avoid links in our documentation

As the title says nothing special, still a fun fix :)

Closes: #8627
changelog: none

2 years agoEscape `mod.rs` file mentions to avoid links in our documentation
xFrednet [Mon, 4 Apr 2022 19:06:53 +0000 (21:06 +0200)]
Escape `mod.rs` file mentions to avoid links in our documentation

We can read them if they want to start sponsoring us xD

2 years agoAuto merge of #8632 - Jarcho:cast_ptr_alignment, r=llogiq
bors [Mon, 4 Apr 2022 18:47:27 +0000 (18:47 +0000)]
Auto merge of #8632 - Jarcho:cast_ptr_alignment, r=llogiq

Don't lint `cast_ptr_alignment` when used for unaligned reads and writes

fixes #2881

Ideally this would trace the usage of the value rather than only looking at the parent expression, but that would require dataflow analysis. e.g.
```rust
let x = ptr as *const u16;
c.read_unaligned(x);
```

Arch specific intrinsic functions need to be checked for ones which could take an unaligned pointer. This can be another PR.

changelog: Don't lint `cast_ptr_alignment` when used for unaligned reads and writes

2 years agoDon't lint `cast_ptr_alignment` when used for unaligned reads and writes
Jason Newcomb [Mon, 4 Apr 2022 17:54:52 +0000 (13:54 -0400)]
Don't lint `cast_ptr_alignment` when used for unaligned reads and writes

2 years agoAdd lints `drop_non_drop` and `forget_non_drop`
Jason Newcomb [Mon, 4 Apr 2022 15:56:56 +0000 (11:56 -0400)]
Add lints `drop_non_drop` and `forget_non_drop`

2 years agoAuto merge of #8450 - Jarcho:unsafe_blocks_8449, r=giraffate
bors [Mon, 4 Apr 2022 13:07:26 +0000 (13:07 +0000)]
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.

2 years agoAuto merge of #8594 - FoseFx:unit_like_struct_brackets, r=giraffate
bors [Mon, 4 Apr 2022 07:28:36 +0000 (07:28 +0000)]
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 :sweat_smile:

changelog: New lint [`empty_structs_with_brackets`]

2 years agois_unit_like_struct -> has_brackets
Max Baumann [Mon, 4 Apr 2022 06:48:49 +0000 (08:48 +0200)]
is_unit_like_struct -> has_brackets

2 years agoRun fmt test before compile-test/dogfood
Alex Macleod [Sat, 2 Apr 2022 11:34:06 +0000 (12:34 +0100)]
Run fmt test before compile-test/dogfood

2 years agoAuto merge of #8605 - Jarcho:remove-deps, r=xFrednet
bors [Sat, 2 Apr 2022 10:42:12 +0000 (10:42 +0000)]
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

2 years agoAuto merge of #8611 - Alexendoo:module-files-relative-paths, r=llogiq
bors [Sat, 2 Apr 2022 07:06:03 +0000 (07:06 +0000)]
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`

2 years agoAdd a couple of examples to `undocumented_unsafe_blocks`
Jason Newcomb [Sat, 2 Apr 2022 04:46:45 +0000 (00:46 -0400)]
Add a couple of examples to `undocumented_unsafe_blocks`

2 years agoignore `&x | &y` in unnested_or_patterns
Peter Jaszkowiak [Sat, 2 Apr 2022 04:36:30 +0000 (22:36 -0600)]
ignore `&x | &y` in unnested_or_patterns

replacing it with `&(x | y)` is actually more characters

2 years agoRemove cargo_metadata dependency from clippy
Jason Newcomb [Tue, 29 Mar 2022 12:57:02 +0000 (08:57 -0400)]
Remove cargo_metadata dependency from clippy

2 years agoRemove cargo_metadata dependency from clippy_dev
Jason Newcomb [Tue, 29 Mar 2022 12:32:12 +0000 (08:32 -0400)]
Remove cargo_metadata dependency from clippy_dev

2 years agoRemove regex dependency from clippy_dev
Jason Newcomb [Tue, 29 Mar 2022 02:08:04 +0000 (22:08 -0400)]
Remove regex dependency from clippy_dev

2 years agoAuto merge of #8616 - pitaj:single_element_loop_arrays, r=llogiq
bors [Fri, 1 Apr 2022 18:45:49 +0000 (18:45 +0000)]
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

2 years agosingle_element_loop: handle arrays for Edition2021
Peter Jaszkowiak [Fri, 1 Apr 2022 06:04:19 +0000 (00:04 -0600)]
single_element_loop: handle arrays for Edition2021

also handle `.iter_mut()`, `.into_iter()`,
and wrapping in parens if necessary

2 years agoDon't unnecessarily suggest unsafe block
SabrinaJewson [Fri, 1 Apr 2022 05:32:22 +0000 (06:32 +0100)]
Don't unnecessarily suggest unsafe block

2 years agoAuto merge of #95501 - Dylan-DPC:rollup-arx6sdc, r=Dylan-DPC
bors [Thu, 31 Mar 2022 00:29:54 +0000 (00:29 +0000)]
Auto merge of #95501 - Dylan-DPC:rollup-arx6sdc, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #93901 (Stabilize native library modifier syntax and the `whole-archive` modifier specifically)
 - #94806 (Fix `cargo run tidy`)
 - #94869 (Add the generic_associated_types_extended feature)
 - #95011 (async: Give predictable name to binding generated from .await expressions.)
 - #95251 (Reduce max hash in raw strings from u16 to u8)
 - #95298 (Fix double drop of allocator in IntoIter impl of Vec)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #95251 - GrishaVar:hashes-u16-to-u8, r=dtolnay
Dylan DPC [Wed, 30 Mar 2022 22:26:31 +0000 (00:26 +0200)]
Rollup merge of #95251 - GrishaVar:hashes-u16-to-u8, r=dtolnay

Reduce max hash in raw strings from u16 to u8

[Relevant discussion](https://rust-lang.zulipchat.com/#narrow/stream/237824-t-lang.2Fdoc/topic/Max.20raw.20string.20delimiters)

2 years agoAuto merge of #95436 - cjgillot:static-mut, r=oli-obk
bors [Wed, 30 Mar 2022 22:09:56 +0000 (22:09 +0000)]
Auto merge of #95436 - cjgillot:static-mut, r=oli-obk

Remember mutability in `DefKind::Static`.

This allows to compute the `BodyOwnerKind` from `DefKind` only, and
removes a direct dependency of some MIR queries onto HIR.

As a side effect, it also simplifies metadata, since we don't need 4
flavours of `EntryKind::*Static` any more.

2 years agoSuggest from_utf8_unchecked in const contexts
SabrinaJewson [Wed, 30 Mar 2022 18:31:50 +0000 (19:31 +0100)]
Suggest from_utf8_unchecked in const contexts

2 years agoAuto merge of #8610 - SabrinaJewson:transmute-int-to-char-const, r=xFrednet
bors [Wed, 30 Mar 2022 20:23:03 +0000 (20:23 +0000)]
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

2 years agopedantic -> restriction
Max Baumann [Wed, 30 Mar 2022 11:33:10 +0000 (13:33 +0200)]
pedantic -> restriction

2 years agoupdate description
Max Baumann [Wed, 30 Mar 2022 11:08:39 +0000 (13:08 +0200)]
update description

Co-authored-by: giraffate <f.seasons017@gmail.com>
2 years agostyle -> pedantic
Max Baumann [Mon, 28 Mar 2022 09:45:06 +0000 (11:45 +0200)]
style -> pedantic

2 years agounit_like_struct_brackets -> empty_structs_with_brackets
Max Baumann [Mon, 28 Mar 2022 09:35:43 +0000 (11:35 +0200)]
unit_like_struct_brackets -> empty_structs_with_brackets

2 years agochanges after review
Max Baumann [Mon, 28 Mar 2022 09:18:20 +0000 (11:18 +0200)]
changes after review

2 years agouse span_suggestion_hidden
Max Baumann [Sun, 27 Mar 2022 18:10:10 +0000 (20:10 +0200)]
use span_suggestion_hidden

2 years agoadditional checks for conditionally compiled code
Max Baumann [Sun, 27 Mar 2022 17:58:23 +0000 (19:58 +0200)]
additional checks for conditionally compiled code

2 years agofix godfood test
Max Baumann [Sun, 27 Mar 2022 13:33:31 +0000 (15:33 +0200)]
fix godfood test

2 years agofix uitests
Max Baumann [Sun, 27 Mar 2022 13:26:36 +0000 (15:26 +0200)]
fix uitests

2 years agofix existing clippy tests
Max Baumann [Sun, 27 Mar 2022 12:41:09 +0000 (14:41 +0200)]
fix existing clippy tests

2 years agoadd unit_like_struct_brackets
Max Baumann [Sun, 27 Mar 2022 12:16:08 +0000 (14:16 +0200)]
add unit_like_struct_brackets

2 years agoDon't warn int-to-char transmutes in const contexts
SabrinaJewson [Wed, 30 Mar 2022 17:47:50 +0000 (18:47 +0100)]
Don't warn int-to-char transmutes in const contexts

2 years agoHandle relative paths in module_files lints
Alex Macleod [Wed, 30 Mar 2022 17:44:04 +0000 (18:44 +0100)]
Handle relative paths in module_files lints

2 years agoAuto merge of #8602 - giraffate:fix_ice_for_iter_overeager_cloned, r=llogiq
bors [Wed, 30 Mar 2022 17:12:24 +0000 (17:12 +0000)]
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`]

2 years agoAuto merge of #8576 - smoelius:crate_in_macro_def, r=llogiq
bors [Wed, 30 Mar 2022 16:57:24 +0000 (16:57 +0000)]
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`

2 years agoFix error message in crate_in_macro_def.stderr
Samuel E. Moelius III [Wed, 30 Mar 2022 16:52:31 +0000 (12:52 -0400)]
Fix error message in crate_in_macro_def.stderr

2 years agoMove `crate_in_macro_def` to suspicious
Samuel E. Moelius III [Wed, 30 Mar 2022 16:32:07 +0000 (12:32 -0400)]
Move `crate_in_macro_def` to suspicious

2 years agoUpdate clippy_lints/src/crate_in_macro_def.rs
Samuel Moelius [Wed, 30 Mar 2022 16:40:44 +0000 (12:40 -0400)]
Update clippy_lints/src/crate_in_macro_def.rs

Co-authored-by: llogiq <bogusandre@gmail.com>
2 years agoUpdate clippy_lints/src/crate_in_macro_def.rs
Samuel Moelius [Wed, 30 Mar 2022 16:40:25 +0000 (12:40 -0400)]
Update clippy_lints/src/crate_in_macro_def.rs

Co-authored-by: llogiq <bogusandre@gmail.com>
2 years agoUpdate clippy_lints/src/crate_in_macro_def.rs
Samuel Moelius [Wed, 30 Mar 2022 16:40:16 +0000 (12:40 -0400)]
Update clippy_lints/src/crate_in_macro_def.rs

Co-authored-by: llogiq <bogusandre@gmail.com>
2 years agoAuto merge of #8597 - giraffate:fix_changelog, r=xFrednet
bors [Wed, 30 Mar 2022 16:25:42 +0000 (16:25 +0000)]
Auto merge of #8597 - giraffate:fix_changelog, r=xFrednet

Fix version in changelog

changelog: none

2 years agoAuto merge of #8592 - c410-f3r:stuff, r=flip1995
bors [Wed, 30 Mar 2022 16:04:14 +0000 (16:04 +0000)]
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.

2 years agoAuto merge of #8586 - pitaj:fix-8378, r=flip1995
bors [Wed, 30 Mar 2022 15:46:48 +0000 (15:46 +0000)]
Auto merge of #8586 - pitaj:fix-8378, r=flip1995

specify serde version compatible with codebase

fix #8378

changelog: none

2 years agoAuto merge of #8584 - Alexendoo:map-unit-fn-context, r=Manishearth
bors [Wed, 30 Mar 2022 15:25:37 +0000 (15:25 +0000)]
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`

2 years agoclippy: nameres for primitive type impls
lcnr [Wed, 30 Mar 2022 09:57:53 +0000 (11:57 +0200)]
clippy: nameres for primitive type impls

2 years agoget clippy to compile again
lcnr [Fri, 18 Mar 2022 12:33:40 +0000 (13:33 +0100)]
get clippy to compile again

2 years agoAllow running `cargo dev lint` on a package directory
Alex Macleod [Tue, 29 Mar 2022 17:36:38 +0000 (18:36 +0100)]
Allow running `cargo dev lint` on a package directory

2 years agoRemember mutability in `DefKind::Static`.
Camille GILLOT [Tue, 29 Mar 2022 15:11:12 +0000 (17:11 +0200)]
Remember mutability in `DefKind::Static`.

This allows to compute the `BodyOwnerKind` from `DefKind` only, and
removes a direct dependency of some MIR queries onto HIR.

As a side effect, it also simplifies metadata, since we don't need 4
flavours of `EntryKind::*Static` any more.

2 years agoFix ICE for `iter_overeager_cloned`
Takayuki Nakata [Tue, 29 Mar 2022 12:51:37 +0000 (21:51 +0900)]
Fix ICE for `iter_overeager_cloned`

2 years agoimprove parent expr check
J-ZhengLi [Tue, 29 Mar 2022 07:23:19 +0000 (15:23 +0800)]
improve parent expr check

2 years agoRemove opaque type obligation and just register opaque types as they are encountered.
Oli Scherer [Thu, 17 Feb 2022 13:28:06 +0000 (13:28 +0000)]
Remove opaque type obligation and just register opaque types as they are encountered.

This also registers obligations for the hidden type immediately.

2 years agoRevert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"
Oli Scherer [Mon, 14 Feb 2022 16:10:22 +0000 (16:10 +0000)]
Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"

This reverts commit 6499c5e7fc173a3f55b7a3bd1e6a50e9edef782d, reversing
changes made to 78450d2d602b06d9b94349aaf8cece1a4acaf3a8.

2 years agoFix version in changelog
Takayuki Nakata [Mon, 28 Mar 2022 12:48:34 +0000 (21:48 +0900)]
Fix version in changelog

2 years agoAddress review comments
Samuel E. Moelius III [Mon, 28 Mar 2022 08:32:31 +0000 (04:32 -0400)]
Address review comments

2 years agoFirst submit
Jaic1 [Mon, 28 Mar 2022 04:09:01 +0000 (12:09 +0800)]
First submit

2 years agoAuto merge of #8487 - dswij:8478, r=giraffate
bors [Mon, 28 Mar 2022 00:25:45 +0000 (00:25 +0000)]
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`

2 years agoAuto merge of #8519 - tysg:redundant-modulo, r=giraffate
bors [Mon, 28 Mar 2022 00:11:32 +0000 (00:11 +0000)]
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`

2 years agoEmit lint when rhs is negative
Tianyi Song [Sun, 27 Mar 2022 13:48:15 +0000 (21:48 +0800)]
Emit lint when rhs is negative

2 years agoAuto merge of #95274 - jendrikw:slice-must-use, r=Dylan-DPC
bors [Sat, 26 Mar 2022 20:17:04 +0000 (20:17 +0000)]
Auto merge of #95274 - jendrikw:slice-must-use, r=Dylan-DPC

add #[must_use] to functions of slice and its iterators.

Continuation of #92853.

Tracking issue: #89692.

2 years agoRustfmt
Caio [Sat, 26 Mar 2022 18:48:17 +0000 (15:48 -0300)]
Rustfmt