Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Clippy #87152

Merged
merged 64 commits into from
Jul 15, 2021
Merged

Update Clippy #87152

merged 64 commits into from
Jul 15, 2021

Conversation

flip1995
Copy link
Member

lyj and others added 30 commits June 3, 2021 16:25
Update Clippy

Biweekly Clippy Update

r? `@Manishearth`
Downgrade nonstandard_macro_braces to nursery

Due to the large number of crates impacted by rust-lang#7422, I don't think this lint can be enabled by default right now until the false positive is fixed.

---

changelog: remove [`nonstandard_macro_braces`] from default set of enabled lints
Add new lint: `rc_mutex`

changelog: Add new lint `rc_mutex`.

It lints on `Rc<Mutex<T>>`.

`Rc<Mutex<T>>` should be corrected to `Rc<RefCell<T>>`
fix doc_markdown false positive

fixes rust-lang#7421

changelog: don't lint unbalanced tick marks in code blocks
Fix use_self ICE

changelog: Fix ICE rust-lang#7423

r? `@flip1995`
Fix emitting in nested (proc_)macros for nonstandard_macro_braces lint

fixes rust-lang#7422

changelog: fixes false positives in [`nonstandard_macro_braces`]
… 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](rust-lang#85439
Ready for the review. Please take a look.
fixes rust-lang#7145
changelog: Add new lint: `strlen_on_c_strings`, that lints on `libc::strlen(some_cstring.as_ptr())`
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: rust-lang#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.
Rollup of 8 pull requests

Successful merges:

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

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
bors and others added 14 commits July 13, 2021 15:06
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.
fix 5707

changelog: ``[`redundant_clone`]``, fix rust-lang#5707

# Root problem of rust-lang#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 rust-lang#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
…1995

suggest `&mut` for redundant FnMut closures

fixes rust-lang#6903

changelog: suggest `&mut` for redundant FnMut closures
And added `branches_sharing_code` PF note to lint doc for `rust-clippy#7452`
…se-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.
…xFrednet,flip1995

add Arc to `redundant_allocation`

 fixes rust-lang#7303
changelog:  add Arc to `redundant_allocation`
Rustup

r? `@ghost`

changelog: none
@rust-highfive
Copy link
Collaborator

Some changes occurred in src/tools/clippy.

cc @rust-lang/clippy

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 15, 2021
@Manishearth
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 15, 2021

📌 Commit e7bc411 has been approved by Manishearth

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 15, 2021
@Manishearth
Copy link
Member

@bors p=1

@bors
Copy link
Contributor

bors commented Jul 15, 2021

⌛ Testing commit e7bc411 with merge 2636682...

@bors
Copy link
Contributor

bors commented Jul 15, 2021

☀️ Test successful - checks-actions
Approved by: Manishearth
Pushing 2636682 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 15, 2021
@bors bors merged commit 2636682 into rust-lang:master Jul 15, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.