Commit Graph

3529 Commits

Author SHA1 Message Date
bors
ba246c8262 Auto merge of #5183 - JohnTitor:fix-fp-import, r=matthiaskrgr
Don't lint `single_component_path_imports` in macros

Fixes #5154

changelog: Fix false positive in `single_component_path_imports`
2020-02-17 03:33:01 +00:00
Yuki Okushi
09165ff576 Don't lint single_component_path_imports in macros 2020-02-17 11:13:42 +09:00
Yuki Okushi
4480ec5b71 Rustup to rust-lang/rust#67953 2020-02-17 11:07:26 +09:00
Matthew Jasper
787398aa53 Avoid using regions from TypeckTables
These regions will all be `ReErased` soon.
2020-02-15 16:24:49 +00:00
bors
779b6aeaa6 Auto merge of #4809 - iankronquist:patch-1, r=flip1995
Typo in literal_representation.rs

Octal numbers can't have 8 in them ;)

changelog: none
2020-02-15 15:12:14 +00:00
flip1995
4a9bfe4184
Let update_lints also generate the internal lints 2020-02-14 14:37:56 +01:00
Matthias Krüger
fa0ad30465 deps: update pulldown-cmark from 0.6 to 0.7 2020-02-13 22:01:26 +01:00
bors
96c2e62d57 Auto merge of #5168 - lily-commure:chars_next_style, r=flip1995
Reclassify chars_next_cmp as a style lint.

This makes it consistent with chars_last_cmp.

changelog: none
2020-02-13 12:54:28 +00:00
Yuki Okushi
f77158bc14 Fix false positive in zero_prefixed_literal 2020-02-13 14:39:29 +09:00
Lily Chung
385fd7cd0a change in the right place, run update_lints 2020-02-12 17:03:49 -08:00
flip1995
57b636422a
Rustup to rust-lang/rust#68725 2020-02-10 15:59:21 +01:00
bors
c066807a70 Auto merge of #5148 - krishna-veerareddy:issue-5147-option-env-unwrap, r=flip1995
Add `option-env-unwrap` lint

changelog: Add `option-env-unwrap` lint

Fixes #5147
2020-02-10 08:08:53 +00:00
Krishna Sai Veera Reddy
46bd185e32 Rustup to rust-lang/rust#68911 2020-02-09 14:44:17 -08:00
Krishna Sai Veera Reddy
a3a1587a1c Allow option-env-unwrap within external macros 2020-02-09 10:58:08 -08:00
Krishna Sai Veera Reddy
0e5ba2f0e7 Account for expect being used to unwrap Option 2020-02-09 08:54:23 -08:00
Lzu Tao
5328b5d667 Rustup "index ReEmpty by universe" 2020-02-09 15:31:47 +07:00
Krishna Sai Veera Reddy
be1bc571c3 Add option-env-unwrap lint 2020-02-08 16:44:35 -08:00
bors
b5e6d6db41 Auto merge of #5134 - flip1995:snippet_block, r=phansch
Make it possible to correctly indent snippet_block snippets

This adds a `indent_relative_to` arg to the `{snippet,expr}_block` functions. This makes it possible to keep the correct indentation of block like suggestions.

In addition, this makes the `trim_multiline` function private and adds a `indent_of` function, to get the indentation of the first line of a span.

The suggestion of `needless_continue` cannot be made auto applicable, since it would be also necessary to remove code following the linted expression. (Well, maybe it is possible, but I don't know how to do it. Expanding the suggestion span to the last expression, that should be removed didn't work)

