]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoMove code generated by `update_lints` to includes
Michael Wright [Sat, 18 Sep 2021 04:43:39 +0000 (06:43 +0200)]
Move code generated by `update_lints` to includes

2 years agoAuto merge of #7736 - vxpm:master, r=giraffate
bors [Wed, 29 Sep 2021 00:10:49 +0000 (00:10 +0000)]
Auto merge of #7736 - vxpm:master, r=giraffate

Fix typo ("asynx" corrected to "async")

changelog: Fixed small typo in [`await_holding_lock`]'s documentation - "asynx" was corrected to "async"

2 years agoFix typo ("asynx" corrected to "async")
vxpm [Tue, 28 Sep 2021 20:53:12 +0000 (17:53 -0300)]
Fix typo ("asynx" corrected to "async")

2 years agoAuto merge of #7734 - Manishearth:doc-unsafe-trait, r=camsteffen
bors [Tue, 28 Sep 2021 17:09:34 +0000 (17:09 +0000)]
Auto merge of #7734 - Manishearth:doc-unsafe-trait, r=camsteffen

Make `doc_unsafe` warn on unsafe traits as well

Fixes #7732

changelog: Make [`doc_unsafe`] warn on unsafe traits as well

2 years agoAuto merge of #7711 - camsteffen:depinfo-error, r=flip1995
bors [Tue, 28 Sep 2021 16:56:02 +0000 (16:56 +0000)]
Auto merge of #7711 - camsteffen:depinfo-error, r=flip1995

Improve depinfo error

changelog: none

r? `@flip1995`

2 years agoAuto merge of #7733 - flip1995:rustup, r=flip1995
bors [Tue, 28 Sep 2021 16:42:31 +0000 (16:42 +0000)]
Auto merge of #7733 - flip1995:rustup, r=flip1995

Rustup

This needs a review this time. Especially https://github.com/rust-lang/rust-clippy/commit/521bf8f0fa18c7f130505f0a902ab0e65a76cec2 cc `@camsteffen` I think this is necessary now, because `itertools` is no longer a dependency of `clippy_utils` and therefore this path can't be found :thinking:

( I forgot about the sync last week. I should get to document this process better, so other people can do it when I'm not around )

changelog: none

2 years agoCleanup of rustup changes
flip1995 [Tue, 28 Sep 2021 16:40:06 +0000 (17:40 +0100)]
Cleanup of rustup changes

2 years agoBump nightly version -> 2021-09-28
flip1995 [Tue, 28 Sep 2021 09:54:04 +0000 (10:54 +0100)]
Bump nightly version -> 2021-09-28

2 years agoUpdate clippy_lints/src/doc.rs
Manish Goregaokar [Tue, 28 Sep 2021 16:37:11 +0000 (09:37 -0700)]
Update clippy_lints/src/doc.rs

Co-authored-by: Cameron Steffen <cam.steffen94@gmail.com>
2 years agoAllow internal lint INVALID_PATHS for itertools path
flip1995 [Tue, 28 Sep 2021 09:53:11 +0000 (10:53 +0100)]
Allow internal lint INVALID_PATHS for itertools path

Since clippy_utils doesn't depend on the itertools crate anymore, the
lint can't find the path.

2 years agoMake doc_unsafe lint on unsafe traits as well
Manish Goregaokar [Tue, 28 Sep 2021 15:33:58 +0000 (08:33 -0700)]
Make doc_unsafe lint on unsafe traits as well

2 years agoAuto merge of #7727 - flip1995:changelog, r=xFrednet
bors [Tue, 28 Sep 2021 10:27:47 +0000 (10:27 +0000)]
Auto merge of #7727 - flip1995:changelog, r=xFrednet

Update changelog to 1.56

As expected a pretty short changelog, because of the missed sync last release cycle.

[Rendered](https://github.com/flip1995/rust-clippy/blob/changelog/CHANGELOG.md)

changelog: none

2 years agoFix CHANGELOG formatting
flip1995 [Tue, 28 Sep 2021 10:08:40 +0000 (11:08 +0100)]
Fix CHANGELOG formatting

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Tue, 28 Sep 2021 09:50:56 +0000 (10:50 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #7608 - andrewpollack:7594/while_let_some_result, r=Manishearth
bors [Tue, 28 Sep 2021 05:33:57 +0000 (05:33 +0000)]
Auto merge of #7608 - andrewpollack:7594/while_let_some_result, r=Manishearth

#7594: Adding new 'while_let_some_result' linting

Excited for the opportunity to contribute to Clippy! Since the latest Bay Area Rust Meetup, I've been looking for an opportunity and found it :smile:

Please let me know how I can improve this PR! Much of it is similar to ``[`if_let_some_result`]``, but I followed the description in the issue to create its own linting rules. Looking forward to feedback, and continuing to work on Clippy in the future!

changelog: Renamed Lint: `if_let_some_result` is now called [`match_result_ok`]. Now also handles `while let` case.

2 years agofmt
Manish Goregaokar [Tue, 28 Sep 2021 05:33:45 +0000 (22:33 -0700)]
fmt

2 years agoAdd renamed lint
Manish Goregaokar [Tue, 28 Sep 2021 05:26:14 +0000 (22:26 -0700)]
Add renamed lint

2 years agoUse a single if_chain
Manish Goregaokar [Tue, 28 Sep 2021 05:09:23 +0000 (22:09 -0700)]
Use a single if_chain

2 years agoAdjusting changelog
Andrew Pollack [Sat, 25 Sep 2021 15:39:00 +0000 (08:39 -0700)]
Adjusting changelog

2 years agoRemoved value from changelog to get pass
Andrew Pollack [Tue, 21 Sep 2021 00:34:32 +0000 (17:34 -0700)]
Removed value from changelog to get pass

2 years agoAdding new linting
Andrew Pollack [Mon, 30 Aug 2021 01:49:09 +0000 (18:49 -0700)]
Adding new  linting

2 years agoUpdate changelog to 1.56
flip1995 [Mon, 27 Sep 2021 09:56:49 +0000 (11:56 +0200)]
Update changelog to 1.56

2 years agoAuto merge of #7664 - matthiaskrgr:bump_to_2021, r=flip1995
bors [Mon, 27 Sep 2021 09:14:10 +0000 (09:14 +0000)]
Auto merge of #7664 - matthiaskrgr:bump_to_2021, r=flip1995

bump clippy crates to edition 2021

Also helps with dogfooding edition 2021 a bit. :)
Tests passed locally.

---

changelog: bump edition from 2018 to 2021

2 years agoAuto merge of #7692 - workingjubilee:float-cmp-not-wrong, r=giraffate
bors [Mon, 27 Sep 2021 09:00:31 +0000 (09:00 +0000)]
Auto merge of #7692 - workingjubilee:float-cmp-not-wrong, r=giraffate

Demote float_cmp to pedantic

See this issue: https://github.com/rust-lang/rust-clippy/issues/7666

This is one of the most frequently suppressed lints. It is deny-by-default. It is not actually clearly wrong, as there are many instances where direct float comparison is actually desirable. It is only after operating on floats that they may lose precision, and that depends greatly on the operation. As most correctness lints have a much higher standard of error, being based on hard and fast binary logic, this should not be amongst them.

A linter is not a substitute for observing the math carefully and running tests, and doing the desirable thing is even more likely to lead one to want exact comparisons.

changelog: Demote [`float_cmp`] from correctness to pedantic lints

2 years agoAuto merge of #7722 - dtolnay-contrib:float, r=giraffate
bors [Mon, 27 Sep 2021 00:49:08 +0000 (00:49 +0000)]
Auto merge of #7722 - dtolnay-contrib:float, r=giraffate

Stop suggesting a float truncation that is not shorter

Fixes #7721.

Previously Clippy would say that a number has excessive precision even if it has the minimum possible precision for the floating point value that it corresponds to.

changelog: Fix [`excessive_precision`] being triggered on floats that are already written in shortest form

2 years agoStop suggesting a float truncation that is not shorter
David Tolnay [Sun, 26 Sep 2021 05:54:08 +0000 (22:54 -0700)]
Stop suggesting a float truncation that is not shorter

2 years agoRollup merge of #89216 - r00ster91:bigo, r=dtolnay
Manish Goregaokar [Sun, 26 Sep 2021 01:22:20 +0000 (18:22 -0700)]
Rollup merge of #89216 - r00ster91:bigo, r=dtolnay

Consistent big O notation

This makes the big O time complexity notation in places with markdown support more consistent.
Inspired by #89210

2 years agoclippy lints: update doctest ranges to inclusive ones
Matthias Krüger [Fri, 10 Sep 2021 21:47:51 +0000 (23:47 +0200)]
clippy lints: update doctest ranges to inclusive ones

2 years agobump clippy crates to edition 2021
Matthias Krüger [Fri, 10 Sep 2021 20:57:00 +0000 (22:57 +0200)]
bump clippy crates to edition 2021

2 years agoAuto merge of #89030 - nbdd0121:box2, r=jonas-schievink
bors [Sat, 25 Sep 2021 11:01:13 +0000 (11:01 +0000)]
Auto merge of #89030 - nbdd0121:box2, r=jonas-schievink

Introduce `Rvalue::ShallowInitBox`

Polished version of #88700.

Implements MCP rust-lang/compiler-team#460, and should allow #43596 to go forward.

In short, creating an empty box is split from a nullary-op `NullOp::Box` into two steps, first a call to `exchange_malloc`, then a `Rvalue::ShallowInitBox` which transmutes `*mut u8` to a shallow-initialized `Box<T>`. This allows the `exchange_malloc` call to unwind. Details can be found in the MCP.

`NullOp::Box` is not yet removed, purely to make reverting easier in case anything goes wrong as the result of this PR. If revert is needed a reversion of "Use Rvalue::ShallowInitBox for box expression" commit followed by a test bless should be sufficient.

Experiments in #88700 showed a very slight compile-time perf regression due to (supposedly) slightly more time spent in LLVM. We could omit unwind edge generation (in non-`oom=panic` case) in box expression MIR construction to restore perf; but I don't think it's necessary since runtime perf isn't affected and perf difference is rather small.

2 years agoIntroduce `Rvalue::ShallowInitBox`
Gary Guo [Mon, 6 Sep 2021 17:33:23 +0000 (18:33 +0100)]
Introduce `Rvalue::ShallowInitBox`

2 years agoRollup merge of #89001 - jackh726:binder-cleanup, r=nikomatsakis
Jubilee [Fri, 24 Sep 2021 18:40:11 +0000 (11:40 -0700)]
Rollup merge of #89001 - jackh726:binder-cleanup, r=nikomatsakis

Be explicit about using Binder::dummy

This is somewhat of a late followup to the binder refactor PR. It removes `ToPredicate` and `ToPolyTraitImpls` that hide the use of `Binder::dummy`. While this does make code a bit more verbose, it allows us be more careful about where we create binders.

Another alternative here might be to add a new trait `ToBinder` or something with a `dummy()` fn. Which could still allow grepping but allows doing something like `trait_ref.dummy()` (but I also wonder if longer-term, it would be better to be even more explicit with a `bind_with_vars(ty::List::empty())` *but* that's not clear yet.

r? ``@nikomatsakis``

2 years agoImprove depinfo error
Cameron Steffen [Thu, 23 Sep 2021 18:14:46 +0000 (13:14 -0500)]
Improve depinfo error

2 years agoAuto merge of #7669 - Labelray:if_then_panic, r=giraffate
bors [Fri, 24 Sep 2021 14:43:51 +0000 (14:43 +0000)]
Auto merge of #7669 - Labelray:if_then_panic, r=giraffate

New lint `if_then_panic`

changelog: add the new lint [`if_then_panic`]
fix #7645

2 years agoAuto merge of #7715 - F3real:vec2, r=camsteffen
bors [Fri, 24 Sep 2021 14:24:41 +0000 (14:24 +0000)]
Auto merge of #7715 - F3real:vec2, r=camsteffen

Avoid needless heap allocation in box_collection

Fix issue left from previous PR

changelog: none.

r? `@Manishearth`

2 years agoAdd new lint `if_then_panic`
Labelray [Tue, 14 Sep 2021 08:28:09 +0000 (16:28 +0800)]
Add new lint `if_then_panic`

2 years agoconsistent big O notation
r00ster91 [Fri, 24 Sep 2021 10:44:28 +0000 (12:44 +0200)]
consistent big O notation

2 years agoAvoid needless heap allocation in box_collection
F3real [Fri, 24 Sep 2021 09:02:16 +0000 (11:02 +0200)]
Avoid needless heap allocation in box_collection

2 years agoAuto merge of #7707 - Jarcho:suspicious_else_proc_mac, r=Manishearth
bors [Thu, 23 Sep 2021 16:14:29 +0000 (16:14 +0000)]
Auto merge of #7707 - Jarcho:suspicious_else_proc_mac, r=Manishearth

Don't lint `suspicious_else_formatting` inside proc-macros

fixes: #7650

I'll add a test for this one soon.

changelog: Don't lint `suspicious_else_formatting` inside proc-macros

2 years agoAdd test for #7650
Jason Newcomb [Thu, 23 Sep 2021 15:17:54 +0000 (11:17 -0400)]
Add test for #7650

2 years agoDon't lint `suspicious_else_formatting` inside proc-macros
Jason Newcomb [Thu, 23 Sep 2021 04:22:27 +0000 (00:22 -0400)]
Don't lint `suspicious_else_formatting` inside proc-macros

2 years agoAuto merge of #89139 - camsteffen:write-perf, r=Mark-Simulacrum
bors [Thu, 23 Sep 2021 02:10:26 +0000 (02:10 +0000)]
Auto merge of #89139 - camsteffen:write-perf, r=Mark-Simulacrum

Use ZST for fmt unsafety

as suggested here - https://github.com/rust-lang/rust/pull/83302#issuecomment-923529151.

2 years agoAuto merge of #7693 - F3real:vec2, r=Manishearth
bors [Wed, 22 Sep 2021 22:13:13 +0000 (22:13 +0000)]
Auto merge of #7693 - F3real:vec2, r=Manishearth

Expand box_vec lint to box_collection

fixed #7451

changelog: Expand `box_vec` into [`box_collection`], and have it error on all sorts of boxed collections

2 years agoAdd missing reference to box_vec
F3real [Wed, 22 Sep 2021 17:59:32 +0000 (19:59 +0200)]
Add missing reference to box_vec

2 years agoAuto merge of #7704 - camsteffen:pedantic-occasional, r=Manishearth
bors [Wed, 22 Sep 2021 16:55:34 +0000 (16:55 +0000)]
Auto merge of #7704 - camsteffen:pedantic-occasional, r=Manishearth

Tweak pedantic description for occasional FPs

changelog: none

Okay this is getting a bit picky (you might even say pedantic). I think we need to be careful not use the pedantic category as cover-all for lints with any amount of false positives. Lints with a high degree of FPs should be nursery or restriction IMO. If the pedantic category were to yield, say hypothetically, over 50% FPs, it would just be too annoying to use at all (to be sure, "too picky for me" is not a FP).

CC `@rust-lang/clippy`

2 years agoTweak pedantic description for occasional FPs
Cameron Steffen [Wed, 22 Sep 2021 15:34:34 +0000 (10:34 -0500)]
Tweak pedantic description for occasional FPs

2 years agoAuto merge of #7679 - lengyijun:issue4546, r=xFrednet
bors [Wed, 22 Sep 2021 09:00:30 +0000 (09:00 +0000)]
Auto merge of #7679 - lengyijun:issue4546, r=xFrednet

add #4546 test

changelog: none
fixed #4546

I notice #4546 was fixed some time, I just add the tests.

2 years agoadd #4546 test
lengyijun [Fri, 17 Sep 2021 03:48:21 +0000 (11:48 +0800)]
add #4546 test

2 years agoAuto merge of #7685 - camsteffen:let-else-needless-ret, r=giraffate
bors [Wed, 22 Sep 2021 00:23:23 +0000 (00:23 +0000)]
Auto merge of #7685 - camsteffen:let-else-needless-ret, r=giraffate

Fix needless_return with let-else

changelog: Fix needless_return FP with `let...else`

Fixes #7637

2 years agoAuto merge of #89158 - the8472:rollup-3e4ijth, r=the8472
bors [Tue, 21 Sep 2021 22:07:32 +0000 (22:07 +0000)]
Auto merge of #89158 - the8472:rollup-3e4ijth, r=the8472

Rollup of 12 pull requests

Successful merges:

 - #88795 (Print a note if a character literal contains a variation selector)
 - #89015 (core::ascii::escape_default: reduce struct size)
 - #89078 (Cleanup: Remove needless reference in ParentHirIterator)
 - #89086 (Stabilize `Iterator::map_while`)
 - #89096 ([bootstrap] Improve the error message when `ninja` is not found to link to installation instructions)
 - #89113 (dont `.ensure()` the `thir_abstract_const` query call in `mir_build`)
 - #89114 (Fixes a technicality regarding the size of C's `char` type)
 - #89115 (:arrow_up: rust-analyzer)
 - #89126 (Fix ICE when `indirect_structural_match` is allowed)
 - #89141 (Impl `Error` for `FromSecsError` without foreign type)
 - #89142 (Fix match for placeholder region)
 - #89147 (add case for checking const refs in check_const_value_eq)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #89078 - camsteffen:map-ref, r=cjgillot
the8472 [Tue, 21 Sep 2021 20:54:00 +0000 (22:54 +0200)]
Rollup merge of #89078 - camsteffen:map-ref, r=cjgillot

Cleanup: Remove needless reference in ParentHirIterator

It forces an intermediate binding of `Map` which is a Copy type.

2 years agoAuto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebank
bors [Tue, 21 Sep 2021 19:25:49 +0000 (19:25 +0000)]
Auto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebank

Migrate in-tree crates to 2021

This replaces #89075 (cherry picking some of the commits from there), and closes #88637 and fixes #89074.

It excludes a migration of the library crates for now (see tidy diff) because we have some pending bugs around macro spans to fix there.

I instrumented bootstrap during the migration to make sure all crates moved from 2018 to 2021 had the compatibility warnings applied first.

Originally, the intent was to support cargo fix --edition within bootstrap, but this proved fairly difficult to pull off. We'd need to architect the check functionality to support running cargo check and cargo fix within the same x.py invocation, and only resetting sysroots on check. Further, it was found that cargo fix doesn't behave too well with "not quite workspaces", such as Clippy which has several crates. Bootstrap runs with --manifest-path ... for all the tools, and this makes cargo fix only attempt migration for that crate. We can't use e.g. --workspace due to needing to maintain sysroots for different phases of compilation appropriately.

It is recommended to skip the mass migration of Cargo.toml's to 2021 for review purposes; you can also use `git diff d6cd2c6c877110748296760aefddc21a0ea1d316 -I'^edition = .20...$'` to ignore the edition = 2018/21 lines in the diff.

2 years agoDemote float_cmp to pedantic
Jubilee Young [Sun, 19 Sep 2021 23:10:29 +0000 (16:10 -0700)]
Demote float_cmp to pedantic

2 years agoAuto merge of #7694 - Jarcho:lintcheck_retry, r=matthiaskrgr
bors [Tue, 21 Sep 2021 16:59:48 +0000 (16:59 +0000)]
Auto merge of #7694 - Jarcho:lintcheck_retry, r=matthiaskrgr

Retry on some download errors in lintcheck

I'm currently on spotty wifi right now. It is shocking the number of things that break when you lose connection for a few seconds. Some 500 errors should probably also be retried, but this fixes my issue.

changelog: None

2 years agoUse ZST for fmt unsafety
Cameron Steffen [Tue, 21 Sep 2021 05:56:45 +0000 (00:56 -0500)]
Use ZST for fmt unsafety

This allows the format_args! macro to keep the pre-expansion code out of
the unsafe block without doing gymnastics with nested `match`
expressions. This reduces codegen.

2 years agoRemove Drop-caused migration-added captures
Mark Rousskov [Sun, 19 Sep 2021 17:46:05 +0000 (13:46 -0400)]
Remove Drop-caused migration-added captures

All of these were added due to insignificant Drop types being present.

2 years agoRegister lint rename
F3real [Mon, 20 Sep 2021 21:07:17 +0000 (23:07 +0200)]
Register lint rename

2 years agoRetry on some download errors in lintcheck
Jason Newcomb [Mon, 20 Sep 2021 16:50:59 +0000 (12:50 -0400)]
Retry on some download errors in lintcheck

2 years agoEnable 2021 compatibility lints for all in-tree code
Mark Rousskov [Sat, 18 Sep 2021 21:37:24 +0000 (17:37 -0400)]
Enable 2021 compatibility lints for all in-tree code

This just applies the suggested fixes from the compatibility warnings,
leaving any that are in practice spurious in. This is primarily intended to
provide a starting point to identify possible fixes to the migrations (e.g., by
avoiding spurious warnings).

A secondary commit cleans these up where they are false positives (as is true in
many of the cases).

2 years agoExpand BOX_VEC to BOX_COLLECTION
F3real [Fri, 17 Sep 2021 22:56:14 +0000 (00:56 +0200)]
Expand BOX_VEC to BOX_COLLECTION

2 years agoDo not store visibility in *ItemRef.
Camille GILLOT [Thu, 15 Jul 2021 20:19:39 +0000 (22:19 +0200)]
Do not store visibility in *ItemRef.

2 years agoAuto merge of #7690 - Jarcho:while_loop_by_ref, r=xFrednet
bors [Sun, 19 Sep 2021 17:37:04 +0000 (17:37 +0000)]
Auto merge of #7690 - Jarcho:while_loop_by_ref, r=xFrednet

Change `while_let_on_iterator` suggestion to use `by_ref()`

It came up in the discussion #7659 that suggesting `iter.by_ref()` is a clearer suggestion than `&mut iter`. I personally think they're equivalent, but if `by_ref()` is clearer to people then that should be the suggestion.

changelog: Change `while_let_on_iterator` suggestion when using `&mut` to use `by_ref()`

2 years agoRemove needless hir Map ref
Cameron Steffen [Sat, 18 Sep 2021 20:48:07 +0000 (15:48 -0500)]
Remove needless hir Map ref

2 years agoFix needless_return with let-else
Cameron Steffen [Sat, 18 Sep 2021 14:40:16 +0000 (09:40 -0500)]
Fix needless_return with let-else

2 years agoChange the suggestion for `while_let_on_iterator` when the iterator cannot be consume...
Jason Newcomb [Sat, 18 Sep 2021 01:44:21 +0000 (21:44 -0400)]
Change the suggestion for `while_let_on_iterator` when the iterator cannot be consumed to `iter.by_ref()`

2 years agoAuto merge of #7657 - dswij:needless-borrow-mut, r=llogiq
bors [Fri, 17 Sep 2021 22:25:07 +0000 (22:25 +0000)]
Auto merge of #7657 - dswij:needless-borrow-mut, r=llogiq

`needless_borrow` checks for mutable borrow

closes #7635

changelog: [`needless_borrow`] now checks for needless mutable borrow

2 years agoAuto merge of #7653 - lengyijun:same_name_method_crate, r=llogiq
bors [Fri, 17 Sep 2021 22:02:04 +0000 (22:02 +0000)]
Auto merge of #7653 - lengyijun:same_name_method_crate, r=llogiq

New lint: `same_name_method`

changelog: ``[`same_name_method`]``
fix: https://github.com/rust-lang/rust-clippy/issues/7632

It only compares a method in `impl` with another in `impl trait for`
It doesn't lint two methods in two traits.

I'm not sure my approach is the best way. I meet difficulty in other approaches.

2 years agoAuto merge of #7678 - lengyijun:issue3414, r=giraffate
bors [Fri, 17 Sep 2021 02:07:11 +0000 (02:07 +0000)]
Auto merge of #7678 - lengyijun:issue3414, r=giraffate

add #3414 test

changelog: none
fixes #3414

I found #3414 was fixed some time. So I add the tests.

2 years agoadd 3414 test
lyj [Thu, 16 Sep 2021 08:52:57 +0000 (16:52 +0800)]
add 3414 test

2 years agoFix clippy
jackh726 [Thu, 16 Sep 2021 04:12:56 +0000 (00:12 -0400)]
Fix clippy

2 years agoAuto merge of #7671 - dtolnay-contrib:singlecharnames, r=xFrednet
bors [Tue, 14 Sep 2021 17:37:32 +0000 (17:37 +0000)]
Auto merge of #7671 - dtolnay-contrib:singlecharnames, r=xFrednet

Downgrade many_single_char_names to pedantic

As suggested by `@flip1995` in https://github.com/rust-lang/rust-clippy/issues/7666#issuecomment-918993215, by today's standards this lint would be considered `pedantic`.

This is one of the most widely suppressed Clippy lints on crates.io according to https://github.com/dtolnay/noisy-clippy.

In my opinion this lint is just too domain specific for Clippy to have reliable visibility into. Sure there are some cases where the author is just being lazy and could use a kick in the butt, but we're still left with an enormous number of suppressions where single chars are the most appropriate name. For example in the context of colors, a function using `h`, `s`, `l`, `r`, `g`, `b` is 100% sensible and spelling all those out is silly, but it's past the default lint threshold.

---

changelog: Moved [`many_single_char_names`] to `pedantic`

2 years agoDowngrade many_single_char_names to pedantic
David Tolnay [Tue, 14 Sep 2021 16:48:30 +0000 (09:48 -0700)]
Downgrade many_single_char_names to pedantic

2 years agoAuto merge of #7640 - kneasle:mut-key-false-positive, r=camsteffen
bors [Tue, 14 Sep 2021 15:56:07 +0000 (15:56 +0000)]
Auto merge of #7640 - kneasle:mut-key-false-positive, r=camsteffen

Improve accuracy of `mut_key`

Fixes #6745.

Whilst writing the tests for this, I noticed what I believe is a false negative (the code in `@xFrednet's` [comment](https://github.com/rust-lang/rust-clippy/issues/6745#issuecomment-909658267) doesn't trigger the lint).  Currently the tests contain a case for this (which is blatantly ignored), but I'm not at all sure how to implement this (since the lint currently behaves completely differently for ADTs).  I'm not sure what should be done - on the one hand the extra test cases are misleading, but on the other hand they don't cause much harm and would save effort for anyone fixing that false negative.

---

changelog: Improve accuracy of `clippy::mutable_key_type`.

2 years agoFix FN for collections/smart ptrs in `std`
Kneasle [Wed, 8 Sep 2021 21:51:47 +0000 (22:51 +0100)]
Fix FN for collections/smart ptrs in `std`

2 years agoAuto merge of #7670 - xFrednet:0000-lets-hope-this-fixes-rustbot-fps, r=camsteffen
bors [Tue, 14 Sep 2021 13:57:41 +0000 (13:57 +0000)]
Auto merge of #7670 - xFrednet:0000-lets-hope-this-fixes-rustbot-fps, r=camsteffen

Updating issue templates to avoid @rustbot triggers

This adds a space between the ``@`` and the name *rustbot*. This should now surely fix it. If not, I'm giving up.

@ rustbot label +C-bug

---

changelog: none

r? `@camsteffen`

2 years agoUpdating issue templates to avoid @rustbot triggers
xFrednet [Tue, 14 Sep 2021 13:49:43 +0000 (15:49 +0200)]
Updating issue templates to avoid @rustbot triggers

2 years agosame_name_method
lengyijun [Wed, 8 Sep 2021 02:36:51 +0000 (10:36 +0800)]
same_name_method

2 years agoUpdate permissions path for clippy lint
Guillaume Gomez [Mon, 13 Sep 2021 19:27:53 +0000 (21:27 +0200)]
Update permissions path for clippy lint

2 years agoFix FP when using raw pointers as hashed keys
Kneasle [Sun, 5 Sep 2021 20:58:47 +0000 (21:58 +0100)]
Fix FP when using raw pointers as hashed keys

2 years agoAuto merge of #7646 - camsteffen:relative-target, r=flip1995
bors [Mon, 13 Sep 2021 09:57:01 +0000 (09:57 +0000)]
Auto merge of #7646 - camsteffen:relative-target, r=flip1995

Target directory cleanup

changelog: none

* .cargo/config now has `target-dir` specified so that it is inherited by child projects. The target directory needs to be shared with clippy_dev, but not necessarily at the project root. (cc #7625)
* Uses `std::env::current_exe` (and its parent directories) whenever possible
* `CLIPPY_DRIVER_PATH` and `TARGET_LIBS` are no longer required from rustc bootstrap (but `HOST_LIBS` still is). These can be removed from the rustc side after merging.
* `CLIPPY_DOGFOOD` and the separate target directory are removed. This was originally added to mitigate #7343.

r? `@flip1995`

2 years agoUpdate `needless_borrow` test output and expected fix
dswij [Thu, 9 Sep 2021 15:38:03 +0000 (23:38 +0800)]
Update `needless_borrow` test output and expected fix

2 years agoFix `needless_borrow` not linting mutable reference
dswij [Thu, 9 Sep 2021 15:37:18 +0000 (23:37 +0800)]
Fix `needless_borrow` not linting mutable reference

2 years agoUpdate test for needless-borrow FP for mutable ref
dswij [Thu, 9 Sep 2021 15:33:28 +0000 (23:33 +0800)]
Update test for needless-borrow FP for mutable ref

2 years agoAuto merge of #88517 - smoelius:without-patch-versions, r=flip1995
bors [Mon, 13 Sep 2021 02:45:18 +0000 (02:45 +0000)]
Auto merge of #88517 - smoelius:without-patch-versions, r=flip1995

Update Clippy dependencies without patch versions

Trial run for https://github.com/rust-lang/rust-clippy/pull/7606

2 years agoAuto merge of #7661 - camsteffen:eta, r=giraffate
bors [Mon, 13 Sep 2021 00:39:34 +0000 (00:39 +0000)]
Auto merge of #7661 - camsteffen:eta, r=giraffate

Fix various redundant_closure bugs

changelog: Fix various false negatives and false positives for [`redundant_closure`]

Closes #3071
Closes #4002

This lint is full of weird nuances and this is basically a re-write to tighten up the logic.

2 years agoAuto merge of #88839 - nbdd0121:alignof, r=nagisa
bors [Sun, 12 Sep 2021 23:49:24 +0000 (23:49 +0000)]
Auto merge of #88839 - nbdd0121:alignof, r=nagisa

Introduce NullOp::AlignOf

This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`.

The changes are originally part of #88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.

2 years agoIntroduce NullOp::AlignOf
Gary Guo [Tue, 7 Sep 2021 15:06:07 +0000 (16:06 +0100)]
Introduce NullOp::AlignOf

2 years agoRollup merge of #88677 - petrochenkov:exportid, r=davidtwco
Manish Goregaokar [Sun, 12 Sep 2021 10:44:53 +0000 (03:44 -0700)]
Rollup merge of #88677 - petrochenkov:exportid, r=davidtwco

rustc: Remove local variable IDs from `Export`s

Local variables can never be exported.

2 years agoAuto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov
bors [Sat, 11 Sep 2021 23:35:28 +0000 (23:35 +0000)]
Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov

Encode spans relative to the enclosing item

The aim of this PR is to avoid recomputing queries when code is moved without modification.

MCP at https://github.com/rust-lang/compiler-team/issues/443

This is achieved by :
1. storing the HIR owner LocalDefId information inside the span;
2. encoding and decoding spans relative to the enclosing item in the incremental on-disk cache;
3. marking a dependency to the `source_span(LocalDefId)` query when we translate a span from the short (`Span`) representation to its explicit (`SpanData`) representation.

Since all client code uses `Span`, step 3 ensures that all manipulations
of span byte positions actually create the dependency edge between
the caller and the `source_span(LocalDefId)`.
This query return the actual absolute span of the parent item.
As a consequence, any source code motion that changes the absolute byte position of a node will either:
- modify the distance to the parent's beginning, so change the relative span's hash;
- dirty `source_span`, and trigger the incremental recomputation of all code that
  depends on the span's absolute byte position.

With this scheme, I believe the dependency tracking to be accurate.

For the moment, the spans are marked during lowering.
I'd rather do this during def-collection,
but the AST MutVisitor is not practical enough just yet.
The only difference is that we attach macro-expanded spans
to their expansion point instead of the macro itself.

2 years agoRebase fallout.
Camille GILLOT [Fri, 10 Sep 2021 17:57:06 +0000 (19:57 +0200)]
Rebase fallout.

2 years agoAuto merge of #7663 - Jarcho:rsplit_once_order, r=llogiq
bors [Sat, 11 Sep 2021 08:29:52 +0000 (08:29 +0000)]
Auto merge of #7663 - Jarcho:rsplit_once_order, r=llogiq

Fix result order for `manual_split_once` when `rsplitn` is used

fixes: #7656

changelog: Fix result order for `manual_split_once` when `rsplitn` is used

2 years agoAuto merge of #88214 - notriddle:notriddle/for-loop-span-drop-temps-mut, r=nagisa
bors [Sat, 11 Sep 2021 07:11:01 +0000 (07:11 +0000)]
Auto merge of #88214 - notriddle:notriddle/for-loop-span-drop-temps-mut, r=nagisa

rustc: use more correct span data in for loop desugaring

Fixes #82462

Before:

      help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped
         |
      LL |     for x in DroppingSlice(&*v).iter(); {
         |                                       +

After:

      help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped
         |
      LL |     };
         |      +

This seems like a reasonable fix: since the desugared "expr_drop_temps_mut" contains the entire desugared loop construct, its span should contain the entire loop construct as well.

2 years agorustc: Remove local variable IDs from `Export`s
Vadim Petrochenkov [Sun, 5 Sep 2021 20:37:15 +0000 (23:37 +0300)]
rustc: Remove local variable IDs from `Export`s

Local variables can never be exported.

2 years agoKeep a parent LocalDefId in SpanData.
Camille GILLOT [Sun, 18 Apr 2021 12:27:04 +0000 (14:27 +0200)]
Keep a parent LocalDefId in SpanData.

2 years agoFix result order for `manual_split_once` when `rsplitn` is used
Jason Newcomb [Fri, 10 Sep 2021 16:20:39 +0000 (12:20 -0400)]
Fix result order for `manual_split_once` when `rsplitn` is used

2 years agoAuto merge of #7660 - HKalbasi:derivable-impls, r=camsteffen
bors [Fri, 10 Sep 2021 15:32:16 +0000 (15:32 +0000)]
Auto merge of #7660 - HKalbasi:derivable-impls, r=camsteffen

Fix derivable impl false positives

fix #7654
fix #7655

changelog: none (not released)

2 years agofix derivable impl false positives
hamidreza kalbasi [Fri, 10 Sep 2021 13:40:55 +0000 (18:10 +0430)]
fix derivable impl false positives

2 years agoEat dogfood
Cameron Steffen [Thu, 9 Sep 2021 20:36:06 +0000 (15:36 -0500)]
Eat dogfood

2 years agoFix redundant closure bugs
Cameron Steffen [Thu, 9 Sep 2021 20:35:26 +0000 (15:35 -0500)]
Fix redundant closure bugs

2 years agoIgnore automatically derived impls of `Clone` and `Debug` in dead code analysis
Fabian Wolff [Fri, 21 May 2021 17:35:49 +0000 (19:35 +0200)]
Ignore automatically derived impls of `Clone` and `Debug` in dead code analysis