Commit Graph

7868 Commits

Author SHA1 Message Date
JarredAllen 5a21661ce5 Some bugfixing 2020-02-28 12:40:13 -08:00
JarredAllen ce0dc9b70e Created floating point abs lint and test, but not yet run 2020-02-27 22:31:41 -08:00
bors 610bceae71 Auto merge of #5232 - JohnTitor:git2-0.12, r=phansch
Update git2 to 0.12

changelog: none
2020-02-27 09:52:56 +00:00
Yuki Okushi 43e760ce1d Update git2 to 0.12 2020-02-27 16:13:05 +09:00
bors 384593cd16 Auto merge of #5231 - JohnTitor:associated-type-defaults, r=phansch
Rustup to rust-lang/rust#61812

changelog: none
2020-02-27 06:40:31 +00:00
Yuki Okushi 7c760e5f83 Rustup to rust-lang/rust#61812 2020-02-27 12:19:18 +09:00
bors 2734e4e1f7 Auto merge of #4897 - krishna-veerareddy:issue-2040-accurate-float-functions, r=flip1995
Add lint to improve floating-point expressions

Looks for floating-point expressions that can be expressed using built-in methods to improve accuracy, performance and/or succinctness.

changelog: Add lint `floating_point_improvements`.

Fixes #4726
Partly addresses [#2040](https://github.com/rust-lang/rust-clippy/issues/2040)

Currently linted expressions:

| Expression | Suggestion |
|---------------------------------|------------|
| x.log(2.0) | x.log2() |
| x.log(10.0) | x.log10() |
| x.log(std::f32::consts::E) | x.ln() |
| (1 + x).ln() | x.ln_1p() |
| (2.0).powf(x) | x.exp2() |
| (std::f32::consts::E).powf(x) | x.exp() |
| x.powf(1/2) | x.sqrt() |
| x.powf(1/3) | x.cbrt() |
| x.powf(y), where y is whole | x.powi(y) |
| x.exp() - 1 | x.exp_m1() |
|x * y + z|x.mul_add(y, z)|
2020-02-24 08:33:03 +00:00
bors c6ad3db8b5 Auto merge of #5222 - JohnTitor:dont-deploy, r=flip1995
Do not run deploy action on other repos

Usually, we don't have to run deploy action on other repos, let's ignore there.

changelog: none
2020-02-24 08:20:10 +00:00
Krishna Sai Veera Reddy ff0d44e45a Add `imprecise_flops` lint
Add lint to detect floating point operations that can be computed more
accurately at the cost of performance. `cbrt`, `ln_1p` and `exp_m1`
library functions call their equivalent cmath implementations which is
slower but more accurate so moving checks for these under this new lint.
2020-02-23 22:36:15 -08:00
Krishna Sai Veera Reddy e94a167508 Rename `mul_add` test file and add general improvements 2020-02-23 22:20:34 -08:00
Krishna Sai Veera Reddy 4065ca9c8c Move `manual_mul_add` into `suboptimal_flops` lint 2020-02-23 22:20:34 -08:00
Krishna Sai Veera Reddy 454e505c12 Run rust-fix on tests 2020-02-23 22:20:34 -08:00
Krishna Sai Veera Reddy bc706e3ba9 Fix `powi` suggestion and add general improvements 2020-02-23 22:20:34 -08:00
Krishna Sai Veera Reddy 6dacb1aa67 Change lint name to `suboptimal_flops` 2020-02-23 22:20:34 -08:00
Krishna Sai Veera Reddy bc03f465c3 Remove lint for logarithm division identity 2020-02-23 22:20:34 -08:00
Krishna Veera Reddy fd2506bcbf Add type suffixes to unsuffixed method receiver suggestions 2020-02-23 22:20:34 -08:00
Krishna Veera Reddy de07c84903 Detect usage of `(x + 1).ln()` and suggest `x.ln_1p()` instead 2020-02-23 22:20:34 -08:00
Krishna Veera Reddy a60ae5d31c Split test cases into separate files 2020-02-23 22:20:34 -08:00
Krishna Veera Reddy de79733924 Lint expressions of the form `x.log(b) / y.log(b)` 2020-02-23 22:20:33 -08:00
Krishna Veera Reddy 9520d3dfa4 Suggest usage of `powi` method when applicable 2020-02-23 22:20:33 -08:00
Krishna Veera Reddy 1f4f357bf5 Consolidate the accuracy and efficiency lints
Merge the accuracy and efficiency lints into a single lint that
checks for improvements to accuracy, efficiency and readability
of floating-point expressions.
2020-02-23 22:20:33 -08:00
Krishna Veera Reddy c636c6a55b Add lints to detect inaccurate and inefficient FP operations
Add lints to detect floating point computations that are either
inaccurate or inefficient and suggest better alternatives.
2020-02-23 22:20:33 -08:00
Yuki Okushi ee91b5b2dd Do not run deploy action on other repos 2020-02-24 15:16:23 +09:00
bors fc5d0cc583 Auto merge of #5221 - JohnTitor:rustup, r=phansch
Rustup to rust-lang/rust#69366

changelog: none
2020-02-24 05:58:17 +00:00
Yuki Okushi 036ec5b63d Rustup to rust-lang/rust#69366 2020-02-24 13:33:04 +09:00
bors 7e49122f20 Auto merge of #5216 - krishna-veerareddy:issue-5192-fp-const-fn, r=flip1995
Prevent `missing_const_for_fn` on functions with const generic params

`const` functions cannot have const generic parameters so prevent the
`missing_const_for_fn` lint from firing in that case.

changelog: Fix false positive in `missing_const_for_fn`

Fixes #5192
2020-02-22 12:44:06 +00:00
Krishna Sai Veera Reddy 049079856b Prevent `missing_const_for_fn` on functions with const generic params
`const` functions cannot have const generic parameters so prevent the
`missing_const_for_fn` lint from firing in that case.
2020-02-21 19:56:44 -08:00
bors e342047068 Auto merge of #5029 - flip1995:wildcard_imports, r=phansch
New Lint: `wildcard imports`

Fixes #1228

### A few notes:
- I put this lint in the pedantic group, even though in the issue restriction was mentioned.
- Every fallout fix was automatically applied by `cargo fix` (This produced 3 `unused_imports` warnings) and are in commit 7e834c8. So reverting these changes wouldn't be a problem.

### A few ideas:
- A configuration to specify the amount of imported Items, where a `*` might be better.
- ~~A configuration to disable the lint for enums. Or just disable the lint for enums, since there is [`enum_glob_use`](https://rust-lang.github.io/rust-clippy/master/index.html#enum_glob_use)~~ I moved `enum_glob_use` into this lint in 12937f0

### A few quotes from the issue:
> Is there a way to ask the compiler about the modules or symbols that the current file is using?

Yes there is. I found it, once I was nearly finished implementing it myself. See 321d64a

> one hard optional feature would be to figure out what is currently used and add a suggestion to replace it with a full import list.

Yeah that was pretty hard, until I found the query for this. Queries are cool, but too hard to find.

> FWIW VS Code and Intellij IDEA both offer imports deglobbing which replace * with required imports.

And now, Clippy can do this too! 🎉

---

Your thoughts on the notes/ideas?

changelog: Add new lint [`wildcard imports`]. Add suggestion to [`enum_glob_use`]
2020-02-21 11:32:12 +00:00
flip1995 4dd2252b17
Fix suggestion for weird formattings 2020-02-21 11:14:19 +01:00
flip1995 b562a519e6
Don't use use ty::TyKind::* 2020-02-21 11:14:18 +01:00
flip1995 8472ecda0f
Fix fallout 2020-02-21 11:14:18 +01:00
flip1995 b67764d5cb
Add test for prelude import 2020-02-21 11:14:18 +01:00
flip1995 f4f781d5cf
Filter prelude glob imports 2020-02-21 11:14:17 +01:00
flip1995 06a6189376
Move enum_glob_use lint into wildcard_imports pass 2020-02-21 11:14:17 +01:00
flip1995 3f5ed28524
Let's do it the easy way
Queries are cool, but too hard to find.
2020-02-21 11:14:16 +01:00
flip1995 4229dbcf33
Run update_lints 2020-02-21 11:14:16 +01:00
flip1995 ba1d50cec1
Implement wildcard_imports lint 2020-02-21 11:02:25 +01:00
flip1995 8a572a540a
Add tests for wildcard_imports lint 2020-02-21 11:02:25 +01:00
bors acfcbee4a2 Auto merge of #5202 - krishna-veerareddy:issue-5201-move-lossy-float-literal-restriction, r=flip1995
Move check for lossy whole-number floats out of `excessive_precision`

changelog: Add new lint `lossy_float_literal` to detect lossy whole number float literals and move it out of `excessive_precision` again.

Fixes #5201
2020-02-21 09:43:55 +00:00
bors 8fbb23f254 Auto merge of #5213 - JohnTitor:warm-return-ty, r=flip1995
Use generator own DefId

Fixes #5207

changelog: Fix ICE in `missing_errors_doc`
2020-02-21 08:27:37 +00:00
bors 3fc24192a5 Auto merge of #5200 - nipunn1313:unneeded_field_pattern, r=flip1995
Move unneeded_field_pattern to restriction group

Fixes #1741

changelog: Move unneeded_field_pattern to pedantic group
2020-02-21 08:14:30 +00:00
Yuki Okushi 8abe4365f3 Use generator own DefId 2020-02-21 16:24:58 +09:00
Krishna Sai Veera Reddy 219c94d028 Separate out lint to check lossy whole number float literals 2020-02-20 22:33:36 -08:00
bors 0d7ae7bd6f Auto merge of #5211 - krishna-veerareddy:rustup-69072, r=flip1995
Rustup to rust-lang/rust#69072

changelog: none
2020-02-21 06:19:02 +00:00
Krishna Sai Veera Reddy ce896ae96d Rustup to rust-lang/rust#69072 2020-02-20 21:20:49 -08:00
bors f5b4acccf7 Auto merge of #5208 - matthiaskrgr:stderr, r=flip1995
rustup https://github.com/rust-lang/rust/pull/69325, update test stderr

changelog: none
2020-02-20 22:57:02 +00:00
Matthias Krüger 4f85bc2fe9 rustup https://github.com/rust-lang/rust/pull/69325, update test stderr 2020-02-20 23:54:10 +01:00
Nipunn Koorapati 78a2507736 Move unneeded_field_pattern to restriction group
Fixes https://github.com/rust-lang/rust-clippy/issues/1741
2020-02-20 13:20:18 -08:00
bors 8daeee5533 Auto merge of #5204 - flip1995:license, r=Manishearth
Update License

r? @Manishearth

I'm not sure if the Copyright claim was left out on purpose in the LICENSE-* files. I added them, because the official templates have them.

changelog: none
2020-02-20 16:23:53 +00:00
bors 5fbec44fd9 Auto merge of #5198 - sinkuu:redundant_clone_df, r=flip1995
redundant_clone: Migrate to new dataflow framework

Migration to [the new dataflow framework](https://github.com/rust-lang/rust/pull/65672) is ongoing in rustc. This PR updates the dataflow impl in `redundant_clone` lint.

---

changelog: none
2020-02-20 12:16:48 +00:00