changelog: Improve suggestions, when blocks of code are involved
2020-02-06 21:41:50 +00:00
flip1995
9897927504
Rustup to rust-lang/rust#68788 2020-02-06 20:33:39 +01:00
flip1995
e23881e131
Rename ctx->cx in needless_continue 2020-02-06 19:15:01 +01:00
flip1995
4068ff4d8a
Improve help message in needless_continue 2020-02-06 19:15:01 +01:00
flip1995
c7979d3515
Fix rebase fallout 2020-02-06 19:15:01 +01:00
flip1995
250c1842b1
Document the indent_relative_to arg of snippet_block 2020-02-06 19:15:01 +01:00
flip1995
cd0f0946cf
Move tests to the end of the file in utils mod.rs 2020-02-06 19:15:00 +01:00
flip1995
f1a72e992d
Update needless_continue stderr 2020-02-06 19:13:46 +01:00
flip1995
8e15985827
Rewrite suggestion generation of needless_continue 2020-02-06 19:13:46 +01:00
flip1995
19f08c200e
Make block_in_if_condition auto applicable 2020-02-06 19:13:46 +01:00
flip1995
5fd22b3f93
Optionally indent snippet_block relative to an Expr 2020-02-06 19:13:45 +01:00
bors
a6f310ed0e Auto merge of #5139 - lzutao:linecount, r=llogiq
dev: Use bytecount for faster line count

changelog: none
2020-02-06 15:31:01 +00:00
bors
75e983a518 Auto merge of #5125 - Areredify:too_many_bools, r=flip1995
Port mitsuhiko's excessive bools lints

Closes #4 .
changelog: add `struct_excessive_bools` and `fn_params_excessive_bools` lints.
I moved is_trait_impl_item check because at first I implemented it as a late pass for some reason but then I realized it's actually an early lint. But it's a useful function to have, should I move it into a separate pr?
2020-02-06 14:47:14 +00:00
Lzu Tao
8794e41728 dev: Use bytecount for faster line count 2020-02-06 21:39:15 +07:00
bors
a3135ba131 Auto merge of #5132 - JohnTitor:fix-fp-in-unwrap-lint, r=flip1995
Do not lint `unnecessary_unwrap` in external macros

Fixes #5131

I think we shouldn't lint `{panicking, unnecessary}_unwrap` in macros, not just `assert!`.

changelog: Fix false positive in `unnecessary_unwrap`
2020-02-06 14:17:35 +00:00
Areredify
338fb7a3e9 add excessive bools lints 2020-02-05 20:54:58 +03:00
Areredify
8e28b2fdf1 move is_trait_impl_item check from functions.rs to utils 2020-02-05 18:11:20 +03:00
bors
c881aca282 Auto merge of #5135 - lzutao:config, r=flip1995
Few improvement to `utils::conf` module

* Fix a few typos
* Handle Option<&Path> early
* Use `env::var_os` when possible

changelog: none
2020-02-05 09:58:15 +00:00
Lzu Tao
32924c6ce0 Few improvement to utils::conf module
* Fix a few typos
* Handle Option<&Path> early
* Use `env::var_os` when possible
2020-02-05 09:06:34 +07:00
ThibsG
00904cb100 Manage macros case + move to MaybeIncorrect when binding values 2020-02-04 22:54:42 +01:00
ThibsG
b29aacfec8 Add wild and struct handling 2020-02-04 22:53:24 +01:00
ThibsG
6afd7ea147 Use span_lint_and_sugg + move infaillible lint
- moving infaillible lint to prevent collisions
2020-02-04 22:49:08 +01:00
Yuki Okushi
19ce66c1c1 Re-cover use of unnecessary unwraps in macros 2020-02-05 05:38:26 +09:00
ThibsG
3445d41f07 Add new lint: match with a single binding statement
- Lint name: MATCH_SINGLE_BINDING
2020-02-04 01:06:16 +01:00
Yuki Okushi
514b1bc2af Do not lint unnecessary_unwrap in macros 2020-02-04 04:01:42 +09:00
bors
a39589480b Auto merge of #5129 - JohnTitor:use-checked-sub, r=flip1995
Use `checked_sub` to avoid index out of bounds

(Fixes) #4681 (possibly)

