Commit Graph

6959 Commits

Author SHA1 Message Date
James Wang
adf58868e9
Change terminology from static to associated 2019-10-15 09:58:12 +02:00
James Wang
8b50599cb4
Switch to OnlyBodies 2019-10-15 09:58:12 +02:00
James Wang
e23a424b31
Change lint to be pedantic 2019-10-15 09:58:11 +02:00
James Wang
e64b27525b
Remove prints 2019-10-15 09:58:11 +02:00
James Wang
664522badd
Add a new lint for unused self 2019-10-15 09:58:11 +02:00
bors
8fae2dd3c1 Auto merge of - rust-lang:must-use-pure, r=phansch
new lints around`#[must_use]`

changelog: Add `must_use_candidate` lint,  add `must-use-unit` lint, add `double_must_use` lint

The first one checks if an public function or method has no mutable argument and mutates no non-local data and lints if it has no `#[must_use]` attribute. It will skip inner functions, because those are usually highly local and the attribute doesn't have as much benefit there.

The second lints `#[must_use]` attributes on functions and methods that return unit. Those attributes are likely a remnant from a refactoring that removed the return value.

The last one lints for `#[must_use]` attributrs without text on functions that return a type which is already marked `#[must_use]`. This has no auto-suggestion, because while it would be easy to do, there may be value in writing a detailed text for the attribute instead.

This fixes 
2019-10-14 17:33:30 +00:00
bors
c40d7db6ed Auto merge of - lzutao:rustup, r=phansch
Rustup

changelog: none

Suppresses .

r? @phansch
2019-10-14 17:00:46 +00:00
Andre Bogus
cc622608db new lints around #[must_use] fns
`must_use_unit` lints unit-returning functions with a `#[must_use]`
attribute, suggesting to remove it.

`double_must_use` lints functions with a plain `#[must_use]`
attribute, but which return a type which is already `#[must_use]`,
so the attribute has no benefit.

`must_use_candidate` is a pedantic lint that lints functions and
methods that return some non-unit type that is not already
`#[must_use]` and suggests to add the annotation.
2019-10-14 12:09:04 +02:00
Lzu Tao
974a05b806 rustc-dev has been temporarily removed 2019-10-14 10:25:05 +07:00
Lzu Tao
c56784e2b8 Use my RTIM fork 2019-10-14 02:27:46 +07:00
Manish Goregaokar
6693199c0b Bump compiletest 2019-10-14 00:46:39 +07:00
bors
a865d0ad73 Auto merge of - Lythenas:use_match_function_call, r=phansch
Use match_function_call wherever possible

Move `match_function_call` to `utils` and use it wherever possible as discussed in .

changelog: none
2019-10-12 06:40:13 +00:00
bors
4d0e897394 Auto merge of - lzutao:rustc-dev, r=phansch
Rustup for rustc-dev

cc https://github.com/rust-lang/rust/pull/64823
Closes 
changelog: none
2019-10-12 06:00:52 +00:00
Lzu Tao
83f04442ec use git version 2019-10-12 10:18:31 +07:00
Lzu Tao
dce46325b5 Rustup for rustc-dev 2019-10-11 15:53:55 +07:00
Matthias Seiffert
15b433af48 Use match_function_call wherever possible 2019-10-10 20:06:04 +02:00
Matthias Seiffert
37a2de1562 Move match_function_call to utils 2019-10-10 10:57:12 +02:00
bors
5317efb8b5 Auto merge of - lzutao:make-pr-guides-visible, r=flip1995
PR template might not be stripped by contributors

cc d97fbdbb42

So I think it would be better to make the template visible.
Also I renamed the template with extension `.md`.

changelog: none
2019-10-10 07:14:41 +00:00
Lzu Tao
871b30266c PR template might not be stripped by contributors 2019-10-10 00:57:57 +07:00
bors
db233b0920 Auto merge of - mati865:license, r=Manishearth
Fix license in Cargo.toml files

Missed in https://github.com/rust-lang/rust-clippy/pull/3269

changelog: none

r? @Manishearth
2019-10-09 16:09:26 +00:00
bors
0583181d03 Auto merge of - nikofil:suspicious_unary_op_formatting, r=flip1995
New lint: suspicious_unary_op_formatting

fixes 

changelog: New lint: [`suspicious_unary_op_formatting`]
2019-10-09 15:26:33 +00:00
Nikos Filippakis
5143fe1a78 New lint: suspicious_unary_op_formatting
Lints when, on the RHS of a BinOp, there is a UnOp without a space
before the operator but with a space after (e.g. foo >- 1).

Signed-off-by: Nikos Filippakis <nikolaos.filippakis@cern.ch>
2019-10-09 16:22:00 +02:00
bors
d97fbdbb42 Auto merge of - Lythenas:suggestions-for-assert-false, r=flip1995
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: 
2019-10-09 08:56:30 +00:00
bors
1dc7f5c0bc Auto merge of - EthanTheMaster:issue-4001, r=flip1995
Add suggestion for mul_add

