]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #7466 - xFrednet:5393-use-more-diagnostic-items, r=flip1995
bors [Tue, 27 Jul 2021 08:19:23 +0000 (08:19 +0000)]
Auto merge of #7466 - xFrednet:5393-use-more-diagnostic-items, r=flip1995

Use diagnostic items where possible

Clippy still uses a bunch of paths in places that could easily use already defined diagnostic items. This PR updates all references to such paths and also removes a bunch of them that are no longer needed after this cleanup.

Some paths are also used to construct new paths and can therefore not be removed that easily. I've added a doc comment to those instances that recommends the use of the diagnostic item where possible.

And that's it, cleaning crew signing off :broom: :wastebasket:

---

changelog: none

(only internal improvements)

cc: #5393

2 years agoActually infer args in visitors
kadmin [Thu, 6 May 2021 15:33:44 +0000 (15:33 +0000)]
Actually infer args in visitors

2 years agoAuto merge of #7495 - camsteffen:extern-conflict, r=Manishearth
bors [Mon, 26 Jul 2021 16:56:05 +0000 (16:56 +0000)]
Auto merge of #7495 - camsteffen:extern-conflict, r=Manishearth

Improve conflicting rlibs error again

changelog: none

Now you can do `rm <paste>` and 🐇💨

```text
thread 'compile_test' panicked at '
----------------------------------------------------------------------
ERROR: Found multiple rlibs for crates: `clippy_lints`, `clippy_utils`
Try running `cargo clean` or remove the following files:

target/debug/deps/libclippy_lints-9117c875159004e0.rlib \
target/debug/deps/libclippy_lints-fe45157be7ff9444.rlib \
target/debug/deps/libclippy_utils-5eba1e07a9846ed0.rlib \
target/debug/deps/libclippy_utils-ccbc08fcf64de262.rlib

For details on this error see https://github.com/rust-lang/rust-clippy/issues/7343
----------------------------------------------------------------------
```

2 years agoImprove conflicting rlibs error again
Cameron Steffen [Mon, 26 Jul 2021 15:32:26 +0000 (10:32 -0500)]
Improve conflicting rlibs error again

2 years agoInclude more information in --help
Nadir Fejzic [Mon, 26 Jul 2021 14:14:29 +0000 (16:14 +0200)]
Include more information in --help

`--no-deps` filled in with a little more information. Explain that
`--fix` implies `--no-deps`.
Explain that `--no-deps` is used with `cargo clippy --`, including
one example.

2 years agoAuto merge of #7493 - xFrednet:7220-fix-new-without-default-impl-type, r=camsteffen
bors [Mon, 26 Jul 2021 12:20:54 +0000 (12:20 +0000)]
Auto merge of #7493 - xFrednet:7220-fix-new-without-default-impl-type, r=camsteffen

Prefer a code snipped over formatting the self type (`new_without_default`)

Fixes: rust-lang/rust-clippy#7220
changelog: [`new_without_default`]: The `Default` impl block type doesn't use the full type path qualification

Have a nice day to everyone reading this :upside_down_face:

2 years agoAuto merge of #7485 - camsteffen:add-test-externs, r=flip1995
bors [Mon, 26 Jul 2021 12:06:07 +0000 (12:06 +0000)]
Auto merge of #7485 - camsteffen:add-test-externs, r=flip1995

Add to test third party crates list

changelog: none

2 years agoAuto merge of #7477 - F3real:needless_continue, r=flip1995
bors [Mon, 26 Jul 2021 11:52:55 +0000 (11:52 +0000)]
Auto merge of #7477 - F3real:needless_continue, r=flip1995

Enhance needless continue to detect loop {continue;}

Fixes #7417

changelog: Report [`needless_continue`] in `loop { continue; }` case

2 years agoAuto merge of #7484 - camsteffen:author, r=flip1995
bors [Mon, 26 Jul 2021 11:41:46 +0000 (11:41 +0000)]
Auto merge of #7484 - camsteffen:author, r=flip1995

Some `clippy::author` improvements

changelog: none

* Use `Debug` instead of re-implementing it for some things
* Fix block trailing expression handing
* Don't double print on stmt/expr with `#[clippy::author]` attribute