The issue likely occurs due to `lit_snip.len() < suffix.len() + 1`. You can see similar backtrace to change it to `lit_snip.len() - suffix.len() - 1000` or something then run `cargo test --release`.
But I couldn't come up with the test so I'd leave the issue open if we want.

changelog: Fix potential ICE in `misc_early`
2020-02-03 16:47:25 +00:00
Areredify
66ad544175 improve 'iter_nth_zero' documentation 2020-02-03 15:44:55 +03:00
Yuki Okushi
bae129ac69 Use checked_sub to avoid index out of bounds 2020-02-03 15:19:54 +09:00
bors
c6b87ef54a Auto merge of #5119 - JohnTitor:tweak-doc, r=flip1995
Tweak documentation in `multiple_crate_versions`

This example isn't reproducible now since `ctrlc` upgrades `winapi` to `0.3.x` in `3.1.1`. We should pin their versions to trigger lint correctly.

changelog: none
2020-02-02 17:48:12 +00:00
Yuki Okushi
f63a6a5baf Rustup to rust-lang/rust#68133 2020-02-02 06:56:27 +09:00
Yuki Okushi
0f67a7ecb5 Pin versions to trigger lint correctly 2020-02-01 20:11:32 +09:00
flip1995
5ba4aa8eba
Move debug_assertions_with_mut_call to nursery 2020-01-31 10:57:52 +01:00
flip1995
9fbd7f478e
Don't trigger debug_assert_with_mut_call on .await 2020-01-31 10:39:05 +01:00
flip1995
b31a3dff48
Small refactor of mutable_debug_assertions 2020-01-31 10:39:04 +01:00
bors
8e9089e454 Auto merge of #5110 - Aloso:patch-1, r=flip1995
Fix syntax highlighting of code fences

The documentation for RESULT_EXPECT_USED includes this code:

    let res: Result<usize, ()> = Ok(1);
    res?;
    # Ok::<(), ()>(())

Because the code fence didn't start with `rust`, the code wasn't highlighted and the line starting with `#` was displayed on the website. This is now fixed.

EDIT: I noticed that highlighting for some other lints is broken as well. It only works if the code fence looks like this:

````markdown
```rust
// ..
```
````

However, many code blocks were ignored. I un-ignored most code blocks and made them compile by adding hidden code with `#`. While doing so, I found two mistakes:

```rust
opt.map_or(None, |a| a + 1)
// instead of
opt.map_or(None, |a| Some(a + 1))
```
and

```rust
fn as_str(self) -> &str
// instead of
fn as_str(self) -> &'static str
```

changelog: none
2020-01-30 23:24:53 +00:00
Ludwig Stecher
1f600f3f9a Un-ignore most code blocks to render correctly on website, correct mistakes 2020-01-30 23:44:37 +01:00
Ludwig Stecher
58da5ba6db Fix code formatting for more lints 2020-01-30 22:12:00 +01:00
Ludwig Stecher
f0dc98160b
Fix syntax highlighting of code fence
The documentation for RESULT_EXPECT_USED includes this code:

    let res: Result<usize, ()> = Ok(1);
    res?;
    # Ok::<(), ()>(())

Because the code fence didn't start with `rust`, the code wasn't highlighted and the line starting with `#` was displayed on the website. This is now fixed.
2020-01-30 21:55:30 +01:00
Areredify
63ab7a5e8c lint all guard types, not just lock functions 2020-01-30 18:46:22 +03:00
Mikhail Babenko
9b88a2b295 decouple 'let_underscore' tests 2020-01-30 16:51:23 +03:00
Mikhail Babenko
d1f8621711 add lint 2020-01-30 16:48:56 +03:00
xiongmao86
ac9f019fbf Reformat code. 2020-01-30 00:23:47 +08:00
xiongmao86
512efbea23 Declare lint and implement lint logic. 2020-01-30 00:21:29 +08:00
Yuki Okushi
66524c5be0 Rustup to rust-lang/rust#68512 2020-01-29 17:15:56 +09:00
Yuki Okushi
f5e86d6894 Rename span_note_and_lint to span_lint_and_note 2020-01-27 11:26:42 +09:00
Yuki Okushi
f60f12f71f Rename span_help_and_lint to span_lint_and_help 2020-01-27 11:17:58 +09:00
bors
4f65bec39a Auto merge of #5084 - JohnTitor:clean-up-span-lint, r=flip1995
Clean up `span_lint` in `methods/mod.rs`