Issue : 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`
2019-10-08 16:17:48 +00:00
Ethan Lam
327c91f8c7 Addresses Issue
Fixed typo

Fixes lint name and uses appropriate linting suggestion

changed lint help message

Added autofixable test

Added Autofixable Test

Removed Broken Autofixable File

updated lints

Generated Autofixable/Nonfixable Test Cases

Changed Suggestion Applicability

Updated Lint Count
2019-10-08 08:46:29 -05:00
bors
5cb983338e Auto merge of - sinkuu:revert_workaround, r=phansch
Revert "Workaround cargo bug on Windows"

[Cargo is fixed on rust master](https://github.com/rust-lang/rust/pull/65186). This reverts PR .

Fixes 

changelog: none
2019-10-08 08:36:26 +00:00
bors
30a3992e97 Auto merge of - kerhong:fix-typo-in-inherent-to-string, r=phansch
Fix typo in inherent_to_string documentation

A simple typo fix in `inherent_to_string` and `inherent_to_string_shadow_display` documentation

changelog: none
2019-10-08 07:52:44 +00:00
bors
b690cdb1e7 Auto merge of - rust-lang:doc-visibility, r=flip1995
account for doc visibility

This fixes .

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
2019-10-08 07:11:26 +00:00
bors
bbad77a12a Auto merge of - rust-lang:rustbot, r=flip1995
Allow everyone to assign labels with rustbot

Also allows people to claim issues even if they aren't part of the org

changelog: none
2019-10-08 06:30:50 +00:00
bors
e2393b09ac Auto merge of - rust-lang:transmute-collection, r=flip1995
New lint: `unsound_collection_transmute`

changelog: Add `unsound_collection_transmute` lint

This fixes 
2019-10-08 05:51:07 +00:00
Shotaro Yamada
d2daf8ecf6 Revert "Workaround cargo bug on Windows"
This reverts commit 248251b3b2.
This reverts commit 20b7351439.
2019-10-08 14:21:05 +09:00
bors
df80193bda Auto merge of - flip1995:rustup, r=phansch
Rustup to 

TODO:
- [x] replace `rvalue_promotable_map` in [1]
- [ ] ~~fix [2] according to this comment https://github.com/rust-lang/rust/pull/64874#issuecomment-536203626 this should be merged with `consume`, but I didn't figure out how to merge them, yet.~~
- [ ] ~~fix [3]; What to do with `LoanCause`?~~

[2]+[3] probably have to be resolved by a rewrite of the lint. https://github.com/rust-lang/rust-clippy/pull/4628#issuecomment-538574944

[1]
54bf4ffd62/clippy_lints/src/methods/mod.rs (L1292-L1299)

[2]
54bf4ffd62/clippy_lints/src/escape.rs (L126)

[3]
54bf4ffd62/clippy_lints/src/escape.rs (L166-L176)

I could need some help with [1]. The purpose of this is to "don't lint for constant values". cc @matthewjasper

For now I see what I can do with [2].

changelog: Temporary break `boxed_local` lint.
2019-10-08 05:09:53 +00:00
Matthias Seiffert
6ee8d751f6 Reduce duplication 2019-10-07 22:08:00 +02:00
Matthias Seiffert
22f057972f Match any expr for panic message 2019-10-07 20:40:05 +02:00
Matthias Seiffert
d66acc23a9 Make if_chain more readable 2019-10-07 19:13:10 +02:00
Matthias Seiffert
72a5d7b612 Add message to replace assert!(false) help 2019-10-07 19:13:10 +02:00
flip1995
3d39379f9c
Move is_argument check into mutate 2019-10-06 14:49:26 +02:00
flip1995
3aa531c194
Run util/dev fmt 2019-10-05 12:42:09 +02:00
flip1995
3b23092b69
Get rid of rvalue_promotable_map method call 2019-10-05 12:38:38 +02:00
flip1995
b7d473503b
Merge consume and consume_pat in escape analysis
FIXME: This doesn't work and probably needs a rewrite of the lint

See https://github.com/rust-lang/rust-clippy/pull/4628#issuecomment-538574944
2019-10-05 12:23:59 +02:00
Mateusz Mikuła
4f1d907462 Use new format of licenses
Co-Authored-By: lzutao <taolzu@gmail.com>
2019-10-04 17:40:32 +02:00
flip1995
c420b07191
Fix needless_pass_by_value
This also accidentally improved the spans of the suggestions
2019-10-04 15:39:46 +02:00
flip1995
b46f5b4a98
Rustup to
Episode 1 - The simple cases
2019-10-04 15:39:46 +02:00
bors
54bf4ffd62 Auto merge of - Lythenas:lint-assert_eq-unit_exprs, r=flip1995
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 
2019-10-04 10:27:44 +00:00
Edgars Baduns
a1137a8439 Fix typo in inherent_to_string documentation 2019-10-04 10:58:53 +01:00
bors
933df2ab8e Auto merge of - JohnTitor:fix-windows, r=phansch
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
2019-10-04 09:35:54 +00:00
bors
249b6cac3e Auto merge of - phansch:rollup-qp7ki0h, r=phansch
Rollup of 2 pull requests

Successful merges:

 -  (Fix false-positive of redundant_clone and move to clippy::perf)
 -  (Allow casts from the result of `abs` to unsigned)

Failed merges:

changelog: none

r? @ghost
2019-10-04 06:45:04 +00:00
bors
c926f1b571 Auto merge of - Lythenas:fix-doc-formatting-for-mistyped-literal-suffixes, r=phansch
Correctly align doc of mistyped literal suffixes

changelog: Fix misaligned markdown list in doc of `mistyped_literal_suffixes`
2019-10-04 06:13:47 +00:00
Phil Hansch
19c58d260b
Rollup merge of - HMPerson1:abs_cast_unsigned, r=flip1995
Allow casts from the result of `abs` to unsigned

changelog: Allow casts from the result of `abs` to unsigned in `cast_sign_loss`

Fixes 
2019-10-04 08:08:59 +02:00
Phil Hansch
8d2912ec00
Rollup merge of - sinkuu:redundant_clone_fix, r=llogiq
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.
2019-10-04 08:08:58 +02:00