2 years agoPrefer a code snipped over formatting the self type (`new_without_default`)
xFrednet [Sun, 25 Jul 2021 18:35:51 +0000 (20:35 +0200)]
Prefer a code snipped over formatting the self type (`new_without_default`)

2 years agoauthor: check block.expr: None
Cameron Steffen [Sun, 25 Jul 2021 21:35:35 +0000 (16:35 -0500)]
author: check block.expr: None

2 years agoExplain flags missing in cargo check in --help
Nadir Fejzic [Sun, 25 Jul 2021 12:41:35 +0000 (14:41 +0200)]
Explain flags missing in cargo check in --help

This commit closes #7389. As stated in the issue, `cargo clippy --help`
provides explanation for some flags and states that the rest are same
as in `cargo check --help`, even though some clippy specific flags
exist.

This commit extends the `cargo clippy --help` with two additional flags,
  - `cargo clippy --fix`
  - `cargo clippy --no-deps`

If there are more flags which are not present in `cargo check --help`
please bring these to my attention, I will include these aswell.
For now, I noticed only the two flags mentioned above.

2 years agoAuto merge of #83723 - cjgillot:ownernode, r=petrochenkov
bors [Sun, 25 Jul 2021 11:11:02 +0000 (11:11 +0000)]
Auto merge of #83723 - cjgillot:ownernode, r=petrochenkov

Store all HIR owners in the same container

This replaces the previous storage in a BTreeMap for each of Item/ImplItem/TraitItem/ForeignItem.
This should allow for a more compact storage.

Based on https://github.com/rust-lang/rust/pull/83114

2 years agoIntroduce OwnerNode::Crate.
Camille GILLOT [Sun, 25 Jul 2021 10:03:24 +0000 (12:03 +0200)]
Introduce OwnerNode::Crate.

2 years agoAdd inferred args to typeck
kadmin [Mon, 26 Apr 2021 18:19:23 +0000 (18:19 +0000)]
Add inferred args to typeck

2 years agoAdd generic arg infer
kadmin [Sat, 24 Apr 2021 21:41:57 +0000 (21:41 +0000)]
Add generic arg infer

2 years agoAuto merge of #7482 - xFrednet:7306-document-repeat-once-fp, r=giraffate
bors [Sat, 24 Jul 2021 14:15:32 +0000 (14:15 +0000)]
Auto merge of #7482 - xFrednet:7306-document-repeat-once-fp, r=giraffate

Documented constant expression evaluation for `repeat_once`

Documents the fact that the `repeat_once` lint evaluates constant expressions

---

closes: #7306

changelog: none
(I don't think it's worth a change log entry, as nothing has really changed)

r? `@giraffate` as you've implemented the lint and were part of the discussion in the issue :upside_down_face:

2 years agoLint inside macro when owned by current crate
Devin Ragotzy [Sat, 24 Jul 2021 11:03:52 +0000 (07:03 -0400)]
Lint inside macro when owned by current crate

2 years agoOnly trigger for one level of macros
Devin Ragotzy [Thu, 22 Jul 2021 12:55:45 +0000 (08:55 -0400)]
Only trigger for one level of macros

2 years agoAdd tests for FP in nonstandard_macro_braces
Devin Ragotzy [Wed, 21 Jul 2021 11:28:52 +0000 (07:28 -0400)]
Add tests for FP in nonstandard_macro_braces

2 years agoFix FP for nonstandard_macro_braces lint
Devin Ragotzy [Tue, 20 Jul 2021 23:02:48 +0000 (19:02 -0400)]
Fix FP for nonstandard_macro_braces lint

2 years agoclippy::author improvements
Cameron Steffen [Fri, 23 Jul 2021 21:02:09 +0000 (16:02 -0500)]
clippy::author improvements

2 years agoAdd clippy_utils and if_chain to extern crate list
Cameron Steffen [Fri, 23 Jul 2021 22:00:00 +0000 (17:00 -0500)]
Add clippy_utils and if_chain to extern crate list

2 years agoupdate clippy ui test 'future_not_send.stderr' to match
chaz-kiker [Fri, 23 Jul 2021 17:30:52 +0000 (12:30 -0500)]
update clippy ui test 'future_not_send.stderr' to match
the new diagnostic messages

