Commit Graph

4322 Commits

Author SHA1 Message Date
Bastian Kauschke
29de25b8a2 const_eval_resolve 2020-07-15 12:58:32 +02:00
Nicholas Nethercote
f2f99be2ff Remove lots of Symbol::as_str() calls.
In various ways, such as changing functions to take a `Symbol` instead
of a `&str`.
2020-07-15 09:01:35 +10:00
bors
128c5dec92 Auto merge of #5793 - warner:5783-nth-zero-next, r=flip1995
improve advice in iter_nth_zero

fixes #5783

*Please keep the line below*
changelog:  For iter_nth_zero, the "use .next()" replacement advice is on the last line of the code snippet, where it is vulnerable to truncation. Display that advice at the beginning instead.
2020-07-14 16:58:23 +00:00
Brian Warner
e83b3eb993 formatting nits 2020-07-14 09:20:19 -07:00
Matthias Krüger
126790999a new lint: Returning unit from closures expecting Ord
This lint catches cases where the last statement of a closure expecting
an instance of Ord has a trailing semi-colon. It compiles since the
closure ends up return () which also implements Ord but causes
unexpected results in cases such as sort_by_key.

Fixes #5080

reprise: rebase, update and address all concerns
2020-07-14 15:54:04 +02:00
flip1995
6f25adbd5a Merge commit '2ca58e7dda4a9eb142599638c59dc04d15961175' into clippyup 2020-07-14 14:59:59 +02:00
bors
2ca58e7dda Auto merge of #5732 - bjorn3:patch-1, r=flip1995
Rename collapsable_if fix suggestion to "collapse nested if block"

The name "try" is confusing when shown as quick fix by rust-analyzer

changelog: Rename `collapsable_if` fix suggestion to "collapse nested if block"
2020-07-14 09:39:01 +00:00
bors
12df6384b9 Auto merge of #5773 - giraffate:repeat_once, r=flip1995
Add a lint for `.repeat(1)`

changelog: New lint `repeat_once`

fix #3028.
2020-07-14 09:13:58 +00:00
Takayuki Nakata
b4091032ab Use .is_some() not Some(_) 2020-07-14 08:08:13 +09:00
Brian Warner
201999ccfd improve advice in iter_nth_zero
The "use .next()" replacement advice is on the last line of the code snippet,
where it is vulnerable to truncation. Display that advice at the beginning
instead.

