Commit graph

3552 commits

Author SHA1 Message Date
Michael Wright
d1f0f04a48 New lint: manual-strip
Add a new lint, `manual-strip`, that suggests using the `str::strip_prefix`
and `str::strip_suffix` methods introduced in Rust 1.45 when the same
functionality is performed 'manually'.

Closes #5734
2020-09-14 06:11:35 +02:00
bors
231444d989 Auto merge of #6035 - matthiaskrgr:try_into_show_type, r=flip1995
useless_conversion: show type in error message.

changelog: useless_conversion: show type in error message.
2020-09-13 18:57:55 +00:00
Takayuki Nakata
9ff7e5d984 Downgrade verbose_bit_mask to pedantic 2020-09-13 23:23:45 +09:00
Matthias Krüger
7ba1a8fec4 useless_conversion: show type in error message.
changelog: useless_conversion: show type in error message.
2020-09-13 12:50:39 +02:00
Matthias Krüger
2487f8f461 into_iter_on_ref: rephrase lint message: will not move the x -> will not consume the x
imo that's a bit clearer.
2020-09-11 16:52:25 +02:00
bors
0ab75c37b6 Auto merge of #5977 - xvschneider:AddLintPanicInResult, r=matthiaskrgr
Add lint panic in result

### Change
Adding a new "restriction" lint that will emit a warning when using "panic", "unimplemented" or "unreachable" in a function of type option/result.

### Motivation
Some codebases must avoid crashes at all costs, and hence functions of type option/result must return an error instead of crashing.

### Test plan
Running:
TESTNAME=panic_in_result cargo uitest ---

changelog: none
2020-09-10 16:22:20 +00:00
bors
5034d47f72 Auto merge of #5980 - matsujika:create-dir, r=flip1995
Add a lint to prevent `create_dir` from being used

This closes #5950
changelog: none
2020-09-10 14:34:22 +00:00
bors
55efa96659 Auto merge of #5931 - montrivo:unit-arg, r=flip1995
improve the suggestion of the lint `unit-arg`

Fixes #5823
Fixes #6015

Changes
```
help: move the expression in front of the call...
  |
3 |     g();
  |
help: ...and use a unit literal instead
  |
3 |     o.map_or((), |i| f(i))
  |
```
into
```
help: move the expression in front of the call and replace it with the unit literal `()`
  |
3 |     g();
  |     o.map_or((), |i| f(i))
  |
```
changelog: improve the suggestion of the lint `unit-arg`
2020-09-10 14:11:27 +00:00
bors
87a4495b5d Auto merge of #6027 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2020-09-10 13:25:39 +00:00
flip1995
2d56512580
Cleanup of rustup 2020-09-10 15:23:38 +02:00
Vali Schneider
3550568a54 removing if chain and renaming lint 2020-09-09 14:02:34 -07:00
Matthias Krüger
de195f2d3d print the unit type () in related lint messages. 2020-09-09 17:59:13 +02:00
Aaron Hill
f23670ed68 Adjust Clippy for CONST_ITEM_MUTATION lint
We no longer lint assignments to const item fields in the
`temporary_assignment` lint, since this is now covered by the
`CONST_ITEM_MUTATION` lint.

Additionally, we `#![allow(const_item_mutation)]` in the
`borrow_interior_mutable_const.rs` test. Clippy UI tests are run with
`-D warnings`, which seems to cause builtin lints to prevent Clippy
lints from running.
2020-09-08 17:59:56 -04:00
Hirochika Matsumoto
a899ad2e12 Change suggestion to create_dir_all({}) from std::fs::create_dir_all({}) 2020-09-08 23:35:19 +09:00
Takayuki Nakata
952c04674e Refactoring: tests in same_item_push 2020-09-08 23:03:15 +09:00
Takayuki Nakata
2c9f82e7d2 Add some tests to same_item_push
Add tests in which the variable is initialized with a match expression and function call
2020-09-08 22:45:27 +09:00
Takayuki Nakata
3d30ef7818 Restrict same_item_push to suppress false positives
It emits a lint when the pushed item is a literal, a constant and an immutable binding that are initialized with those.
2020-09-07 23:46:43 +09:00
Eduardo Broto
9fa9208bd5 Restrict unnecessary_sort_by to non-ref copy types 2020-09-07 00:19:17 +02:00
bors
e9440cbcde Auto merge of #5997 - giraffate:fix_fp_about_clone_in_same_item_push, r=ebroto
Fix FP in `same_item_push`

Don't emit a lint when the pushed item doesn't have Clone trait

Fix #5979

changelog: Fix FP in `same_item_push` not to emit a lint when the pushed item doesn't have Clone trait
2020-09-05 20:27:17 +00:00
Takayuki Nakata
96b31a5b36 Fix FP when coercion kicks in 2020-09-06 00:02:35 +09:00
Ryan1729
9e7ce9d385 run the specific script suggested by the error message
```
./tests/ui-toml/update-references.sh './target/debug/test_build_base' 'functions_maxlines/test.rs'
```
2020-09-04 21:12:16 -06:00
Ryan1729
db16fa26ce run tests/ui/update-all-references.sh 2020-09-04 20:16:02 -06:00
Eduardo Broto
23646e6583 Merge remote-tracking branch 'upstream/master' into sync-from-rust 2020-09-04 23:27:01 +02:00
bors
8829214764 Auto merge of #5994 - taiki-e:useless_attribute, r=phansch
useless_attribute: Permit wildcard_imports and enum_glob_use

Fixes #5918

