Commit graph

13730 commits

Author SHA1 Message Date
bors
18ab97d220 Auto merge of #8668 - Jarcho:iter_with_drain_8538, r=Manishearth
Don't lint `iter_with_drain` on references

fixes #8538
changelog: Don't lint `iter_with_drain` on references
2022-04-11 15:20:01 +00:00
bors
5c19ae96e7 Auto merge of #8660 - yoav-lavi:squashed-master, r=flip1995
`unnecessary_owned_empty_strings`

[`unnecessary_owned_empty_strings`]

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

- \[x] 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`

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

changelog: Adds `unnecessary_owned_empty_strings`, a lint that detects passing owned empty strings to a function expecting `&str`
2022-04-11 11:12:33 +00:00
Yoav Lavi
10201370a1 unnecessary_owned_empty_string -> unnecessary_owned_empty_strings 2022-04-11 13:05:42 +02:00
Yoav Lavi
a4d1837f07 unnecessary_string_new 2022-04-11 12:35:44 +02:00
bors
85e91dc99e Auto merge of #8671 - andy-k:fix-typo, r=flip1995
fix typo

fix typo in #8630

changelog: none
2022-04-11 09:22:37 +00:00
bors
5344236715 Auto merge of #8631 - Alexendoo:splitn-overlap, r=xFrednet
Remove overlap between `manual_split_once` and `needless_splitn`

changelog: Remove overlap between [`manual_split_once`] and [`needless_splitn`]. Fixes some incorrect `rsplitn` suggestions for [`manual_split_once`]

Things that can trigger `needless_splitn` no longer trigger `manual_split_once`, e.g.

```rust
s.[r]splitn(2, '=').next();
s.[r]splitn(2, '=').nth(0);
s.[r]splitn(3, '=').next_tuple();
```

Fixes some suggestions:

```rust
let s = "should not match";

s.rsplitn(2, '.').nth(1);
// old -> Some("should not match")
Some(s.rsplit_once('.').map_or(s, |x| x.0));
// new -> None
s.rsplit_once('.').map(|x| x.0);