closes #5783
2020-07-13 10:59:45 -07:00
bjorn3
ff796b6d70 Rename collapsable_if fix suggestion to "collapse nested if block"
The name "try" is confusing when shown as quick fix by rust-analyzer
2020-07-13 17:54:57 +02:00
Takayuki Nakata
f2419b9d62 Refactoring to use `constant_context
Use `constant_context`, `.is_str()` and `builtin_index()` to simplify.
2020-07-14 00:23:20 +09:00
bors
4b8700879c Auto merge of #5792 - flip1995:rollup-torc1we, r=flip1995
Rollup of 5 pull requests

Successful merges:

 - #5443 (Some accuracy lints for floating point operations)
 - #5752 (Move range_minus_one to pedantic)
 - #5756 (unnecessary_sort_by: avoid linting if key borrows)
 - #5784 (Fix out of bounds access by checking length equality BEFORE accessing by index.)
 - #5786 (fix phrase in new_lint issue template)

Failed merges:

r? @ghost

changelog: rollup
2020-07-13 14:21:20 +00:00
Philipp Krones
26ede3115f
Rollup merge of #5784 - matthiaskrgr:ice_5780, r=phansch
Fix out of bounds access by checking length equality BEFORE accessing by index.

Fixes #5780

changelog: fix out of bounds access in unnested_or_patterns lint.

Edit: I did not bother reducing a testcase from `librustc_typeck` crate but I can confirm that with the change the crash no longer occurs.
2020-07-13 15:59:45 +02:00
Philipp Krones
32ef448bdb
Rollup merge of #5756 - ebroto:5754_sort_by, r=flip1995
unnecessary_sort_by: avoid linting if key borrows

changelog: Avoid linting if key borrows in [`unnecessary_sort_by`]

Fixes #5754
Closes #2313
2020-07-13 15:59:44 +02:00
Philipp Krones
019e281d15
Rollup merge of #5752 - chrisduerr:pedantic_ranges, r=flip1995
Move range_minus_one to pedantic

This moves the range_minus_one lint to the pedantic category, so there
will not be any warnings emitted by default. This should work around
problems where the suggestion is impossible to resolve due to the range
consumer only accepting a specific range implementation, rather than the
`RangeBounds` trait (see #3307).

While it is possible to work around this by extracting the boundary into
a variable, I don't think clippy should encourage people to disable or
work around lints, but instead the lints should be fixable. So hopefully
this will help until a proper implementation checks what the range is
used for.

*Please keep the line below*
changelog: move [`range_minus_one`] to pedantic
2020-07-13 15:59:42 +02:00
Philipp Krones
75d43aac73
Rollup merge of #5443 - thiagoarrais:issue-2040, r=flip1995
Some accuracy lints for floating point operations

This will add some lints for accuracy on floating point operations suggested by @clarfon in #2040 (fixes #2040).

These are the remaining lints:

- [x] x.powi(2) => x * x
- [x] x.logN() / y.logN() => x.logbase(y)
- [x] x.logbase(E) => x.log()
- [x] x.logbase(10) => x.log10()
- [x] x.logbase(2) => x.log2().
- [x] x * PI / 180 => x.to_radians()
- [x] x * 180 / PI => x.to_degrees()
- [x] (x + 1).log() => x.log_1p()
- [x] sqrt(x * x + y * y) => x.hypot(y)

changelog: Included some accuracy lints for floating point operations
2020-07-13 15:59:41 +02:00
bors
fa4a737fba Auto merge of #5790 - flip1995:rustup, r=flip1995
Rustup

r? @ghost

changelog: none
2020-07-13 13:53:11 +00:00
Matthias Krüger
1b3bc16533 Fix out of bounds access by checking length equality BEFORE accessing by index.
Fixes #5780
2020-07-11 12:30:18 +02:00
bors
7d611d9224 Auto merge of #5769 - robojumper:match_like_matches_macro, r=phansch
new lint: match_like_matches_macro

Suggests using the `matches!` macro from `std` where appropriate.

`redundant_pattern_matching` has been moved into the `matches` pass to allow suppressing the suggestion where `is_some` and friends are a better replacement.

changelog: new lint: `match_like_matches_macro`
2020-07-10 18:10:08 +00:00
Takayuki Nakata
780a4c87de Fix typo 2020-07-10 23:53:15 +09:00
Christian Duerr
ba2a85dadc
Run update_lints 2020-07-10 15:20:00 +02:00
Christian Duerr
298a1fa3bd
Move range_minus_one to pedantic
This moves the range_minus_one lint to the pedantic category, so there
will not be any warnings emitted by default. This should work around
problems where the suggestion is impossible to resolve due to the range
consumer only accepting a specific range implementation, rather than the
`RangeBounds` trait (see #3307).

While it is possible to work around this by extracting the boundary into
a variable, I don't think clippy should encourage people to disable or
work around lints, but instead the lints should be fixable. So hopefully
this will help until a proper implementation checks what the range is
used for.
2020-07-10 15:20:00 +02:00
Tamir Duberstein
cf91c54cc6 Avoid "whitelist"
Other terms are more inclusive and precise.
2020-07-10 07:39:28 -04:00
bors
45eea9a822 Auto merge of #5771 - montrivo:bugfix/single-match-else, r=matthiaskrgr
single_match_else - single expr/stmt else block corner case

One approach to fix #3489.
See discussion in the issue.

changelog: single_match_else - single expr/stmt else block corner case fix
2020-07-09 12:03:14 +00:00
Tim Nielens
dac19e3afc single_match_else - single expr/stmt else block corner case 2020-07-09 12:04:27 +02:00
Eduardo Broto
db1c946aaa unnecessary_sort_by: avoid linting if key borrows 2020-07-08 21:31:59 +02:00
robojumper
37d75da266 make match_like_matches_macro only apply to matches with a wildcard 2020-07-08 18:37:20 +02:00
bors
e12a316b01 Auto merge of #5776 - flip1995:rustup, r=flip1995
Rustup

changelog: none

r? @ghost
2020-07-08 15:56:23 +00:00
Takayuki Nakata
5307cb5614 Add a lint for .repeat(1)
fix #3028.
2020-07-07 23:13:39 +09:00
bors
c41fcad908 Auto merge of #74117 - Manishearth:rollup-ds7z0kx, r=Manishearth
Rollup of 14 pull requests

Successful merges:

 - #70563 ([rustdoc] Page hash handling)
 - #73856 (Edit librustc_lexer top-level docs)
 - #73870 (typeck: adding type information to projection)
 - #73953 (Audit hidden/short code suggestions)
 - #73962 (libstd/net/tcp.rs: #![deny(unsafe_op_in_unsafe_fn)])
 - #73969 (mir: mark mir construction temporaries as internal)
 - #73974 (Move A|Rc::as_ptr from feature(weak_into_raw) to feature(rc_as_ptr))
 - #74067 (rustdoc: Restore underline text decoration on hover for FQN in header)
 - #74074 (Fix the return type of Windows' `OpenOptionsExt::security_qos_flags`.)
 - #74078 (Always resolve type@primitive as a primitive, not a module)
 - #74089 (Add rust-analyzer to the build manifest)
 - #74090 (Remove unused RUSTC_DEBUG_ASSERTIONS)
 - #74102 (Fix const prop ICE)
 - #74112 (Expand abbreviation in core::ffi description)

Failed merges:

r? @ghost
2020-07-07 00:56:44 +00:00
Manish Goregaokar
245b006a2e Rollup merge of #73870 - sexxi-goose:projection-ty, r=nikomatsakis
typeck: adding type information to projection

This commit modifies the Place as follow:
* remove 'ty' from ProjectionKind
* add type information into to Projection
* replace 'ty' in Place with 'base_ty'
* introduce 'ty()' in `Place` to return the final type of the `Place`
* introduce `ty_before_projection()` in `Place` to return the type of
  a `Place` before i'th projection is applied

Closes https://github.com/rust-lang/project-rfc-2229/issues/5
2020-07-06 17:45:20 -07:00
bors
4705037374 Auto merge of #73978 - Mark-Simulacrum:shrink-paramenv, r=nnethercote
Shrink ParamEnv to 16 bytes

r? @nnethercote

x.py check passes but I haven't tried running perf or tests
2020-07-06 20:44:16 +00:00
Thiago Arrais
3065201eb3 Includes TODO for constants equivalent to π/180 2020-07-06 13:45:43 -03:00
Thiago Arrais
6be9491eac Reclassify powi(2) lint under suboptimal_flops 2020-07-06 13:45:43 -03:00
Thiago Arrais
db7bc6b3bd Place radian lints under suboptimal_flops 2020-07-06 13:45:43 -03:00
Thiago Arrais
f5596826fa Better copy for lint message
Since x.log(y) is actually implemented as x.ln() / y.ln()
2020-07-06 13:45:43 -03:00
Thiago Arrais
076ec872ce Lint for to_radians and to_degrees 2020-07-06 13:45:39 -03:00
robojumper
1740dda763 fix match_like_matches_macro in clippy 2020-07-06 18:35:58 +02:00
Thiago Arrais
0c8afa39ce Lint x.log(b) / y.log(b) => x.log(y) 2020-07-06 13:32:31 -03:00
robojumper
2e8a1be444 new lint: match_like_matches_macro 2020-07-06 18:25:20 +02:00
Thiago Arrais
f62798454c Lint (x * x + y * y).sqrt() => x.hypot(y) 2020-07-06 13:23:17 -03:00
Thiago Arrais
a6f1af75d7 Lint for x.powi(2) => x * x 2020-07-06 13:23:17 -03:00
Mark Rousskov
3503247c11 Shrink ParamEnv to 16 bytes 2020-07-05 09:51:42 -04:00
JarredAllen
c8f700ea69 Fixed compile errors 2020-07-03 21:22:23 -07:00
JarredAllen
1c32263176 Formatted updates to lints 2020-07-03 16:51:44 -07:00
JarredAllen
6ce981225b Clean existing lint code to match new lint 2020-07-03 16:51:44 -07:00
JarredAllen
ccb999851a Fix compile error from library change 2020-07-03 16:50:45 -07:00
JarredAllen
93f0f5d37b Last few tweaks 2020-07-03 16:50:45 -07:00
JarredAllen
5150277a4f Used clippy to clean itself 2020-07-03 16:50:45 -07:00
JarredAllen
5e20475e47 Don't lint if contains a macro 2020-07-03 16:47:38 -07:00
JarredAllen
7c4de9d3de Refactoring pt. 2 2020-07-03 16:47:38 -07:00
JarredAllen
f73b455b99 Refactoring 2020-07-03 16:47:38 -07:00
JarredAllen
88c8afdddf Handle ref, mut, &, and &mut on the option 2020-07-03 16:47:38 -07:00
JarredAllen
b85796fe36 Properly parenthesize to avoid operator precedence errors 2020-07-03 16:47:38 -07:00
JarredAllen
82f8d4d6f1 Stop linting on macros and correctly use braces for constructs 2020-07-03 16:47:38 -07:00
JarredAllen
bf48a2d50d Lint for if let Some(x) = ... instead of Option::map_or 2020-07-03 16:47:38 -07:00
bors
57cdf2dc16 Auto merge of #4841 - phaylon:pattern-type-mismatch, r=flip1995
Added restriction lint: pattern-type-mismatch

changelog: Added a new restriction lint `pattern-type-mismatch`. This lint is especially helpful for beginners learning about the magic behind pattern matching. (This explanation might be worth to include in the next changelog.)
2020-07-03 16:41:26 +00:00
Robert Sedlacek
c0fd452840 fmt fix 2020-07-03 18:23:36 +02:00
Robert Sedlacek
aa4bee228f LateContext has only one lifetime parameter now 2020-07-03 18:20:19 +02:00
Robert Sedlacek
d617551a6a Expanded lint documentation 2020-07-03 18:12:29 +02:00
Robert Sedlacek
92ecc53691 Catching up with rustc changes 2020-07-03 18:12:29 +02:00
flip1995
6447507ab1 Fix rebase fallout 2020-07-03 18:12:29 +02:00
Robert Sedlacek
55877d7b4a span_help_and_lint -> span_lint_and_help 2020-07-03 18:12:29 +02:00
Robert Sedlacek
c3c402783f Added restriction lint: pattern-type-mismatch 2020-07-03 18:12:29 +02:00
ThibsG
2d5930a3da Don't lint for predicates generated in macros 2020-07-03 17:29:54 +02:00
ThibsG
d5a8f03a35 Take generic args into account for bounded type 2020-07-03 17:29:54 +02:00
ThibsG
754bfb1dc8 Add configurable threshold for type_repetition_in_bounds lint 2020-07-03 17:29:54 +02:00
flip1995
a7c58e66d4
Merge remote-tracking branch 'upstream/master' into rustup 2020-07-03 12:50:41 +02:00
Eduard-Mihai Burtescu
30c046ede4 Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
Eduard-Mihai Burtescu
590e07bbc2 rustc_lint: avoid using TypeckTables::empty for LateContext. 2020-07-02 16:51:04 +03:00
Philipp Hansch
d347d0cf59
Deprecate regex_macro lint 2020-07-01 13:05:41 +02:00
bors
36b7983580 Auto merge of #5758 - ebroto:5704_unnested_or_pats, r=flip1995
Require `or_patterns` to suggest nesting them

changelog: Require `#![feature(or_patterns)]` to trigger [`unnested_or_patterns`]