2 years agoClean up unnecessary unwraps
F3real [Fri, 23 Jul 2021 15:30:27 +0000 (17:30 +0200)]
Clean up unnecessary unwraps

2 years agoDocumented constant expression evaluation for `repeat_once`
xFrednet [Fri, 23 Jul 2021 15:02:45 +0000 (17:02 +0200)]
Documented constant expression evaluation for `repeat_once`

2 years agoLint on continue expression without semi-colon
F3real [Thu, 22 Jul 2021 20:21:34 +0000 (22:21 +0200)]
Lint on continue expression without semi-colon

2 years agoEmit needless_continue warning if loop ends on continue
F3real [Wed, 21 Jul 2021 21:15:29 +0000 (23:15 +0200)]
Emit needless_continue warning if loop ends on continue

2 years agoEnhance needless continue to detect loop {continue;}
F3real [Tue, 20 Jul 2021 15:29:03 +0000 (17:29 +0200)]
Enhance needless continue to detect loop {continue;}

2 years agoAuto merge of #7221 - th1000s:keyword_, r=giraffate
bors [Mon, 19 Jul 2021 14:18:59 +0000 (14:18 +0000)]
Auto merge of #7221 - th1000s:keyword_, r=giraffate

similar_names: No longer suggest inserting or appending an underscore

changelog: [`similar_names`] lint no longer suggests to insert or add an underscore to "fix" too similar names

2 years agoMerge commit '4c41a222ca5d1325fb4b6709395bd06e766cc042' into clippyup
flip1995 [Mon, 19 Jul 2021 09:52:05 +0000 (11:52 +0200)]
Merge commit '4c41a222ca5d1325fb4b6709395bd06e766cc042' into clippyup

2 years agoAuto merge of #7476 - flip1995:rustup, r=flip1995
bors [Mon, 19 Jul 2021 09:49:57 +0000 (09:49 +0000)]
Auto merge of #7476 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

Out of cycle sync for 2 ICE fixes #7470 #7471 #7473

changelog: none