s.rsplitn(2, '.').nth(1)?;
// old -> "should not match"
s.rsplit_once('.').map_or(s, |x| x.0);
// new -> early returns
s.rsplit_once('.')?.0;
```
2022-04-10 17:45:19 +00:00
Alex Macleod
6fba89751b Remove overlap between manual_split_once and needless_splitn
Also fixes some incorrect suggestions for rsplitn
2022-04-10 17:05:07 +01:00
Andy Kurnia
1450c989ae fix typo 2022-04-10 01:07:01 +08:00
bors
c7e6863843 Auto merge of #8664 - yoav-lavi:main, r=xFrednet
Allow passing `--remove` to `cargo dev setup <SUBCOMMAND>`

changelog: none

Allows passing `--remove` to `cargo dev setup <SUBCOMMAND>` as an alternative to `cargo dev remove ...`

Fixes https://github.com/rust-lang/rust-clippy/issues/8663
2022-04-09 14:57:06 +00:00
Yoav Lavi
ffde78b456 Allow passing --remove to cargo dev setup <SUBCOMMAND>
add missing args

unque name not needed

more descriptive help

formatting fixes

missing quote
2022-04-09 16:50:10 +02:00
bors
cfd52aa0ff Auto merge of #8669 - kyoto7250:fix_comments_in_test_split_once, r=xFrednet
fix comments in test for split_once

This PR fixed comments in test.

`split_once` was stabilized in 1.52, so I think the comments maybe be wrong.

ref:
https://doc.rust-lang.org/std/string/struct.String.html#method.split_once

thank you in advance.

changelog: none
2022-04-09 11:58:18 +00:00
kyoto7250
a9511482d6 fix comments in test for split_once
split_once was stabilized in 1.52
2022-04-09 20:34:43 +09:00
Jason Newcomb
744b0ff903 Don't lint iter_with_drain on references 2022-04-08 23:41:50 -04:00
bors
b029a86c6b Auto merge of #8648 - Jarcho:transmute_collection_7706, r=xFrednet
Fix `unsound_collection_transmute`

fixes #7706

changelog: Better check size and alignment requirements in `unsound_collection_transmute`
2022-04-08 21:43:26 +00:00
bors
a63308be0a 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
2022-04-08 00:37:56 +00:00
bors
984330a6ee 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
2022-04-07 17:11:26 +00:00
flip1995
6ab4508350
Allow raw lint descriptions
update_lints now understands raw strings in declare_clippy_lint
descriptions.

Co-authored-by: Alex Macleod <alex@macleod.io>
2022-04-07 18:05:46 +01:00
bors
abc59bb914 Auto merge of #8656 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-04-07 15:30:27 +00:00
flip1995
a2fdbb5f53
Bump changelog stable version -> 1.60 2022-04-07 16:26:43 +01:00
flip1995
f5e32dc647
Bump nightly version -> 2022-04-07 2022-04-07 16:24:55 +01:00
flip1995
f23a9fb295
Bump Clippy Version -> 0.1.62 2022-04-07 16:24:33 +01:00
flip1995
db1d5dca50
Fix internal::INVALID_PATHS lint 2022-04-07 16:24:10 +01:00
flip1995
669fddab37
Merge remote-tracking branch 'upstream/master' into rustup 2022-04-07 15:44:37 +01:00
bors
574bf88e3e 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()`.
2022-04-07 13:17:28 +00:00
bors
650a0e52b8 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
2022-04-07 13:00:15 +00:00
Alex Macleod
182b7c38d7 Fix as_deref_mut false positives in needless_option_as_deref
Also moves the lint to the methods directory
2022-04-07 12:39:21 +01:00
Paolo Borelli
f2bbb5fac0 conf: fix lint name in comment
The lint name is ERR_EXPECT, not EXPECT_ERR
2022-04-07 11:29:02 +02:00
Paolo Borelli
b0edbca0e6 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.
2022-04-07 11:28:14 +02:00
bors
0d66404941 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`
2022-04-06 23:04:20 +00:00
bors
409a936f3b 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()
2022-04-06 18:07:56 +00:00
infrandomness
a7125b0393 Fix mistakes in documentation :
- err() was meant to be employed instead of ok()
- wraps comment
2022-04-06 19:25:58 +02:00
InfRandomness
cebe575aad Add .err().expect() lint 2022-04-06 19:25:58 +02:00
bors
81e004aadb 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`]
2022-04-06 17:23:14 +00:00
Jason Newcomb
d5e887c6f0 Better check size and alignment requirements in unsound_collection_transmute 2022-04-06 11:57:55 -04:00
bors
30019d1d05 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.
2022-04-06 15:13:43 +00:00
Yoav Lavi
1ad6442e91 update unnecessary_join documentation 2022-04-06 15:59:38 +02:00
J-ZhengLi
85b081b65a code refractor for [needless_match] 2022-04-06 20:44:54 +08:00
bors
cf1e2e9c1c 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
2022-04-06 09:32:51 +00:00
Sabrina Jewson
41ef4f729f
Report from_utf8 suggestion as maybe incorrect
Co-authored-by: Philipp Krones <hello@philkrones.com>
2022-04-06 10:14:20 +01:00
bors
880ff2497d 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 `]
2022-04-06 08:27:03 +00:00
bors
41f2eccf92 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
2022-04-06 08:13:26 +00:00
bors
9a09506406 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
2022-04-05 13:03:16 +00:00
bors
938b9fd720 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`]``
2022-04-05 10:07:13 +00:00
Akshay
1582e7bf88
fix mispelling in diagnostic message of bytes_nth 2022-04-05 10:53:10 +01:00
bors
511752fd9d 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
2022-04-05 09:50:53 +00:00
bors
01ea6241ae 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
2022-04-05 09:33:38 +00:00
flip1995
f8c2e6dc4e
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.
2022-04-05 10:24:32 +01:00
David Wood
ba718bbeee 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>
2022-04-05 07:01:03 +01:00
David Wood
865386e9dc 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>
2022-04-05 07:01:02 +01:00
David Wood
41d1340505 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.
2022-04-05 07:01:02 +01:00