Fixes #5704
2020-06-30 22:23:23 +00:00
Eduardo Broto
bff6c435ef Require or_patterns to suggest nesting them 2020-07-01 00:15:21 +02:00
Eduardo Broto
c5d8f530e0 Move blanket_clippy_restriction_lints to "style" 2020-06-30 21:56:19 +02:00
Eduardo Broto
814349f941 Lint enabling the whole restriction group 2020-06-30 21:56:19 +02:00
flip1995
1e861a2663
Merge remote-tracking branch 'upstream/master' into rustup2 2020-06-30 15:40:22 +02:00
Azhng
dfecaef914 typeck: adding type information to projection
This commit modifies the Place as follow:
* remove 'ty' from ProjectionKind
* add type information into to Projection
* replace 'ty' in Place with 'base_ty'
* introduce 'ty()' in `Place` to return the final type of the `Place`
* introduce `ty_before_projection()` in `Place` to return the type of
  a `Place` before i'th projection is applied

Closes https://github.com/rust-lang/project-rfc-2229/issues/5
2020-06-29 16:46:52 -04:00
bors
81810fa8f4 Auto merge of #73756 - Manishearth:rollup-aehswb2, r=Manishearth
Rollup of 13 pull requests

Successful merges:

 - #72620 (Omit DW_AT_linkage_name when it is the same as DW_AT_name)
 - #72967 (Don't move cursor in search box when using arrows to navigate results)
 - #73102 (proc_macro: Stop flattening groups with dummy spans)
 - #73297 (Support configurable deny-warnings for all in-tree crates.)
 - #73507 (Cleanup MinGW LLVM linkage workaround)
 - #73588 (Fix handling of reserved registers for ARM inline asm)
 - #73597 (Record span of `const` kw in GenericParamKind)
 - #73629 (Make AssocOp Copy)
 - #73681 (Update Chalk to 0.14)
 - #73707 (Fix links in `SliceIndex` documentation)
 - #73719 (emitter: column width defaults to 140)
 - #73729 (disable collectionbenches for android)
 - #73748 (Add code block to code in documentation of `List::rebase_onto`)