changelog: `useless_attribute`: Permit `wildcard_imports` and `enum_glob_use` on `use` items
2020-09-03 05:33:03 +00:00
Michael Wright
93ce686b5d Update ui stderr with improved rustc output
Related rust pull request: rust-lang/rust#76160
2020-09-03 04:58:14 +02:00
Tim Nielens
b1f0e019fe Merge branch 'master' into unit-arg 2020-09-02 19:39:54 +02:00
bors
7f27b12288 Auto merge of #5996 - Koxiaet:master, r=ebroto
Allow GraphQL in docs without backticks

changelog: Allow "GraphQL" in [`doc_markdown`] without backticks.
2020-09-02 12:24:31 +00:00
Koxiaet
22c9940613 Add tests for allowed non-backticked identifiers in doc 2020-09-02 12:51:44 +01:00
Sasha
246f1f8a8e Improve recovery on malformed format call
If a comma in a format call is replaced with a similar token, then we
emit an error and continue parsing, instead of stopping at this point.
2020-09-02 13:18:19 +02:00
Takayuki Nakata
aa7ffa5257 Fix FP in same_item_push
Don't emit a lint when the pushed item doesn't have Clone trait
2020-09-01 22:39:09 +09:00
Taiki Endo
2e4b4cebbb useless_attribute: Permit wildcard_imports and enum_glob_use 2020-09-01 12:09:32 +09:00
rail
afeb917fca Fix a fp in transmute_ptr_to_ptr
Avoid firing the lint when `transmute` in const contexts
as dereferencing raw pointers in consts is unstable. cc #5959
2020-09-01 11:51:32 +12:00
bors
67e18c2d5c Auto merge of #5993 - taiki-e:default_trait_access, r=phansch
default_trait_access: Fix wrong suggestion

https://github.com/rust-lang/rust-clippy/issues/5975#issuecomment-683751131
> I think the underlying problem is clippy suggests code with complete parameters, not clippy triggers this lint even for complex types. AFAIK, If code compiles with `Default::default`, it doesn't need to specify any parameters, as type inference is working. (So, in this case, `default_trait_access` should suggest `RefCell::default`.)

Fixes #5975 Fixes #5990

changelog: `default_trait_access`: fixed wrong suggestion
2020-09-01 15:05:16 +00:00
bors
066f105d67 Auto merge of #5992 - giraffate:fix_wrong_seggestion_in_collapsible_if, r=yaahc
Fix the wrong suggestion when using macro in `collapsible_if`

Fix #5962

changelog: Fix the wrong suggestion when using macro in `collapsible_if`
2020-08-31 19:41:13 +00:00
bors
8334a58c2f Auto merge of #5909 - khuey:async_yields_async, r=yaahc
Add a lint for an async block/closure that yields a type that is itself awaitable.

This catches bugs of the form

tokio::spawn(async move {
    let f = some_async_thing();
    f // Oh no I forgot to await f so that work will never complete.
});

See the two XXXkhuey comments and the unfixed `_l` structure for things that need more thought.

*Please keep the line below*
changelog: none
2020-08-31 19:20:30 +00:00
Taiki Endo
8b0aa6a00b default_trait_access: Fix wrong suggestion 2020-09-01 00:31:53 +09:00
Takayuki Nakata
001f9e45f2 Fix the wrong suggestion when using macro in collapsible_if 2020-09-01 00:05:53 +09:00
Hirochika Matsumoto
451ef78803 Use match_def_path instead of match_qpath 2020-08-31 22:40:47 +09:00
Vali Schneider
a424a2c167 changed check_impl_item to check_fn and added a few more test cases 2020-08-29 16:17:53 -07:00
Kyle Huey
c1d2b9376a Add a test for an async function. 2020-08-29 15:33:54 -07:00
Kyle Huey
4972989b61 Add a lint for an async block/closure that yields a type that is itself awaitable.
This catches bugs of the form

tokio::spawn(async move {
    let f = some_async_thing();
    f // Oh no I forgot to await f so that work will never complete.
});
2020-08-29 15:33:54 -07:00
Eduardo Broto
7a66e6502d or_fn_call: ignore nullary associated const fns 2020-08-29 01:20:49 +02:00
flip1995
282c59820b Merge commit '3d0b0e66afdfaa519d8855b338b35b4605775945' into clippyup 2020-08-28 18:43:25 +02:00
bors
3d0b0e66af Auto merge of #5774 - ThibsG:FixNewRetNoSelf, r=ebroto
Fix FP in `new_ret_no_self`: trigger in trait def instead of impl block

Lint in trait def instead of impl block.

Fixes: #5435

changelog: none
2020-08-28 11:54:07 +00:00
Hirochika Matsumoto
5574182b4d Add a new lint to prevent create_dir from being used 2020-08-28 18:45:28 +09:00
Vali Schneider
b006522393 added lint for todo and removed option 2020-08-27 16:55:23 -07:00
bors
07c5e9edb5 Auto merge of #5971 - giraffate:fix_fp_in_to_string_in_display, r=ebroto
Fix FP in `to_string_in_display`

Don't emit a lint when `.to_string()` on anything that is not `self`

Fix #5967

changelog: Fix FP in `to_string_in_display` when calling `.to_string()` on anything that is not `self`
2020-08-27 23:26:52 +00:00
Vali Schneider
459969f88f added restriction lint that prohibits the usage of unimplemented, unreachable or panic in a function of type result or option 2020-08-27 16:18:05 -07:00
Tim Nielens
f3ccbef2af unit-arg - pr comments 2020-08-27 19:36:28 +02:00
ThibsG
3cb75c2e5c Remove expansion restriction + fix doc and tests naming 2020-08-27 18:25:38 +02:00