Uses `span_help_and_lint` instead of `span_lint` and `span_lint_and_sugg` instead of `span_lint_and_then`.

changelog: none
2020-01-26 15:28:39 +00:00
Eduard-Mihai Burtescu
0e52a0ed6d Don't use ExpnKind::descr to get the name of a bang macro. 2020-01-26 03:12:44 +02:00
Yuki Okushi
4b133f2867 Apply review comments 2020-01-26 07:01:16 +09:00
bors
fd6f609f64 Auto merge of #5083 - Areredify:issue-4399, r=flip1995
dont fire `possible_missing_comma` if intendation is present

Closes #4399
changelog: dont fire `possible_missing_comma` if intendation is present

I suspect there is already a utils function for indentation (but searching indent didn't yield a function for that), and my solution is certainly not universal, but it's probably the best we can do.
2020-01-25 17:47:54 +00:00
Mikhail Babenko
a234aef084 dont fire possible_missing_comma if intendation is present 2020-01-25 20:16:05 +03:00
bors
6b5419412e Auto merge of #5081 - Areredify:vec_box_threshold, r=flip1995
add size parameter for `vec_box`  lint

changelog: add size threshold for the `vec_box` lint, currently 4096 bytes (one page) (subject to change). Closes #3547.

diff is a little bit confusing due to some refactoring (moving free functions to lint struct functions), relevant portion is [this](https://github.com/rust-lang/rust-clippy/compare/master...Areredify:vec_box_threshold?expand=1#diff-1096120ca9143af89dcc9175ea92b54aR294-R298). In hindsight should've been different commits, but oh well.
2020-01-25 16:11:43 +00:00
Mikhail Babenko
2b7bc260de add size parameter for lint 2020-01-25 18:06:52 +03:00
bors
87597b5a42 Auto merge of #5087 - Areredify:issue-4905, r=phansch
improve `empty_enum` documentation

closes #4905
changelog: improve `empty_enum` help message and documentation.
2020-01-24 22:30:07 +00:00
Mikhail Babenko
634774b89b don't fire empty_loop in no_std crates 2020-01-24 14:42:24 +03:00
Mikhail Babenko
199ae1714e improve empty_enum documentation 2020-01-24 14:37:16 +03:00
Yuki Okushi
2dc73c45d5 Clean up methods/mod.rs 2020-01-24 17:04:37 +09:00
bors
2c7cfa8321 Auto merge of #5027 - sinkuu:vectored_io, r=phansch
Lint vectored IO in unused_io_amount lint

`read_vectored` & `write_vectored` require handling returned value likewise non-vectored methods. https://github.com/rust-lang/rust/issues/68041

---

changelog: lint vectored IO in `unused_io_amount` lint
2020-01-24 06:44:09 +00:00
bors
3237b7a69f Auto merge of #5082 - Areredify:issue-4980, r=flip1995
disable let_underscore_must_use in external macros

changelog: disable let_underscore_must_use in external macros
Closes #4980
2020-01-23 18:29:28 +00:00
Mikhail Babenko
fef3657100 disable let_underscore_must_use in external macros 2020-01-23 20:02:34 +03:00
Areredify
796958c7e2 add option_as_ref_deref lint 2020-01-23 16:12:16 +03:00
Yuki Okushi
a7d58edf27 Ignore macros with ! operators in eq_op 2020-01-22 16:48:00 +09:00
Yuki Okushi
7ce9b8437d Rustup to rust-lang/rust#68140 2020-01-22 07:26:07 +09:00
bors
dd06c06183 Auto merge of #5028 - krishna-veerareddy:issue-5026-mem-ordering-fences, r=phansch
Detect usage of invalid atomic ordering in memory fences

Detect usage of `core::sync::atomic::{fence, compiler_fence}` with `Ordering::Relaxed` and suggest valid alternatives.

changelog: Extend `invalid_atomic_ordering` to lint memory fences

Fixes #5026
2020-01-21 05:53:46 +00:00
bors
eca0d8e5d0 Auto merge of #5067 - JohnTitor:lint-skip-while-next, r=flip1995
Add `skip_while_next` lint

Fixes #4036

changelog: Add `skip_while_next` lint
2020-01-20 17:28:38 +00:00
bors
32949da78e Auto merge of #5070 - JohnTitor:suspicious-map-doc, r=flip1995
Improve `suspicious_map`documentation

Fixes #4793

changelog: none
2020-01-20 12:12:03 +00:00
Yuki Okushi
bec5b69e45 Apply review comment 2020-01-20 21:07:31 +09:00
Yuki Okushi
f8034e0bc6 Improve suspicious_mapdocumentation 2020-01-20 15:05:40 +09:00
Yuki Okushi
fdda3c3f25 Tweak wording in assertions_on_constants 2020-01-20 11:52:58 +09:00
Yuki Okushi
95c369fa91 Add skip_while_next lint 2020-01-20 10:56:02 +09:00
bors
f7b3e4f29c Auto merge of #5056 - rust-lang:dissasociate-mut-key, r=flip1995
Avoid mut_key on types of unknown layout

This fixes #5020 by requiring a known layout for the key type before linting. Edit: This fixes #5043, too.

changelog: none
2020-01-19 14:41:28 +00:00
Andre Bogus
59fd637ba1 Avoid mut_key on types of unknown layout 2020-01-19 14:49:18 +01:00
Yuki Okushi
c9f8d03f42 Treat more strange pattern 2020-01-19 21:14:47 +09:00
Yuki Okushi
7e76a19664 Apply review comments 2020-01-19 10:14:03 +09:00
Yuki Okushi
ce06ba3d30 Run update_lints 2020-01-19 10:06:08 +09:00
Yuki Okushi
aab64a21cc Reduce span range 2020-01-19 10:06:08 +09:00
Yuki Okushi
ae872fe1c7 Rename ok_if_let to if_let_some_result 2020-01-19 10:06:08 +09:00
Yuki Okushi
9e55424bdc Apply review comments 2020-01-19 10:06:08 +09:00
Yuki Okushi
9035264a8f Add suggestion in if_let_some_result 2020-01-19 10:06:08 +09:00
bors
0a7003ecf0 Auto merge of #5065 - matthiaskrgr:rustup_28, r=matthiaskrgr
rustup https://github.com/rust-lang/rust/pull/67712

slice_patterns have been stabilized.

changelog: none
2020-01-18 22:44:46 +00:00
Matthias Krüger
b2c4f09d77 rustup https://github.com/rust-lang/rust/pull/67712
slice_patterns have been stabilized.
2020-01-18 23:43:28 +01:00
bors
0964b8d192 Auto merge of #5046 - JohnTitor:order-nonminimal-bool, r=flip1995
Keep the ordering in `nonminimal_bool` lint

I believe it shouldn't cause any regression but feel free to let me know if you have a doubtful example.
Also, splits up `booleans` ui test.

Fixes #5045

changelog: none
2020-01-18 19:51:46 +00:00
bors
ee06aa990f Auto merge of #5063 - JohnTitor:allow-correctly, r=flip1995
Allow `unused_self` lint at the function level

Another approach of #5062.
Fixes #5053

changelog: Allow `unused_self` lint at the function level
2020-01-18 16:58:30 +00:00