Failed merges:

r? @ghost
2020-06-26 10:11:43 +00:00
Manish Goregaokar
a671ea4d3f Rollup merge of #73597 - ayazhafiz:i/const-span, r=ecstatic-morse
Record span of `const` kw in GenericParamKind

Context: this is needed for a fix of https://github.com/rust-lang/rustfmt/issues/4263,
which currently records the span of a const generic param incorrectly
because the location of the `const` kw is not known.

I am not sure how to add tests for this; any guidance in how to do so
would be appreciated 🙂
2020-06-26 00:39:08 -07:00
Eduard-Mihai Burtescu
f5ce0e5fe9 rustc_lint: only query typeck_tables_of when a lint needs it. 2020-06-26 02:56:23 +03:00
Carol (Nichols || Goulding)
fa0f1d3e53
Change a noun to a verb to make the sentence complete 2020-06-25 11:25:21 -04:00
bors
46d33043d5 Auto merge of #5701 - ebroto:4874_cmp_owned_fp, r=flip1995
cmp_owned: handle when PartialEq is not implemented symmetrically

changelog: Handle asymmetrical implementations of PartialEq in [`cmp_owned`].

Fixes #4874
2020-06-24 12:48:24 +00:00
bors
a14eab389f Auto merge of #5745 - montrivo:copy_on_clone, r=phansch
clone_on_copy - add machine applicability

Fix #4826.
Change the applicability of the lint clone_on_copy. Split a test file and run rustfix on the clone_on_copy part.

changelog: clone_on_copy - add machine applicability
2020-06-24 07:11:07 +00:00
Tim Nielens
6bf5434e19 copy_on_clone - add machine applicability 2020-06-24 01:01:44 +02:00
Eduardo Broto
b498e1d715 cmp_owned: reverse operands if necessary 2020-06-23 22:14:45 +02:00
Eduardo Broto
5987c7d404 cmp_owned: avoid FP when PartialEq is not implemented symmetrically 2020-06-23 22:14:45 +02:00
Ayaz Hafiz
7c1b3aa0dd Record span of const kw in GenericParamKind
Context: this is needed to fix https://github.com/rust-lang/rustfmt/issues/4263,
which currently records the span of a const generic param incorrectly
because the location of the `const` kw is not known.

I am not sure how to add tests for this; any guidance in how to do so
would be appreciated 🙂
2020-06-23 09:25:46 -07:00
bors
583d644934 Auto merge of #5694 - wangtheo:issue-5626, r=matthiaskrgr
#5626: lint iterator.map(|x| x)

