Add assert message to suggestion in lint assertions_on_constants
<!--
Thank you for making Clippy better!
We're collecting our changelog from pull request descriptions.
If your PR only updates to the latest nightly, you can leave the
`changelog` entry as `none`. Otherwise, please write a short comment
explaining your change.
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.
- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [ ] `cargo test` passes locally
- [x] Executed `./util/dev update_lints`
- [ ] Added lint documentation
- [ ] Run `./util/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 -->
- [x] suggest replacing `assert!(false, "msg")` with `panic!("msg")`
- [x] extend to allow ~~variables~~ any expression for `"msg"`
- ~~suggest replacing `assert!(false, "msg {}", "arg")` with `panic!("msg {}", "arg")`~~
changelog: add assert message to suggestion in lint assertions_on_constants
Work towards fixing: #3575
Add suggestion for mul_add
Issue #4001: Whenever `a*b+c` is found where `a`,`b`, and `c` are floats, a lint is suggested saying to use `a.mul_add(b, c)`. Using `mul_add` may give a performance boost depending on the target architecture and also has higher numerical accuracy as there is no round off when doing `a*b`.
changelog: New lint: `manual_mul_add`
Fix typo in inherent_to_string documentation
A simple typo fix in `inherent_to_string` and `inherent_to_string_shadow_display` documentation
changelog: none
account for doc visibility
This fixes#4608.
Also I noticed that the lint failed to look at trait and impl items. There's a small bit of fallout in the code, too, but not enough to warrant its own commit.
changelog: check docs of trait items and impl items, also make `missing_safety_doc` account for visibility
Add check for assert_eq macros to unit_cmp lint
changelog: Add check for unit comparisons through `assert_eq!`, `debug_assert_eq!`, `assert_ne!` and `debug_assert_ne!` macros to unit_cmp lint.
fixes#4481
Use windows-sdk-10.1 to avoid installation failure
This fixes installation failure on Windows on Travis but we need to fix rustfmt issue first to pass the CI completely.
changelog: none
Rollup of 2 pull requests
Successful merges:
- #4509 (Fix false-positive of redundant_clone and move to clippy::perf)
- #4614 (Allow casts from the result of `abs` to unsigned)
Failed merges:
changelog: none
r? @ghost
Fix false-positive of redundant_clone and move to clippy::perf
This PR introduces dataflow analysis to `redundant_clone` lint to filter out borrowed variables, which had been incorrectly detected.
Depends on https://github.com/rust-lang/rust/pull/64207.
changelog: Moved `redundant_clone` lint to `perf` group
# What this lint catches
## `clone`/`to_owned`
```rust
let s = String::new();
let t = s.clone();
```
```rust
// MIR
_1 = String::new();
_2 = &_1;
_3 = clone(_2); // (*)
```
We can turn this `clone` call into a move if
1. `_2` is the sole borrow of `_1` at the statement `(*)`
2. `_1` is not used hereafter
## `Deref` + type-specific `to_owned` method
```rust
let s = std::path::PathBuf::new();
let t = s.to_path_buf();
```
```rust
// MIR
_1 = PathBuf::new();
_2 = &1;
_3 = call deref(_2);
_4 = _3; // Copies borrow
StorageDead(_2);
_5 = Path::to_path_buf(_4); // (*)
```
We can turn this `to_path_buf` call into a move if
1. `_3` `_4` are the sole borrow of `_1` at `(*)`
2. `_1` is not used hereafter
# What this PR introduces
1. `MaybeStorageLive` that determines whether a local lives at a particular location
2. `PossibleBorrowerVisitor` that constructs [`TransitiveRelation`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/transitive_relation/struct.TransitiveRelation.html) of possible borrows, e.g. visiting `_2 = &1; _3 = &_2:` will result in `_3 -> _2 -> _1` relation. Then `_3` and `_2` will be counted as possible borrowers of `_1` in the sole-borrow analysis above.