Commit Graph

4493 Commits

Author SHA1 Message Date
InfRandomness
0a7f19b547 Fix #8748 2022-05-30 22:46:31 +02:00
bors
39231b4b50 Auto merge of #8385 - cameron1024:doc_link_with_quotes, r=llogiq
add doc_link_with_quotes lint

I'm not sure about wording, it seems OK to me but happy to change if other people have better ideas

closes #8383

---
changelog: add [`doc_link_with_quotes`] lint
2022-05-28 14:27:51 +00:00
bors
5920fa3516 Auto merge of #8844 - smoelius:fixed-paths, r=Alexendoo
Check `.fixed` paths' existence in `run_ui`

This PR adds a test to check that there exists a `.fixed` file for every `.stderr` file in `tests/ui` that mentions a `MachineApplicable` lint. The test leverages `compiletest-rs`'s `rustfix_coverage` option.

I tried to add `.fixed` files where they appeared to be missing. However, 38 exceptional `.rs` files remain. Several of those include comments indicating that they are exceptions, though not all do. Apologies, as I have not tried to associate the 38 files with GH issues. (I think that would be a lot of work, and I worry about linking the wrong issue.)

changelog: none
2022-05-28 11:28:04 +00:00
llogiq
c9be57dbf3
Merge branch 'master' into doc_link_with_quotes 2022-05-28 10:55:25 +02:00
Samuel E. Moelius III
6027255eb2 Ignore crashes dir 2022-05-27 16:44:02 -04:00
bors
1dd55471b4 Auto merge of #8892 - smoelius:fix-empty-line-false-positive, r=Manishearth
Fix `empty_line_after_outer_attribute` false positive

This PR fixes a false positive in `empty_line_after_outer_attribute`.

Here is a minimal example that trigger the FP:
```rust
#[derive(clap::Parser)]
#[clap(after_help = "This ia a help message.

You're welcome.
")]
pub struct Args;
```

changelog: PF: [`empty_line_after_outer_attribute`]: No longer lints empty lines in inner string values.
2022-05-27 20:34:06 +00:00
bors
461a6613cf Auto merge of #8897 - tamaroning:improve_dbg, r=Alexendoo
Introduce `allow-dbg-in-tests` config value

related to: Issue #8758,  PR https://github.com/rust-lang/rust-clippy/pull/8838

changelog: Introduced `allow-dbg-in-tests` config value. [dbg_macro] does not allow `dbg!` in test code by default.
2022-05-27 19:41:39 +00:00
Samuel E. Moelius III
c91a7f0b83 Address review comments 2022-05-27 15:18:46 -04:00
Samuel E. Moelius III
911eb1f4cd Check .fixed paths' existence in run_ui 2022-05-27 15:18:46 -04:00
bors
a5ece8132f Auto merge of #8885 - Serial-ATA:rc-clone-in-vec-init-weak, r=llogiq
Support `Weak` in [`rc_clone_in_vec_init`]

changelog: Support `Weak` in [`rc_clone_in_vec_init`]
2022-05-27 04:02:53 +00:00
Serial
fc28f6acc8 Support Weak in [rc_clone_in_vec_init] 2022-05-26 21:52:25 -04:00
tamaron
ea06a414f1 fix 2022-05-27 01:30:44 +09:00
Alex Macleod
17f7047811 Only return DefIds to Fn-like definitions in clippy_utils::fn_def_id 2022-05-26 14:35:19 +00:00
Samuel E. Moelius III
9ee211af9f Fix empty_line_after_outer_attribute false positive 2022-05-25 19:35:26 -04:00
Micha White
4de301e394
Fixed the test to not use an epsilon 2022-05-24 22:53:35 -04:00
Micha White
d8a281ef73
Added an unused_rounding lint 2022-05-24 22:53:29 -04:00
kyoto7250
e47c5b0e03 ignore clippy::get_first 2022-05-25 09:08:25 +09:00
kyoto7250
b531eb1a7a suggest first() instead of get(0) 2022-05-25 09:08:25 +09:00
kyoto7250
1dd026698d feat(lint): impl lint about use first() instead of get(0) 2022-05-25 09:08:23 +09:00
bors
b97784fd07 Auto merge of #8862 - Alexendoo:get-last-with-len, r=Jarcho,xFrednet
`get_last_with_len`: lint `VecDeque` and any deref to slice

changelog: [`get_last_with_len`]: lint `VecDeque` and any deref to slice