changelog: adds a new lint for iterator.map(|x| x) (see https://github.com/rust-lang/rust-clippy/issues/5626)

The code also lints for result.map(|x| x) and option.map(|x| x). Also, I'm not sure if I'm checking for type adjustments correctly and I can't think of an example where .map(|x| x) would apply type adjustments.
2020-06-23 15:59:27 +00:00
Teddy_Wang
fb4f9a0ad7 Fix pattern match of ExprKind::MethodCall 2020-06-23 11:40:38 -04:00
flip1995
80bcbf521c Merge commit 'c2c07fa9d095931eb5684a42942a7b573a0c5238' into clippyup 2020-06-23 17:05:22 +02:00
bors
c2c07fa9d0 Auto merge of #5740 - lzutao:unused-unused, r=flip1995
Remove unused allowed unused attributes

changelog: none
2020-06-23 14:34:18 +00:00
bors
c420382ac2 Auto merge of #5738 - mikerite:loops-20200623-2, r=matthiaskrgr
Improve end of expression check in for loop lints

changelog: none
2020-06-23 14:05:45 +00:00
Lzu Tao
7374185b36 Remove unused allowed unused attributes 2020-06-23 20:59:35 +07:00
Philipp Krones
e4cbd1df4e
Rollup merge of #5726 - sozysozbot:patch-1, r=flip1995
Fix typo

changelog: extending it's lifetime -> extending its lifetime
2020-06-23 14:39:50 +02:00
Philipp Krones
f562117788
Rollup merge of #5724 - ebroto:5697_const_result_option, r=Manishearth
redundant_pattern_matching: avoid non-`const fn` calls in const contexts

changelog: Avoid suggesting non-`const fn` calls in const contexts in [`redundant_pattern_matching`]

Fixes #5697
2020-06-23 14:39:49 +02:00
Philipp Krones
68c0b24e23
Rollup merge of #5716 - bugadani:patch-1, r=matthiaskrgr
Fix typo in wildcard_imports

changelog: none
2020-06-23 14:39:48 +02:00
Philipp Krones
598a79f309
Rollup merge of #5713 - flip1995:more_lints, r=Manishearth
Use lints in Clippy that are enabled in rustc bootstrap

cc https://github.com/rust-lang/rust/pull/73297#discussion_r439747061

changelog: none
2020-06-23 14:39:47 +02:00
Philipp Krones
0799be7156
Rollup merge of #5712 - ijijn:master, r=flip1995
Remove `bar` from blacklisted names

changelog: Remove `bar` from blacklisted names
fixes #5225
2020-06-23 14:39:45 +02:00
Philipp Krones
24b77ea72f
Rollup merge of #5710 - lcnr:patch-1, r=flip1995
typo

changelog: none
2020-06-23 14:39:44 +02:00
Philipp Krones
9505919be5
Rollup merge of #5709 - ebroto:5389_ice, r=Manishearth
Fix ICE in consts::binop

changelog: Fix ICE in `consts::binop`

Fixes #5389
2020-06-23 14:39:43 +02:00
Philipp Krones
1f39eeb06d
Rollup merge of #5705 - dtolnay:orpat, r=flip1995
Downgrade unnested_or_patterns to pedantic

Even with #5704 fixed, I don't believe it is a safe bet that if someone is using or-patterns anywhere in a codebase then they want to use it as much as possible in the whole codebase. I think it would be reasonable to reevaluate after the feature is stable. I feel that a warn-by-default lint suggesting use of an unstable feature, even if already being used in one place, is questionable.

changelog: Remove unnested_or_patterns from default set of enabled lints
2020-06-23 14:39:42 +02:00
flip1995
b886c06c1a
Fix fallout 2020-06-23 14:05:53 +02:00
flip1995
ed083cc959
Use lints in Clippy that are enabled in rustc bootstrap 2020-06-23 14:05:52 +02:00
bors
4cc2fa933b Auto merge of #5739 - flip1995:rustup, r=flip1995
Rustup

changelog: none

r? @ghost
2020-06-23 12:04:08 +00:00
Michael Wright
52c4864757 Improve end of expression check in for loop lints
The code should to check that the current expression _is_ the end
expression; not that it's equal to it. The equality check seems very
wasteful in terms of performance.
2020-06-23 07:51:51 +02:00
bors
c56c7e2d02 Auto merge of #5695 - esamudera:lint_mem_uninitialized, r=phansch,oli-obk
New lint: suggest `ptr::read` instead of `mem::replace(..., uninitialized())`

resolves: #5575

changelog: improvements to `MEM_REPLACE_WITH_UNINIT`:
- add a new test case in `tests/ui/repl_uninit.rs` to cover the case of replacing with `mem::MaybeUninit::uninit().assume_init()`.
- modify the existing `MEM_REPLACE_WITH_UNINIT` when replacing with `mem::uninitialized` to suggest using `ptr::read` instead.
- lint with `MEM_REPLACE_WITH_UNINIT` when replacing with `mem::MaybeUninit::uninit().assume_init()`
2020-06-23 05:14:21 +00:00
flip1995
51592f8587
Fix sync fallout 2020-06-23 02:23:27 +02:00
flip1995
018440c11e
Merge remote-tracking branch 'upstream/master' into rustup 2020-06-23 02:18:17 +02:00
Ralf Jung
b92602ba69 Make is_freeze and is_copy_modulo_regions take TyCtxtAt 2020-06-21 11:47:19 +02:00
Aman Arora
922ff8e485 Refactor hir::Place
For the following code
```rust
let c = || bar(foo.x, foo.x)
```

We generate two different `hir::Place`s for both `foo.x`.
Handling this adds overhead for analysis we need to do for RFC 2229.

We also want to store type information at each Projection to support
analysis as part of the RFC. This resembles what we have for
`mir::Place`

This commit modifies the Place as follows:
- Rename to `PlaceWithHirId`, where there `hir_id` is that of the
expressioin.
- Move any other information that describes the access out to another
struct now called `Place`.
- Removed `Span`, it can be accessed using the [hir
API](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.span)
- Modify `Projection` to be a strucutre of its own, that currently only
contains the `ProjectionKind`.

Adding type information to projections wil be completed as part of https://github.com/rust-lang/project-rfc-2229/issues/5

Closes https://github.com/rust-lang/project-rfc-2229/issues/3

Co-authored-by: Aman Arora <me@aman-arora.com>
Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-06-18 18:59:38 -04:00
sozysozbot
f3a40f5eb1
Fix typo
extending it's lifetime -> extending its lifetime
2020-06-18 06:50:04 +09:00
Eduardo Broto
a7743e9084 redundant_pattern_matching: avoid non-const fn in const context 2020-06-17 00:32:47 +02:00
Ericko Samudera
8c1ee063bb mem_replace_with_uninit: suggest std::ptr::read 2020-06-17 01:26:37 +07:00
Ralf Jung
93696f45ff Rollup merge of #72938 - lzutao:stabilize_option_zip, r=dtolnay
Stabilize Option::zip

This PR stabilizes the following API:

```rust
impl<T> Option<T> {
    pub fn zip<U>(self, other: Option<U>) -> Option<(T, U)>;
}
```

This API has real world usage as seen in <https://grep.app/search?q=-%3E%20Option%3C%5C%28T%2C%5Cs%3FU%5C%29%3E&regexp=true&filter[lang][0]=Rust>.

The `zip_with` method is left unstably as this API is kinda niche
and it hasn't received much usage in Rust repositories on GitHub.

cc #70086
2020-06-15 12:01:03 +02:00
bors
9217ef2018 Auto merge of #72080 - matthewjasper:uniform-impl-trait, r=nikomatsakis
Clean up type alias impl trait implementation

- Removes special case for top-level impl trait
- Removes associated opaque types
- Forbid lifetime elision in let position impl trait. This is consistent with the behavior for inferred types.
- Handle lifetimes in type alias impl trait more uniformly with other parameters

cc #69323
cc #63063
Closes #57188
Closes #62988
Closes #69136
Closes #73061
2020-06-15 04:10:24 +00:00
Dániel Buga
8a6f42a970
Fix typo in wildcard_imports 2020-06-14 11:07:44 +02:00
Iain Brandram-Adams
454ed47acf Update comment in conf.rs 2020-06-14 12:46:56 +12:00
Teddy_Wang
40ee620e51 Added a lint for .map(|x| x) 2020-06-13 10:08:12 -04:00
Iain Brandram-Adams
f663a21c8f Remove bar from blacklisted names 2020-06-14 01:24:36 +12:00
Bastian Kauschke
dee794f450
typo 2020-06-13 12:42:58 +02:00
Lzu Tao
994a839622 Stabilize Option::zip 2020-06-13 01:27:18 +00:00
Eduardo Broto
b21ef2b365 Fix ICE in consts::binop 2020-06-13 00:52:32 +02:00
Dylan DPC
7c15f30701 Rollup merge of #72906 - lzutao:migrate-numeric-assoc-consts, r=dtolnay
Migrate to numeric associated consts

The deprecation PR is #72885

cc #68490
cc rust-lang/rfcs#2700
2020-06-12 12:28:23 +02:00
Matthew Jasper
af9b09235c Remove ImplItemKind::OpaqueTy from clippy 2020-06-11 16:24:01 +01:00
Matthew Jasper
857ea16feb Remove associated opaque types
They're unused now.
2020-06-11 16:24:01 +01:00
David Tolnay
56f25e3e62
Downgrade unnested_or_patterns to pedantic 2020-06-10 19:29:11 -07:00
Aaron Hill
e2e2a0fa83 Clippy fixes 2020-06-10 17:30:12 -04:00
Aaron Hill
6b3ee8f600 Update Clippy for MethodCall changes 2020-06-10 17:30:11 -04:00
Lzu Tao
c9bd35cac3 Migrate to numeric associated consts 2020-06-10 01:35:47 +00:00
Eduardo Broto
2f74283fce Add a comment linking to the issue 2020-06-10 00:14:02 +02:00
Eduardo Broto
a083b84b78 if_same_then_else: don't assume multiplication is always commutative 2020-06-09 23:49:21 +02:00
Devin R
e521a4ed38 Add enough attrs to the test file so the fix compiles with no errors, fmt/clippy 2020-06-09 16:39:31 -04:00
Lzu Tao
8db24840f7 Merge commit 'ff0993c5e9162ddaea78e83d0f0161e68bd4ea73' into clippy 2020-06-09 14:36:01 +00:00
Devin R
288df59b25 Fix suggestion output, add run-rustfix to test file, stop sorting import segments duh 2020-06-08 16:00:33 -04:00
Devin R
8c5a5a92ec cleaned up import suggestion formatter, look into code reuse with wildcard impotrs 2020-06-08 16:00:33 -04:00
Devin R
d4f60b5ff4 wip: of handling nested import paths for multi-macro paths 2020-06-08 16:00:33 -04:00
Devin R
451363dc59 still working on displaying nested imports 2020-06-08 16:00:33 -04:00
Devin R
8bc106b29d fix some of the review, rename, fmt, refactor 2020-06-08 16:00:33 -04:00
Devin R
1d9e80ad7b remove session 2020-06-08 16:00:33 -04:00
Devin R
8ffbf6f94d use hashset not map for keeping track of seen macro refs
remove stdout, fix clippy warnings, fmtcar
2020-06-08 16:00:33 -04:00
Devin R
ede366be63 collected all the imports and names
how to compare macro to import path

add more imports to test
2020-06-08 16:00:30 -04:00
Devin R
a4b8bb88f2 warn on macro_use attr
cargo dev update lints

use if_chain

clean up alot, span_lint_and_sugg

find imported macros for sugg
2020-06-08 15:59:41 -04:00
bors
ff0993c5e9 Auto merge of #5692 - ebroto:5689_N_dotdot_N, r=yaahc
reversed_empty_ranges: avoid linting N..N except in for loop arguments

changelog: [`reversed_empty_ranges`]: avoid linting N..N except in for loop arguments

r? @yaahc
Fixes #5689
2020-06-08 17:15:45 +00:00
bors
f947644f0d Auto merge of #5680 - ebroto:3792_let_return, r=Manishearth
let_and_return: avoid "does not live long enough" errors

EDIT: Add #3324 to the list of fixes

<details>
<summary>Description of old impl</summary>
<br>
Avoid suggesting turning the RHS expression of the last statement into the block tail expression if a temporary borrows from a local that would be destroyed before.

This is my first incursion into MIR so there's probably room for improvement!
</details>

Avoid linting if the return type of some method or function called in the last statement has a lifetime parameter.

changelog: Fix false positive in [`let_and_return`]

Fixes #3792
Fixes #3324
2020-06-08 16:47:22 +00:00
flip1995
a9ca832b11
Fix rebase fallout 2020-06-07 21:37:55 +02:00
flip1995
ecabed67ec
Apply self-review by Centril 2020-06-07 21:16:05 +02:00
Mazdak Farrokhzad
78f158e80e
dogfood unnested_or_patterns 2020-06-07 21:16:03 +02:00
Eduardo Broto
a664ce7789 Remove unnecessary lifetime parameter 2020-06-07 21:13:13 +02:00
Mazdak Farrokhzad
7b6dc7b33d
add unnested_or_patterns lint 2020-06-07 21:09:47 +02:00
Eduardo Broto
ebfc1da07d reversed_empty_ranges: don't lint N..N except in for loop arg 2020-06-07 21:03:08 +02:00
Eduardo Broto
dac8a3c1ca let_and_return: do not lint if last statement borrows 2020-06-07 20:53:38 +02:00
Eduardo Broto
dc13016ac2 Make let_and_return a late lint pass 2020-06-07 20:53:38 +02:00
flip1995
1a8a69d012
Merge remote-tracking branch 'upstream/master' into rustup 2020-06-07 02:17:49 +02:00
Ralf Jung
161474b7f7 Rollup merge of #72508 - ecstatic-morse:poly-self-ty, r=nikomatsakis
Make `PolyTraitRef::self_ty` return `Binder<Ty>`

This came up during review of #71618. The current implementation is the same as a call to `skip_binder` but harder to audit. Make it preserve binding levels and add a call to `skip_binder` at all use sites so they can be audited as part of #72507.
2020-06-06 21:57:38 +02:00
Philipp Hansch
623faac84e
Cleanup: Use rustc's same_types instead of our same_tys 2020-06-06 11:50:59 +02:00
bors
b059c0a2e6 Auto merge of #72927 - petrochenkov:rustc, r=Mark-Simulacrum
Rename all remaining compiler crates to use the `rustc_foo` pattern

libarena -> librustc_arena
libfmt_macros -> librustc_parse_format
libgraphviz -> librustc_graphviz
libserialize -> librustc_serialize

Closes https://github.com/rust-lang/rust/issues/71177 in particular.
2020-06-06 09:00:51 +00:00
Eduardo Broto
413713c884 Add error info when cargo metadata fails to run 2020-06-05 22:28:58 +02:00
Matthias Krüger
7654125d27 match_wildcard_for_single_variants: remove empty line at start of lint example.
See https://rust-lang.github.io/rust-clippy/master/index.html#match_wildcard_for_single_variants

changelog: none
2020-06-04 03:34:22 +02:00
Mark Rousskov
0c470b3339 Bump to 1.46 2020-06-03 15:27:51 -04:00
Lzu Tao
b39fd5f62f Fix false negative of checked_conversion lint 2020-06-03 09:04:24 +07:00
Vadim Petrochenkov
bd3fc11416 Update fulldeps tests and clippy 2020-06-03 00:18:57 +03:00
Vadim Petrochenkov
2b79413491 Rename the crates in source code 2020-06-02 20:42:54 +03:00
bors
6c833df69b Auto merge of #5678 - lzutao:slice, r=flip1995
Make use of slice pattern

changelog: none
2020-06-02 16:42:51 +00:00
Lzu Tao
fbf0b84b32 Make use of slice pattern 2020-06-02 21:42:33 +07:00
bors
5cb9ef390a Auto merge of #5664 - ThibsG:GiveCorrectedCode, r=flip1995
Give corrected code

This PR adds corrected code for doc examples.

I did this in several commits to facilitate review.
Don't hesitate to tell me if I forgot some.
Also, sometimes I felt it was not necessary to give corrected code, but I maybe wrong.

fixes: #4829

changelog: Improve documentation examples across multiple lints.
2020-06-02 12:11:28 +00:00
bors
f760d77bdb Auto merge of #5597 - esamudera:slice_iter_next, r=flip1995
New lint: iter_next_slice

Hello, this is a work-in-progress PR for issue: https://github.com/rust-lang/rust-clippy/issues/5572

I have implemented lint to replace `iter().next()` for `slice[index..]` and `array` with `get(index)` and `get(0)` respectively. However since I made a lot of changes, I would like to request some feedback before continuing so that I could fix mistakes.

Thank you!

---

changelog: implement `iter_next_slice` lint and test, and modify `needless_continues`, `for_loop_over_options_result` UI tests since they have `iter().next()`
2020-06-02 11:42:22 +00:00
Dylan MacKenzie
ea06c72fdd Call skip_binder or no_bound_vars before self_ty 2020-06-01 12:18:57 -07:00
bors
bfafb8e0d6 Auto merge of #5673 - phansch:endless-loop, r=Manishearth
Add regression test for endless loop / update `pulldown_cmark`

Closes #4917

This was fixed in pulldown_cmark 0.7.1, specifically raphlinus/pulldown-cmark#438

changelog: none
2020-06-01 17:16:06 +00:00
ThibsG
137a3b4d32 Corrected doc PR fixes 2020-06-01 10:49:48 +02:00
ThibsG
9893254dff Add more corrected code for doc 2020-06-01 10:39:52 +02:00
ThibsG
19339334cb Give more corrected code examples in doc 2020-06-01 10:39:52 +02:00
ThibsG
262c9dc025 Fix more code examples 2020-06-01 10:39:52 +02:00
ThibsG
61587c9a29 Fix some code examples in doc 2020-06-01 10:39:52 +02:00
Philipp Hansch
861b897c54
Add regression test for endless loop
This was fixed in pulldown_cmark 0.7.1, specifically
https://github.com/raphlinus/pulldown-cmark/pull/438
2020-06-01 10:20:17 +02:00
JarredAllen
b89880a30c Ran update_lints 2020-05-31 15:19:31 -07:00
JarredAllen
9a5baed482 Implement suggestions from phansch 2020-05-31 15:09:12 -07:00
Ericko Samudera
32fde0b511 New lint: iter_next_slice 2020-06-01 03:08:51 +07:00
JarredAllen
20cb512e81 Updated test cases and formatted 2020-05-31 12:06:32 -07:00
JarredAllen
015ab9f925 Renamed to 2020-05-31 11:55:45 -07:00
JarredAllen
07886a9764 Detect also when works 2020-05-31 11:55:45 -07:00
JarredAllen
059e8edd15 Detect also a non-reversed comparison 2020-05-31 11:55:45 -07:00
JarredAllen
955a25ee7d Added negative test cases and ran cargo dev fmt 2020-05-31 11:55:45 -07:00
JarredAllen
943cb94dce Passes all tests now! 2020-05-31 11:55:45 -07:00
JarredAllen
8590ab4d46 More progress towards sort_by_key_reverse lint 2020-05-31 11:55:45 -07:00
JarredAllen
24847ea53e Attempted start at sort_by_key_reverse lint 2020-05-31 11:55:45 -07:00
JarredAllen
7e843515d9 Created lint 2020-05-31 11:55:45 -07:00
bors
9fdcb13edb Auto merge of #4455 - flip1995:unit_arg_appl, r=phansch
Rework suggestion generation of `unit_arg` lint

Found this bug while running `cargo fix --clippy` on quite a big codebase:

This would replace something like:
```rust
Some(fn_that_actually_does_something(&a, b))
```
with
```rust
Some(())
```
which obviously suppresses side effects.

Since pretty much every expression could have side effects, I think making this suggestion `MaybeIncorrect` is the best thing to do here.

A correct suggestion would be:

```rust
fn_that_actually_does_something(&a, b);
Some(())
```

Somehow the suggestion is not correctly applied to the arguments, when more than one argument is a unit value. I have to look into this a little more, though.

changelog: Fixes suggestion of `unit_arg` lint, so that it suggests semantic equivalent code

Fixes #4741
2020-05-31 18:01:40 +00:00
flip1995
a9cde3a804
Don't suggest to move empty blocks 2020-05-31 19:29:03 +02:00
flip1995
4c9cefa122
Move linting out in its own function 2020-05-31 18:50:33 +02:00
flip1995
f9c325f5b6
Suggest to remove the semicolon of the last stmt in a block 2020-05-31 18:50:33 +02:00
flip1995
0f69cafc2d
Rework suggestion generation and use multipart_suggestion again 2020-05-31 18:50:31 +02:00
flip1995
a1a1a4b82a
Use multiple span_suggestions instead of multipart_suggestion
multipart suggestions aren't autofixable by rustfix yet
2020-05-31 18:48:29 +02:00
flip1995
0ab823c509
Rework suggestion generation of unit_arg lint 2020-05-31 18:47:48 +02:00
Michael Wright
6122612232 Increase cargo_metadata version to 0.9.1
`clippy_lints` makes use of `dep_kinds` on `NodeDep` but this was only
added in versoin 0.9.1. Compiling with 0.9.0 will fail because of this.
2020-05-31 17:38:59 +02:00
bors
8aa8f42556 Auto merge of #5667 - djugei:master, r=flip1995
moved cast_ptr_alignment to pedantic and expanded documentation

fixes: #5618
changelog: cast_ptr_alignment moved to pedantic
2020-05-31 14:26:03 +00:00
djugei
18b5ceed79
ran update_lints 2020-05-31 16:00:29 +02:00
djugei
0bcfae92f8
moved cast_ptr_alignment to pedantic and expanded documentation 2020-05-31 15:41:33 +02:00
Philipp Krones
873c9fc8f2
Rollup merge of #5656 - ebroto:len_zero_ranges, r=matthiaskrgr
len_zero: skip ranges if feature `range_is_empty` is not enabled

If the feature is not enabled, calling `is_empty()` on a range is ambiguous. Moreover, the two possible resolutions are unstable methods, one inherent to the range and the other being part of the `ExactSizeIterator` trait.

Since `len_zero` only checks for existing `is_empty()` inherent methods, we only take into account the `range_is_empty` feature.

Related: https://github.com/rust-lang/rust/issues/48111#issuecomment-445132965

changelog: len_zero: avoid linting ranges without #![feature(range_is_empty)]

Fixes: #3807
2020-05-31 14:57:33 +02:00
Philipp Krones
0fff522071
Rollup merge of #5637 - montrivo:feature/vec_resize_to_zero, r=yaahc,flip1995
new lint: vec_resize_to_zero

implements #5444

changelog: new lint vec_resize_to_zero
2020-05-31 14:57:32 +02:00