2 years agoBump nightly version -> 2021-07-19
flip1995 [Mon, 19 Jul 2021 09:49:03 +0000 (11:49 +0200)]
Bump nightly version -> 2021-07-19

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Mon, 19 Jul 2021 09:38:40 +0000 (11:38 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #7470 - DevinR528:fix-ice7447, r=flip1995
bors [Mon, 19 Jul 2021 09:22:34 +0000 (09:22 +0000)]
Auto merge of #7470 - DevinR528:fix-ice7447, r=flip1995

Add check if ty has_escaping_bound_vars in zero_sized_map_values lint

Fixes: #7447
changelog: fix ICE in [`zero_sized_map_values`]

2 years agoAuto merge of #7403 - Anthuang:redundant-method-names, r=Manishearth
bors [Mon, 19 Jul 2021 06:49:51 +0000 (06:49 +0000)]
Auto merge of #7403 - Anthuang:redundant-method-names, r=Manishearth

New lint: [`self_named_constructor`]

Adds the `self_named_constructor` lint for detecting when an implemented method has the same name as the type it is implemented for.

changelog: [`self_named_constructor`]

closes: #7142

2 years agoRun bless
Anthony Huang [Mon, 19 Jul 2021 05:21:06 +0000 (01:21 -0400)]
Run bless

2 years agoAuto merge of #7474 - camsteffen:binop, r=Manishearth
bors [Sun, 18 Jul 2021 15:52:49 +0000 (15:52 +0000)]
Auto merge of #7474 - camsteffen:binop, r=Manishearth

Use lang items for BinOp lints

changelog: none

2 years agofix(clippy): add missing allow(dyn_drop)
Michael Howell [Sun, 18 Jul 2021 14:57:03 +0000 (07:57 -0700)]
fix(clippy): add missing allow(dyn_drop)

2 years agoAuto merge of #7473 - Jarcho:ice_7340, r=Manishearth
bors [Sun, 18 Jul 2021 03:32:31 +0000 (03:32 +0000)]
Auto merge of #7473 - Jarcho:ice_7340, r=Manishearth

Fix ICE in `is_integer_const`

fixes: #7340
changelog: Fix ICE in `modulo_one` in const contexts

2 years agoFactor BinOp utils
Cameron Steffen [Fri, 16 Jul 2021 19:41:19 +0000 (14:41 -0500)]
Factor BinOp utils

2 years agoUse From to convert BinOpKind
Cameron Steffen [Mon, 28 Jun 2021 19:05:48 +0000 (14:05 -0500)]
Use From to convert BinOpKind

2 years agoFix ICE in `is_integer_const` when the expression is inside an `AnonConst` body
Jason Newcomb [Sat, 17 Jul 2021 23:01:19 +0000 (19:01 -0400)]
Fix ICE in `is_integer_const` when the expression is inside an `AnonConst` body

2 years agoAuto merge of #7471 - flip1995:ice-7410, r=giraffate
bors [Fri, 16 Jul 2021 14:26:08 +0000 (14:26 +0000)]
Auto merge of #7471 - flip1995:ice-7410, r=giraffate

Fix ICE in redundant_pattern_matching

Fixes #7410

changelog: Fix ICE in `redundant_pattern_matching` in `no_std` crates.

2 years agoAuto merge of #87140 - camsteffen:pat-slice-refs, r=oli-obk
bors [Fri, 16 Jul 2021 13:35:48 +0000 (13:35 +0000)]
Auto merge of #87140 - camsteffen:pat-slice-refs, r=oli-obk

Remove refs from Pat slices

Changes `PatKind::Or(&'hir [&'hir Pat<'hir>])` to `PatKind::Or(&'hir [Pat<'hir>])` and others. This is more consistent with `ExprKind`, saves a little memory, and is a little easier to use.

2 years agoFix ICE in redundant_pattern_matching
flip1995 [Fri, 16 Jul 2021 08:45:28 +0000 (10:45 +0200)]
Fix ICE in redundant_pattern_matching

2 years agoRollup merge of #87069 - sexxi-goose:copy_ref_always, r=nikomatsakis
Guillaume Gomez [Fri, 16 Jul 2021 08:08:05 +0000 (10:08 +0200)]
Rollup merge of #87069 - sexxi-goose:copy_ref_always, r=nikomatsakis

ExprUseVisitor: Treat ByValue use of Copy types as ImmBorrow

r? ```@nikomatsakis```

2 years agoAdd check if ty has_escaping_bound_vars in zero_sized_map_values lint
Devin Ragotzy [Thu, 15 Jul 2021 22:35:43 +0000 (18:35 -0400)]
Add check if ty has_escaping_bound_vars in zero_sized_map_values lint

2 years agoAuto merge of #7460 - camsteffen:run-from-source, r=Manishearth
bors [Thu, 15 Jul 2021 21:53:17 +0000 (21:53 +0000)]
Auto merge of #7460 - camsteffen:run-from-source, r=Manishearth

Add instructions to run from source

changelog: none

We often get messages on Zulip asking how to install and run Clippy from source. This adds instructions to the readme. I also added a note explaining that `cargo install --path . --force` is bad, which I just decided after some investigating. I use macOS. It would be nice to get some tests on other platforms to see if this is correct.

2 years agoRemove refs from pat slices
Cameron Steffen [Wed, 14 Jul 2021 21:17:04 +0000 (16:17 -0500)]
Remove refs from pat slices

2 years agoAdd instructions to run from source
Cameron Steffen [Tue, 13 Jul 2021 15:09:24 +0000 (10:09 -0500)]
Add instructions to run from source

2 years agoMerge commit '54a20a02ecd0e1352a871aa0990bcc8b8b03173e' into clippyup
flip1995 [Thu, 15 Jul 2021 08:44:10 +0000 (10:44 +0200)]
Merge commit '54a20a02ecd0e1352a871aa0990bcc8b8b03173e' into clippyup

2 years agoAuto merge of #7468 - flip1995:rustup, r=flip1995
bors [Thu, 15 Jul 2021 08:37:36 +0000 (08:37 +0000)]
Auto merge of #7468 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2021-07-15
flip1995 [Thu, 15 Jul 2021 08:32:21 +0000 (10:32 +0200)]
Bump nightly version -> 2021-07-15

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 15 Jul 2021 08:21:01 +0000 (10:21 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #7308 - lengyijun:redundant_allocation_arc, r=xFrednet,flip1995
bors [Thu, 15 Jul 2021 07:20:37 +0000 (07:20 +0000)]
Auto merge of #7308 - lengyijun:redundant_allocation_arc, r=xFrednet,flip1995

add Arc to `redundant_allocation`

 fixes #7303
changelog:  add Arc to `redundant_allocation`

2 years agoredundant_allocation: add Arc; some refractoring.
lyj [Wed, 2 Jun 2021 05:41:52 +0000 (13:41 +0800)]
redundant_allocation: add Arc; some refractoring.

2 years agoUse diagnostic items for `Vec`, `VecDeque` and connected refactorings
xFrednet [Wed, 14 Jul 2021 21:34:34 +0000 (23:34 +0200)]
Use diagnostic items for `Vec`, `VecDeque` and connected refactorings

2 years agoUse diagnostic items for `intrinsics::transmute`, `TryInto`
xFrednet [Wed, 14 Jul 2021 21:09:24 +0000 (23:09 +0200)]
Use diagnostic items for `intrinsics::transmute`, `TryInto`

2 years agoUse diagnostic items for `Into`, `IntoIterator`, `LinkedList`, `ptr::null`, `prt...
xFrednet [Wed, 14 Jul 2021 20:10:15 +0000 (22:10 +0200)]
Use diagnostic items for `Into`, `IntoIterator`, `LinkedList`, `ptr::null`, `prt::null_mut`

2 years agoAuto merge of #7462 - xFrednet:7369-branches-sharing-code-else-expr-fp, r=camsteffen
bors [Wed, 14 Jul 2021 20:29:56 +0000 (20:29 +0000)]
Auto merge of #7462 - xFrednet:7369-branches-sharing-code-else-expr-fp, r=camsteffen

FP fix and documentation for `branches_sharing_code` lint

Closes rust-lang/rust-clippy#7369

Related rust-lang/rust-clippy#7452 I'm still thinking about the best way to fix this. I could simply add another visitor to ensure that the moved expressions don't modify values being used in the condition, but I'm not totally happy with this due to the complexity. I therefore only documented it for now

changelog: [`branches_sharing_code`] fixed false positive where block expressions would sometimes be ignored.

2 years agoUse diagnostic items for `BinaryHeap`, `BTreeMap`, `BTreeSet`, `HashMap`, `HashSet...
xFrednet [Wed, 14 Jul 2021 10:58:43 +0000 (12:58 +0200)]
Use diagnostic items for `BinaryHeap`, `BTreeMap`, `BTreeSet`, `HashMap`, `HashSet`, `Borrow`, `Default`

2 years agoFixed `branches_sharing_code` FP with block expressions in else
xFrednet [Tue, 13 Jul 2021 21:27:19 +0000 (23:27 +0200)]
Fixed `branches_sharing_code` FP with block expressions in else

And added `branches_sharing_code` PF note to lint doc for `rust-clippy#7452`

2 years agoAuto merge of #7437 - ebobrow:redundant-closure-move, r=flip1995
bors [Wed, 14 Jul 2021 15:15:28 +0000 (15:15 +0000)]
Auto merge of #7437 - ebobrow:redundant-closure-move, r=flip1995

suggest `&mut` for redundant FnMut closures

fixes #6903

changelog: suggest `&mut` for redundant FnMut closures

2 years agosuggest `&mut` for redundant FnMut closures
Elliot Bobrow [Sat, 3 Jul 2021 03:25:55 +0000 (20:25 -0700)]
suggest `&mut` for redundant FnMut closures

2 years agoAuto merge of #7346 - lengyijun:redundant_clone_5707, r=oli-obk
bors [Wed, 14 Jul 2021 10:10:14 +0000 (10:10 +0000)]
Auto merge of #7346 - lengyijun:redundant_clone_5707, r=oli-obk

fix 5707

changelog: ``[`redundant_clone`]``, fix #5707

# Root problem of #5707 :
```
&2:&mut HashMap = &mut _4;
&3:&str = & _5;
_1 = HashMap::insert(move _2,move _3, _);
```

generate PossibleBorrower(_2,_1) and PossibleBorrower(_3,_1).

However, it misses PossibleBorrower(_3,_2).

# My solution to #5707 :

When meet a function call, we should:
1. build PossibleBorrower between borrow parameters and return value (currently)
2. build PossibleBorrower between immutable borrow parameters and mutable borrow parameters (*add*)
3. build PossibleBorrower inside mutable borrow parameters (*add*)

For example:
```
_2: &mut _22;
_3: &mut _;
_4: & _;
_5: & _;
_1 = call(move _2, move _3, move _4, move _5);
```
we need to build
1. return value with parameter(current implementataion)
 PossibleBorrower(_2,_1)
 PossibleBorrower(_3,_1)
 PossibleBorrower(_4,_1)
 PossibleBorrower(_5,_1)

2. between mutable borrow and immutable borrow
PossibleBorrower(_4,_2)
PossibleBorrower(_5,_2)
PossibleBorrower(_4,_3)
PossibleBorrower(_5,_3)

3. between mutable borrow and mutable borrow
PossibleBorrower(_3,_2)
PossibleBorrower(_2,_3)

  But that's not enough.
 Modification to _2 actually apply to _22.
  So I write a `PossibleBorrowed` visitor, which tracks (borrower => possible borrowed) relation.
  For example (_2 => _22).
  However, a lot of problems exist here.

## Known Problems:
  1. not sure all `&mut`'s origin are collected.
  I'm not sure how to deal with `&mut` when meet a function call, so I didn't do it currently.
  Also, my implement is not flow sensitive, so it's not accurate.

```
foo(_2:&mut _, _3: &_)
```
This pr doesn't count _3 as origin of _2.

 2. introduce false negative
`foo(_2, _3)` will  emit PossibleBorrower(_3,_2) in this pr, but _3 and _2 may not have relation.
Clippy may feel that _3 is still in use because of _2, but actually, _3 is on longer needed and can be moved.

## Insight
  The key problem is determine where every `&mut` come from accurately.
  I think Polonius is an elegant solution to it. Polonius is flow sensitive and accurate.
  But I'm uncertain about whether we can import Polonius in rust-clippy currently.
  This pr actually is part of Polonius' functionality, I think.

# TODO
1. `cargo test` can't pass yet due to similar variable name

2 years agoExprUseVisitor::Delegate consume only when moving
Aman Arora [Wed, 14 Jul 2021 06:21:08 +0000 (02:21 -0400)]
ExprUseVisitor::Delegate consume only when moving

2 years agorename possible_borrowed to possible_origin; pass dogfood
lyj [Wed, 14 Jul 2021 03:29:39 +0000 (11:29 +0800)]
rename possible_borrowed to possible_origin; pass dogfood

2 years agofix 5707
lyj [Fri, 11 Jun 2021 12:57:11 +0000 (20:57 +0800)]
fix 5707

2 years agoNo longer suggest inserting or appending an underscore
Thomas Otto [Thu, 13 May 2021 20:53:31 +0000 (22:53 +0200)]
No longer suggest inserting or appending an underscore

changelog: [`similar_names`] lint no longer suggests to insert or add an underscore
to "fix" too similar names

2 years agoAuto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk
bors [Tue, 13 Jul 2021 15:06:10 +0000 (15:06 +0000)]
Auto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk

Fix internal `default_hash_types` lint to use resolved path

I run into false positives now and then (mostly in Clippy) when I want to name some util after HashMap.

2 years agoAuto merge of #7446 - Y-Nak:fix-7445, r=xFrednet,flip1995
bors [Tue, 13 Jul 2021 14:31:02 +0000 (14:31 +0000)]
Auto merge of #7446 - Y-Nak:fix-7445, r=xFrednet,flip1995

`default_numeric_fallback`: Fix FP with floating literal

Fix #7445

changelog: `default_numeric_fallback`: Fix FP with floating literal

2 years ago`default_numeric_fallback`: Add rustfix tests
Yoshitomo Nakanishi [Tue, 13 Jul 2021 13:57:47 +0000 (22:57 +0900)]
`default_numeric_fallback`: Add rustfix tests

2 years agoAuto merge of #7442 - camsteffen:format-args, r=xFrednet
bors [Tue, 13 Jul 2021 13:58:38 +0000 (13:58 +0000)]
Auto merge of #7442 - camsteffen:format-args, r=xFrednet

Refactor `format_args!` expansion parsing

Introduces `FormatExpn::parse` and `FormatArgsExpn::parse`. Motivated by rust-lang/rust#83302, so I only have to change Clippy in one place. Fixed an FP along the way.

I also allowed `needless_bool` in macros because I often want to do `if_chain! { .. then { true } else { false } }`.

changelog: Fix false positive in `useless_format` when some text is appended or prepended to a single string with some useless formatting params
changelog: Allow `needless_bool` in macros

2 years agoSplit a lint message into help
Cameron Steffen [Mon, 12 Jul 2021 01:30:19 +0000 (20:30 -0500)]
Split a lint message into help

2 years agoReduce redundant code
Cameron Steffen [Mon, 12 Jul 2021 01:21:21 +0000 (20:21 -0500)]
Reduce redundant code

2 years agoRefactor format macro parsing
Cameron Steffen [Tue, 6 Jul 2021 16:51:15 +0000 (11:51 -0500)]
Refactor format macro parsing

2 years agoFix useless_format false positive
Cameron Steffen [Sun, 4 Jul 2021 21:34:22 +0000 (16:34 -0500)]
Fix useless_format false positive

2 years agoAllow needless_bool in macro
Cameron Steffen [Wed, 9 Jun 2021 19:44:42 +0000 (14:44 -0500)]
Allow needless_bool in macro

2 years agoFix `NumericLiteral::format` that may produce a invalid literal
Yoshitomo Nakanishi [Tue, 13 Jul 2021 13:56:41 +0000 (22:56 +0900)]
Fix `NumericLiteral::format` that may produce a invalid literal

2 years agoAuto merge of #7458 - flip1995:unused_unit-doc, r=giraffate
bors [Tue, 13 Jul 2021 13:43:12 +0000 (13:43 +0000)]
Auto merge of #7458 - flip1995:unused_unit-doc, r=giraffate

Add fixed example to unused_unit documentation

changelog: none

(don't think this is worth a changelog mention)

2 years agoAdd fixed example to unused_unit documentation
flip1995 [Tue, 13 Jul 2021 08:54:29 +0000 (10:54 +0200)]
Add fixed example to unused_unit documentation

2 years agorustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`
Vadim Petrochenkov [Sat, 10 Jul 2021 19:14:52 +0000 (22:14 +0300)]
rustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`

The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.

2 years agoclippy: allow default_hash_types on bootstrap
Cameron Steffen [Thu, 8 Jul 2021 17:59:16 +0000 (12:59 -0500)]
clippy: allow default_hash_types on bootstrap

2 years agoAuto merge of #7449 - flip1995:remove-lints_enabled, r=camsteffen
bors [Fri, 9 Jul 2021 14:00:52 +0000 (14:00 +0000)]
Auto merge of #7449 - flip1995:remove-lints_enabled, r=camsteffen

Remove lints_enabled

r? `@camsteffen`

cc https://github.com/rust-lang/rust-clippy/pull/7448#issuecomment-876497862

I haven't added a variant with `last_node_with_lint_attrs` yet, since I didn't see a usecase for this. Also this field is not documented, so I'm wondering how it behaves with command line lints and so on.

changelog: none

2 years agoRename `is_allowed` -> `is_lint_allowed`
flip1995 [Fri, 9 Jul 2021 13:06:12 +0000 (15:06 +0200)]
Rename `is_allowed` -> `is_lint_allowed`

2 years agoRemove lints_enabled function
flip1995 [Fri, 9 Jul 2021 13:00:24 +0000 (15:00 +0200)]
Remove lints_enabled function

This function was redundant with the is_allowed function. Now is_allowed
is used everywhere lints_enabled was used before.

2 years ago`default_numeric_fallback`: Add more tests for floating literal
Yoshitomo Nakanishi [Fri, 9 Jul 2021 05:51:16 +0000 (14:51 +0900)]
`default_numeric_fallback`: Add more tests for floating literal

2 years agoAuto merge of #7448 - flip1995:run_lints-rename, r=llogiq
bors [Fri, 9 Jul 2021 06:39:56 +0000 (06:39 +0000)]
Auto merge of #7448 - flip1995:run_lints-rename, r=llogiq

Rename run_lints -> lints_enabled

Just a quick rename of a utilities function. `run_lints` kinda suggested that the lints were run by this function. But the only thing this function does is to check if the lints are enabled in the context of the `hir_id`

changelog: none

2 years agoRework SESSION_GLOBALS API to prevent overwriting it
Guillaume Gomez [Wed, 5 May 2021 19:31:25 +0000 (21:31 +0200)]
Rework SESSION_GLOBALS API to prevent overwriting it

2 years agoRename run_lints -> lints_enabled
flip1995 [Thu, 8 Jul 2021 13:45:19 +0000 (15:45 +0200)]
Rename run_lints -> lints_enabled

2 years agodefault_numeric_fallback: Fix FP with floating literal
Yoshitomo Nakanishi [Thu, 8 Jul 2021 02:37:12 +0000 (11:37 +0900)]
default_numeric_fallback: Fix FP with floating literal

2 years agoAuto merge of #86920 - JohnTitor:rollup-buvzpkr, r=JohnTitor
bors [Wed, 7 Jul 2021 03:31:23 +0000 (03:31 +0000)]
Auto merge of #86920 - JohnTitor:rollup-buvzpkr, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #80918 (Add Integer::log variants)
 - #86717 (Rename some Rust 2021 lints to better names )
 - #86819 (Clean up rustdoc IDs)
 - #86880 (Test ManuallyDrop::clone_from.)
 - #86906 (Replace deprecated compare_and_swap and fix typo in core::sync::atomic::{fence, compiler_fence} docs)
 - #86907 (Migrate `cpu-usage-over-time.py` to Python 3)
 - #86916 (rewrote documentation for thread::yield_now())
 - #86919 (Update books)

Failed merges:

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

2 years agoMake type_implements_trait not a query
Aman Arora [Tue, 6 Jul 2021 09:38:15 +0000 (05:38 -0400)]
Make type_implements_trait not a query

2 years agoAdd s to non_fmt_panic
Ryan Levick [Tue, 29 Jun 2021 18:33:31 +0000 (20:33 +0200)]
Add s to non_fmt_panic

2 years agoAuto merge of #7439 - iobtl:assert_msg_panic_fp, r=flip1995
bors [Tue, 6 Jul 2021 08:22:57 +0000 (08:22 +0000)]
Auto merge of #7439 - iobtl:assert_msg_panic_fp, r=flip1995

Fix false-positive `assert` in `panic`

This PR fixes a false-positive in `clippy::panic` when using the `assert` macro with its optional message parameter.

Fixes: #7433
changelog: `panic_unimplemented.rs`: added condition to exclude `assert` macro, similar to `debug_assert`
changelog: `panicking_macros.rs`: relevant tests to check for `assert` usage.

2 years agofix false positive (panic message) with assert macro using message parameter
iobtl [Tue, 6 Jul 2021 07:14:53 +0000 (15:14 +0800)]
fix false positive (panic message) with assert macro using message parameter

3 years agoAdd redundant_method_names lint
Anthony Huang [Fri, 25 Jun 2021 20:34:45 +0000 (16:34 -0400)]
Add redundant_method_names lint

3 years agoAuto merge of #7243 - mgacek8:issue7145_strlen_on_c_strings, r=giraffate
bors [Mon, 5 Jul 2021 13:12:43 +0000 (13:12 +0000)]
Auto merge of #7243 - mgacek8:issue7145_strlen_on_c_strings, r=giraffate

Add new lint: `strlen_on_c_strings`

~~This is WIP, linting in case of `CString` has been added, but for `CStr`, its diagnostic item needs to be available for clippy.
[PR that adds diagnostic item for CStr on rust repo](https://github.com/rust-lang/rust/pull/85439).~~
Ready for the review. Please take a look.
fixes #7145
changelog: Add new lint: `strlen_on_c_strings`, that lints on `libc::strlen(some_cstring.as_ptr())`

3 years agoAdd new lint: strlen_on_c_strings
Mateusz Gacek [Tue, 18 May 2021 13:19:56 +0000 (15:19 +0200)]
Add new lint: strlen_on_c_strings