Commit graph

9644 commits

Author SHA1 Message Date
bors 171ab9bf9f Auto merge of #6132 - rust-lang:regex-unicode, r=ebroto
Fix unicode regexen with bytes::Regex

fixes #6005

The rationale for this is that since we wrote that lint, `bytes::Regex` was extended to be able to use unicode character classes.

---

changelog: [`invalid_regex`]: allow unicode character classes in bytes regex.
2020-10-08 08:48:12 +00:00
João Paulo Taylor Ienczak Zanette 15150c07ea clippy_lint: Test for BoxedLocal false-positive in C-FFI and fix C-FFI Abi comparison. 2020-10-07 22:49:50 -03:00
João Paulo Taylor Ienczak Zanette 738ed38306 clippy_lints: Do not warn against Box parameter in C FFI
Fixes #5542.

When using C FFI, to handle pointers in parameters it is needed to
declare them as `Box` in its Rust-side signature. However, the current
linter warns against the usage of Box stating that "local variable
doesn't need to be boxed here".

This commit fixes it by ignoring functions whose Abi is Cdecl.
2020-10-07 21:41:54 -03:00
bors 13a80b34ba Auto merge of #6128 - dtolnay:rc_buffer, r=yaahc
Downgrade rc_buffer to restriction

I think Arc\<Vec\<T\>\> and Arc\<String\> and similar are a totally reasonable data structure, as observed by others in the comments on [#6044](https://github.com/rust-lang/rust-clippy/pull/6044#event-3799579830) as well. Doing `Arc::make_mut(&mut self.vec).push(...)` or `Arc::make_mut(&mut self.string).push_str("...")` is a terrific and well performing copy-on-write pattern. Linting this with an enabled-by-default <kbd>performance</kbd> lint strikes me as an unacceptable false positive balance.

As of #6090 the documentation of this lint now contains:

> **Known problems:** This pattern can be desirable ...

which should indicate that we shouldn't be linting against correct, reasonable, well-performing patterns with an enabled-by-default lint.

Mentioning #6044, #6090.
r? `@yaahc,` who reviewed the lint.

---

changelog: Remove rc_buffer from default set of enabled lints
2020-10-07 23:10:34 +00:00
Andre Bogus 11672577de Fix unicode regexen with bytes::Regex
fixes #6005
2020-10-08 01:07:00 +02:00
Bruno BELANYI 6edde811b5
fixup! New lint: Recommend using ptr::eq when possible
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2020-10-07 17:11:11 +02:00
Bruno BELANYI 326090dbb8
fixup! Rename tables to typecheck_result()
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2020-10-07 17:10:31 +02:00
Bruno BELANYI 9ef311b477 Rename tables to typecheck_result() 2020-10-07 11:59:20 +02:00
Bruno BELANYI aa7c42f756 fixup! New lint: Recommend using ptr::eq when possible
Add missing modified files.
2020-10-07 11:54:09 +02:00
Bruno BELANYI 5bad9175fb New lint: Recommend using ptr::eq when possible
This is based almost entirely on the code available in the previous PR #4596.
2020-10-07 11:48:06 +02:00
bors 277191890b Auto merge of #6120 - phansch:replace-lazy-static, r=Manishearth
Replace some lazy_static usage with once_cell feature

This replaces some `lazy_static` usage with [`SyncLazy`](https://doc.rust-lang.org/nightly/std/lazy/struct.SyncLazy.html) of the unstable `once_cell` feature.

changelog: none
2020-10-07 04:58:13 +00:00
David Tolnay 0e159a55d6
Downgrade rc_buffer to restriction 2020-10-06 19:46:03 -07:00
David Tolnay a5ef305cb5
Downgrade string_lit_as_bytes to nursery 2020-10-06 19:41:22 -07:00
bors 14e72696a6 Auto merge of #6124 - pickfire:patch-1, r=flip1995
Use more concrete explanation for methods

*Please keep the line below*
changelog: none
2020-10-06 23:22:28 +00:00
bors c8d89ba5d5 Auto merge of #6127 - ebroto:reinstate_forbid_restriction, r=flip1995
Reinstate test for forbid(clippy::restriction)

In [this commit](5747c15961) coming from rust-lang/rust (#6126) the test for `#![forbid(clippy::restriction)]` was removed because some restriction lints were being allowed after the forbid.

This change reinstates the test for `forbid` by using a separate file.

changelog: none

r? `@flip1995`
2020-10-06 22:33:57 +00:00
Eduardo Broto 6c3611bdef Reinstate test for forbid blanket restriction 2020-10-07 00:02:28 +02:00
bors 1a4175bcec Auto merge of #6126 - flip1995:rustup, r=flip1995
Rustup

Supersedes #6121. There was another breakage.

r? `@ghost`

changelog: none
2020-10-06 21:34:50 +00:00
flip1995 b05aeaa9bc
Run fmt 2020-10-06 23:32:38 +02:00
Ivan Tham 7021d70d2e
Use more concrete explanation for methods
Show some code rather than "a single method call".
2020-10-06 23:58:32 +08:00
Philipp Hansch da57a16872
clippy_lints: Replace lazy_static with SyncLazy 2020-10-06 14:39:04 +02:00
Matthew Jasper adb7fc6283 Fix tools 2020-10-06 11:19:30 +01:00
Yuki Okushi 22c5e0c347 Rollup merge of #77560 - rschoon:fix-litkind-rc-bytebuf, r=lcnr
Fix LitKind's byte buffer to use refcounted slice

While working on adding a new lint for clippy (see https://github.com/rust-lang/rust-clippy/pull/6044) for avoiding shared ownership of "mutable buffer" types (such as using `Rc<Vec<T>>` instead of `Rc<[T]>`), I noticed a type exported from rustc_ast and used by clippy gets caught by the lint. This PR fixes the exported type.

This PR includes the actual change to clippy too, but I will open a PR directly against clippy for that part (although it will currently fail to build there).
2020-10-06 16:26:11 +09:00
Yuki Okushi a7b721968a Rollup merge of #77534 - Mark-Simulacrum:issue-70819-disallow-override-forbid-in-same-scope, r=petrochenkov
Disallow overriding forbid in same scope

Rebased #73379.

Fixes #70819.
2020-10-06 16:26:04 +09:00
bors c9fdeef643 Auto merge of #6078 - ebroto:unnecessary_sort_by_take_2, r=phansch
unnecessary sort by: avoid dereferencing the suggested closure parameter

This change tries to simplify the solution for problematic cases but is less restrictive than  #6006.

* We can't dereference shared references to non-Copy types, so the new suggestion does not do that. Note that this implies that the suggested closure parameter will be a reference.
* We can't take a reference to the closure parameter in the returned key, so we don't lint in those cases. This can happen either because the key borrows from the parameter (e.g. `|a| a.borrows()`), or because we suggest `|a| Reverse(a)`. If we did we would hit this error:
```
error: lifetime may not live long enough
  --> /home/ebroto/src/ebroto-clippy/tests/ui/unnecessary_sort_by.fixed:19:25
   |
19 |     vec.sort_by_key(|b| Reverse(b));
   |                      -- ^^^^^^^^^^ returning this value requires that `'1` must outlive `'2`
   |                      ||
   |                      |return type of closure is Reverse<&'2 isize>
   |                      has type `&'1 isize`

error: aborting due to previous error
```

Note that Clippy does not currently have the (MIR-based) machinery necessary to check that what is borrowed is actually the closure parameter.

changelog: [`unnecessary_sort_by`]: avoid dereferencing the suggested closure parameter

Fixes #6001
2020-10-06 06:59:33 +00:00
Philipp Hansch 9b4ceee593
integration tests: Replace lazy_static with SyncLazy 2020-10-06 08:20:18 +02:00
Philipp Hansch 4b459596a9
clippy_dev: Replace lazy_static with SyncLazy 2020-10-06 08:18:11 +02:00
Eduardo Broto 13781ae2f8 Remove "thanks" section 2020-10-06 00:09:45 +02:00
bors 3239b46e92 Auto merge of #6114 - FliegendeWurst:no-mistyped-fraction, r=Manishearth
Do not lint float fractions in `mistyped_literal_suffixes`

As suggested in https://github.com/rust-lang/rust-clippy/issues/4706#issuecomment-544797928, the fractional part is now ignored (the integer part is checked instead).

Fixes: #4706

changelog: `mistyped_literal_suffixes` no longer warns on the fractional part of a float (e.g. 713.23_64)
2020-10-05 21:17:37 +00:00
bors 411e3bac56 Auto merge of #6118 - ebroto:rustup, r=ebroto
Rustup

changelog: none

r? `@ghost`
2020-10-05 20:44:31 +00:00
Eduardo Broto 5554641fce Fix rustup fallout 2020-10-05 22:32:04 +02:00
Eduardo Broto 5f492490a3 Merge remote-tracking branch 'upstream/master' into rustup 2020-10-05 22:13:44 +02:00
Eduardo Broto c5f17002e5 Add changelog for 1.48 beta 2020-10-05 17:03:24 +02:00
FliegendeWurst 428ef362d6 Fix test formatting 2020-10-05 12:23:01 +02:00
FliegendeWurst 78695bd496
Do not lint float fractions in mistyped_literal_suffixes (fixes #4706) 2020-10-05 12:09:21 +02:00
Dylan MacKenzie 29d43f63bd clippy: (Body, DefId) -> Body 2020-10-04 16:07:03 -07:00
Robin Schoonover f34f4a7327 Change clippy's Constant back to refcount clone byte strings 2020-10-04 15:53:37 -06:00
Felix S. Klock II 5747c15961 Prevent forbid from being ignored if overriden at the same level.
That is, this changes `#[forbid(foo)] #[allow(foo)]` from allowing foo to
forbidding foo.
2020-10-04 13:14:01 -04:00
bors 2ed5143c0e Auto merge of #6111 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: Deprecate [`drop_bounds`] lint. This lint was uplifted to rustc with the same name.
2020-10-04 12:04:31 +00:00
bors 9408c68c1d Auto merge of #6105 - bugadani:sus-char, r=ebroto
Lint for invisible Unicode characters other than ZWSP

This PR extends the existing `zero_width_space` lint to look for other invisible characters as well (in this case, `\\u{ad}` soft hyphen.

I feel like this lint is the logical place to add the check, but I also realize the lint name is not particularly flexible, but I also understand that it shouldn't be renamed for compatibility reasons.

Open questions:
 - What other characters should trigger the lint?
 - What should be done with the lint name?
 - How to indicate the change in functionality?

Motivation behind this PR: https://github.com/rust-lang/rust/issues/77417 - I managed to shoot myself in the foot by an invisible character pasted into my test case.

changelog: rename [`zero_width_space`] to [`invisible_characters`] and add SHY and WJ to the list.
2020-10-02 22:22:37 +00:00
Dániel Buga 572e4c4837 Add WJ 2020-10-03 00:07:56 +02:00
Dániel Buga 998bd3b6b4 Rename lint to invisible_characters 2020-10-03 00:03:33 +02:00
bors a1a7f20b4c Auto merge of #6098 - longlb:interior_mut_const, r=ebroto
Downgrade interior_mutable_const lints to warn by default

This change updates the two lints in the file non_copy_const.rs to be warn by default rather than deny by default. It also updates the known problems for declare_interior_mutable_const to mention some issues that are affected by the lints.

This is a repeat pull request since I botched the first one (#6012). Apart from my messing up the commits of that one, I also had a problem where the stderr of the tests didn't change despite me changing both lints to warn by default. Is this normal behaviour for some lints or do I need to adjust the tests to accommodate the change?

fixes #5863
changelog: none
2020-10-02 21:21:49 +00:00
Long Louis Bui 8b8c63f568 changed non_copy_const lints to warn by default 2020-10-02 23:12:40 +02:00
nahuakang f302af33bc Add doc comment issue of #5834 to known problems of lint doc_markdown 2020-10-02 22:05:40 +02:00
Michael Howell 840f7daaad Deprecate clippy lint 2020-10-02 11:34:14 -07:00
rail b541884294 remove the explicit return value of print_limit 2020-10-02 23:38:10 +13:00
rail 7820cb1442 Add tests for
* `dst.len()` as the end of the range with loop counters
* the increment of the loop counter at the top of the loop
2020-10-02 23:21:24 +13:00
Dániel Buga 45f25f82fe Run update_lints 2020-10-02 12:02:54 +02:00
Dániel Buga 515ca93123 Look for soft hyphens as well 2020-10-02 11:56:21 +02:00
rail 2a0e45b8db supress clippy::filter_map 2020-10-02 21:38:50 +13:00