Previously only `Vec`s were linted, this will now catch any usages on slices, arrays, etc. It also suggests `.back()` for `VecDeque`s

Also moves the lint into `methods/`
2022-05-24 21:40:15 +00:00
bors
67a089134d Auto merge of #8880 - hellow554:rustfix_update, r=Manishearth
Add some testcases for recent rustfix update

changelog: none

This adds a testcase for a bugfix that has been fixed by https://github.com/rust-lang/rustfix/tree/v0.6.1

`rustfix` is pulled in by `compiletest_rs`. So to test that the correct rustfix version is used, I added one (and a half) testcase.

I tried to add a testcase for #8734 as well, but interesting enough the rustfix is wrong:

```diff
 fn issue8734() {
     let _ = [0u8, 1, 2, 3]
         .into_iter()
-        .and_then(|n| match n {
+        .flat_map(|n| match n {
+            1 => [n
+                .saturating_add(1)
             1 => [n
                 .saturating_add(1)
                 .saturating_add(1)
                 .saturating_add(1)
                 .saturating_add(1)
                 .saturating_add(1)
                 .saturating_add(1)
                 .saturating_add(1)
                 .saturating_add(1)],
             n => [n],
         });
 }
```

this needs some investigation and then this testcase needs to be enabled by commenting it out

closes #8878
related to #8734
2022-05-24 21:20:57 +00:00
bors
c41c410a90 Auto merge of #8786 - Alexendoo:identity-op-suggestions, r=dswij,xFrednet
`identity_op`: add parenthesis to suggestions where required

changelog: [`identity_op`]: add parenthesis to suggestions where required

Follow up to #8730, wraps the cases we can't lint as-is in parenthesis rather than ignoring them

Catches a couple new FPs with mixed operator precedences and `as` casts

```rust
// such as
0 + { a } * 2;
0 + a as usize;
```

The suggestions are now applied using `span_lint_and_sugg` rather than appearing in just the message and have a `run-rustfix` test
2022-05-24 20:47:34 +00:00
bors
fbb9e565e3 Auto merge of #8754 - guerinoni:no_effect_replace, r=llogiq
New lint `no_effect_replace`

Closes #1595

Signed-off-by: Federico Guerinoni <guerinoni.federico@gmail.com>

changelog: Add [`no_effect_replace`] lint.
2022-05-24 16:55:06 +00:00
Marcel Hellwig
04297de2ed prepare test for 8734 2022-05-24 14:42:08 +02:00
Marcel Hellwig
22673bce4c add testcase for #8878 2022-05-24 14:41:23 +02:00
Federico Guerinoni
ea62347a5a New lint no_effect_replace
Closes #1595

changelog: Add no_effect_replace lint.
2022-05-24 11:08:41 +02:00
Alex Macleod
855849034c get_last_with_len: lint VecDeque and any deref to slice
previously only vecs were supported
2022-05-21 19:52:43 +00:00
xFrednet
4e6cf0036e
Merge remote-tracking branch 'upstream/master' into rustup 2022-05-20 20:47:31 +02:00
bors
ea96091331 Auto merge of #8838 - tamaroning:fix_dbg, r=Jarcho,xFrednet
[dbg_macro] tolerates use of `dbg!` in items which have `#[cfg(test)]` attribute

fix: #8758
changelog: [dbg_macro] tolerates use of `dbg!` in items with `#[cfg(test)]` attribute
2022-05-19 15:46:35 +00:00
bors
bf2e63104d Auto merge of #8807 - Jarcho:cmp_owned, r=giraffate
Fix `cmp_owned` on copy types

fixes #8803
fixes #7365

changelog: Don't lint `cmp_owned` on `From::from` for copy types
2022-05-18 00:19:36 +00:00
tamaron
b4c3f0f79b fix 2022-05-18 00:37:12 +09:00
bors
d901079ca1 Auto merge of #8814 - yonip23:add-suggestion-to-rc-clone-in-vec-init, r=xFrednet
add suggestions to rc_clone_in_vec_init

A followup to https://github.com/rust-lang/rust-clippy/pull/8769
I also switch the order of the 2 suggestions, since the loop initialization one is probably the common case.

`@xFrednet` I'm not letting you guys rest for a minute 😅
changelog: add suggestions to [`rc_clone_in_vec_init`]
2022-05-17 05:46:00 +00:00
Jason Newcomb
c649d4e8a7 Fix ICE in let_unit_value when calling a static or const callable type 2022-05-16 10:00:32 -04:00
bors
a1632fffc1 Auto merge of #8761 - tamaroning:fix_8505, r=Jarcho
`undocumented_unsafe_blocks` does not trigger on unsafe trait impls

Closes #8505

changelog: This lint checks unsafe impls NOT from macro expansions and checks ones in macro declarations.
~~`unsafe impl`s from macro invocations don't trigger the lint for now.~~
~~This lint checks unsafe impls from/not from macro expansions~~
2022-05-16 00:47:10 +00:00
bors
6ec735962f Auto merge of #8699 - Jarcho:vec_init_then_push_7071, r=dswij,xFrednet
Don't lint `vec_init_then_push` when further extended

fixes #7071

This will still lint when a larger number of pushes are done (four currently). The exact number could be debated, but this is more readable then a sequence of pushes so it shouldn't be too large.

changelog: Don't lint `vec_init_then_push` when further extended.
changelog: Remove `mut` binding from `vec_init_then_push` when possible.
2022-05-15 21:51:24 +00:00
Jason Newcomb
f1574cc131 Update vec_init_then_push docs 2022-05-15 17:39:39 -04:00
Jason Newcomb
50eada16f7 Rename eval_order_dependence to mixed_read_write_in_expression 2022-05-15 17:08:45 -04:00
bors
2038084cf2 Auto merge of #8813 - evantypanski:redundant_alloc_fat_ptr, r=Alexendoo
Fix redundant_allocation warning for Rc<Box<str>>

changelog: [`redundant_allocation`] Fixes #8604

Fixes false positives where a fat pointer with `str` type was made thin by another allocation, but that thinning allocation was marked as redundant
2022-05-13 15:02:58 +00:00
ydah
4e5f69cc86 Tweak some words improved representation
This PR has implemented improved representation.

- Use "lib" instead of "lifb"
- Use "triggered" instead of "triggere"
- Use "blacklisted_name" instead of "blackisted_name"
- Use "stabilization" instead of "stabilisation"
- Use "behavior" instead of "behaviour"
- Use "target" instead of "tartet"
- Use "checked_add" instead of "chcked_add"
- Use "anti-pattern" instead of "antipattern"
- Use "suggestion" instead of "suggesttion"
- Use "example" instead of "exampel"
- Use "Cheat Sheet" instead of "Cheatsheet"
2022-05-13 14:20:25 +09:00
Evan Typanski
0def44a1c1 Catch other thinning allocations using Ty 2022-05-12 19:15:08 -04:00
yonip23
dc23b5d661 fix indentation + test 2022-05-12 10:06:15 +03:00
bors
a3d1f28849 Auto merge of #8818 - koic:use_rust_2021_prelude, r=flip1995
Use the traits added to the Rust 2021 Edition prelude

Follow up https://github.com/rust-lang/rust/pull/96861.

This PR uses the traits added to the Rust 2021 Edition prelude.

> The `TryInto`, `TryFrom` and `FromIterator` traits are now part of the prelude.

https://doc.rust-lang.org/edition-guide/rust-2021/prelude.html

---

changelog: none
2022-05-11 20:16:42 +00:00
yonip23
344888a582 fix review comments 2022-05-11 23:11:52 +03:00
Camille GILLOT
31825326e5 Bless clippy. 2022-05-11 18:51:14 +02:00
Koichi ITO
ae0216d557 Use the traits added to the Rust 2021 Edition prelude
Follow up https://github.com/rust-lang/rust/pull/96861.

This PR uses the traits added to the Rust 2021 Edition prelude.

> The `TryInto`, `TryFrom` and `FromIterator` traits are now part of the prelude.

https://doc.rust-lang.org/edition-guide/rust-2021/prelude.html
2022-05-12 00:38:11 +09:00
Serial
554dc41cea Fix match_single_binding for assign expressions 2022-05-10 18:38:51 -04:00
yonip23
f3e01c4f6a add suggestions to rc_clone_in_vec_init 2022-05-11 01:09:45 +03:00
Evan Typanski
631b4ee7a2 Fix redundant_allocation warning for Rc<Box<str>> 2022-05-10 14:21:51 -04:00
tamaron
aaf87c3871 fix 2022-05-10 23:54:42 +09:00
bors
d422baa30c Auto merge of #8796 - nsunderland1:master, r=giraffate
New lint: [`derive_partial_eq_without_eq`]

Introduces a new lint, [`derive_partial_eq_without_eq`].

See: #1781 (doesn't close it though).

changelog: add lint [`derive_partial_eq_without_eq`]
2022-05-10 13:25:27 +00:00