]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoReturn to generating mod declarations in lib.rs
Manish Goregaokar [Wed, 6 Oct 2021 07:12:38 +0000 (00:12 -0700)]
Return to generating mod declarations in lib.rs

2 years agoDrop exponent suggestion when 0
dswij [Wed, 6 Oct 2021 07:02:38 +0000 (15:02 +0800)]
Drop exponent suggestion when 0

This commit changes numeric literal formatting to drop exponent when
exponent is 0.

2 years agoAuto merge of #7770 - zvavybir:master, r=xFrednet
bors [Tue, 5 Oct 2021 19:51:09 +0000 (19:51 +0000)]
Auto merge of #7770 - zvavybir:master, r=xFrednet

improved help message for `suspicious_map`

`suspicious_map`'s help message assumes that the literal behavior is never the intended one, although it's sometimes.  This PR adds a mention of `inspect`, offering a idiomatic alternative.

fixes #7767

---

changelog: Improved help message of [`suspicious_map`].

2 years agoMentioned `inspect` in lint description of `suspicious_map`
Matthias Kaak [Tue, 5 Oct 2021 19:40:15 +0000 (19:40 +0000)]
Mentioned `inspect` in lint description of `suspicious_map`

2 years agoimproved help message for `suspicious_map`
Matthias Kaak [Tue, 5 Oct 2021 19:03:13 +0000 (19:03 +0000)]
improved help message for `suspicious_map`

2 years agoAuto merge of #7762 - HKalbasi:master, r=Manishearth
bors [Mon, 4 Oct 2021 19:38:04 +0000 (19:38 +0000)]
Auto merge of #7762 - HKalbasi:master, r=Manishearth

Add lint `equatable_if_let`

This is my attempt for #1716. There is a major false positive, which is people may implement `PartialEq` in a different way. It is unactionable at the moment so I put it into `nursery`.

There is a trait `StructuralPartialEq` for solving this problem which is promising but it has several problems currently:
* Integers and tuples doesn't implement it.
* Some types wrongly implement it, like `Option<T>` when `T` doesn't implement it.

I consider them bugs and against the propose of `StructuralPartialEq`. When they become fixed, this lint can become a useful lint with a single line change.

changelog: New lint: [`equatable_if_let`]

2 years agoImplement equatable if let lint
hkalbasi [Mon, 4 Oct 2021 06:33:40 +0000 (10:03 +0330)]
Implement equatable if let lint

2 years agoAuto merge of #7761 - giraffate:fix_ice_in_inplicit_hasher, r=Manishearth
bors [Mon, 4 Oct 2021 17:07:00 +0000 (17:07 +0000)]
Auto merge of #7761 - giraffate:fix_ice_in_inplicit_hasher, r=Manishearth

Fix ICE in `implicit_hasher`

close #7712

changelog: Fix ICE in [`implicit_hasher`]

2 years agoFix ICE in `implicit_hasher`
Takayuki Nakata [Mon, 4 Oct 2021 14:31:40 +0000 (23:31 +0900)]
Fix ICE in `implicit_hasher`

2 years agoAuto merge of #88175 - camsteffen:let-desugar-span, r=Manishearth
bors [Sun, 3 Oct 2021 21:44:10 +0000 (21:44 +0000)]
Auto merge of #88175 - camsteffen:let-desugar-span, r=Manishearth

Add expansion to while desugar spans

In the same vein as #88163, this reverts a change in Clippy behavior as a result of #80357 (and reverts some `#[allow]`s): This changes `clippy::blocks_in_if_conditions` to not fire on `while` loops. Though we might actually want Clippy to lint those cases, we should introduce the change purposefully, with tests, and possibly under a different lint name.

The actual change here is to add a desugaring expansion to the spans when lowering a `while` loop.

r? `@Manishearth`

2 years agoAuto merge of #7755 - HKalbasi:master, r=xFrednet
bors [Sun, 3 Oct 2021 10:30:16 +0000 (10:30 +0000)]
Auto merge of #7755 - HKalbasi:master, r=xFrednet

exclude enum from derivable impls

fix #7753

changelog: Exclude enum from ``[`derivable_impls`]``

2 years agoChange not enum to is struct
HKalbasi [Sun, 3 Oct 2021 09:31:57 +0000 (13:01 +0330)]
Change not enum to is struct

2 years agoAuto merge of #7709 - Qwaz:drop_non_send, r=xFrednet
bors [Sun, 3 Oct 2021 08:43:32 +0000 (08:43 +0000)]
Auto merge of #7709 - Qwaz:drop_non_send, r=xFrednet

Implement `non_send_field_in_send_ty` lint

changelog: Implement [`non_send_fields_in_send_ty`] lint

Fixes #7703

2 years agoexclude enum from derivable impls
hkalbasi [Sun, 3 Oct 2021 08:28:27 +0000 (11:58 +0330)]
exclude enum from derivable impls

2 years agoMake diangostic item names consistent
Cameron Steffen [Sat, 2 Oct 2021 23:51:01 +0000 (18:51 -0500)]
Make diangostic item names consistent

2 years agoUpdate documentation and name for non_send_fields_in_send_ty lint
Yechan Bae [Sat, 2 Oct 2021 23:22:37 +0000 (19:22 -0400)]
Update documentation and name for non_send_fields_in_send_ty lint

2 years agoAdd desugaring mark to while loop
Cameron Steffen [Thu, 19 Aug 2021 21:57:15 +0000 (16:57 -0500)]
Add desugaring mark to while loop

2 years agoAuto merge of #7747 - Manishearth:excessive-precision, r=xFrednet
bors [Sat, 2 Oct 2021 16:12:30 +0000 (16:12 +0000)]
Auto merge of #7747 - Manishearth:excessive-precision, r=xFrednet

Correctly handle signs in exponents in numeric_literal::format()

Fixes #7744

changelog: Correctly handle signs in exponents in `numeric_literal::format()`

2 years agoCorrectly handle signs in exponents in numeric_literal::format()
Manish Goregaokar [Sat, 2 Oct 2021 00:27:47 +0000 (17:27 -0700)]
Correctly handle signs in exponents in numeric_literal::format()

2 years agoAdd regression test
Manish Goregaokar [Fri, 1 Oct 2021 23:14:35 +0000 (16:14 -0700)]
Add regression test

2 years agoAuto merge of #89449 - Manishearth:rollup-3alb61f, r=Manishearth
bors [Fri, 1 Oct 2021 22:47:22 +0000 (22:47 +0000)]
Auto merge of #89449 - Manishearth:rollup-3alb61f, r=Manishearth

Rollup of 7 pull requests

Successful merges:

 - #85223 (rustdoc: Clarified the attribute which prompts the warning)
 - #88847 (platform-support.md: correct ARMv7+MUSL platform triple notes)
 - #88963 (Coerce const FnDefs to implement const Fn traits )
 - #89376 (Fix use after drop in self-profile with llvm events)
 - #89422 (Replace whitespaces in doctests' name with dashes)
 - #89440 (Clarify a sentence in the documentation of Vec (#84488))
 - #89441 (Normalize after substituting via `field.ty()`)

Failed merges:

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

2 years agoRollup merge of #88963 - fee1-dead:const-iterator, r=oli-obk
Manish Goregaokar [Fri, 1 Oct 2021 21:46:48 +0000 (14:46 -0700)]
Rollup merge of #88963 - fee1-dead:const-iterator, r=oli-obk

Coerce const FnDefs to implement const Fn traits

You can now pass a FnDef to a function expecting `F` where `F: ~const FnTrait`.

r? ``@oli-obk``

``@rustbot`` label T-compiler F-const_trait_impl

2 years agoAuto merge of #88880 - cjgillot:no-krate, r=oli-obk
bors [Fri, 1 Oct 2021 20:06:34 +0000 (20:06 +0000)]
Auto merge of #88880 - cjgillot:no-krate, r=oli-obk

Rework HIR API to make invocations of the hir_crate query harder.

`hir_crate` forces the recomputation of queries that depend on it.

This PR aims at avoiding useless invocations of `hir_crate` by making dependent code go through `tcx.hir()`.

2 years agoForgot to bless ui-toml test
Yechan Bae [Fri, 1 Oct 2021 18:26:04 +0000 (14:26 -0400)]
Forgot to bless ui-toml test

2 years agoDo not use full type path in help message
Yechan Bae [Fri, 1 Oct 2021 18:00:50 +0000 (14:00 -0400)]
Do not use full type path in help message

2 years agoAdd ui-test for enable-raw-pointer-heuristic-for-send config
Yechan Bae [Fri, 1 Oct 2021 17:07:25 +0000 (13:07 -0400)]
Add ui-test for enable-raw-pointer-heuristic-for-send config

2 years agoMinor changes from PR feedback
Yechan Bae [Fri, 1 Oct 2021 16:47:54 +0000 (12:47 -0400)]
Minor changes from PR feedback

2 years agoAdd configuration for raw pointer heuristic
Yechan Bae [Tue, 28 Sep 2021 20:55:36 +0000 (16:55 -0400)]
Add configuration for raw pointer heuristic

2 years agoLook into tuple, array, ADT args in raw pointer heuristic
Yechan Bae [Tue, 28 Sep 2021 20:42:27 +0000 (16:42 -0400)]
Look into tuple, array, ADT args in raw pointer heuristic

2 years agoEmit one report for all fields in the same ADT
Yechan Bae [Tue, 28 Sep 2021 19:23:39 +0000 (15:23 -0400)]
Emit one report for all fields in the same ADT

2 years agoUpdate documentation
Yechan Bae [Tue, 28 Sep 2021 17:46:13 +0000 (13:46 -0400)]
Update documentation

2 years agotypo
Yechan Bae [Thu, 23 Sep 2021 10:49:23 +0000 (06:49 -0400)]
typo

2 years agoFix attribute handling
Yechan Bae [Thu, 23 Sep 2021 10:45:24 +0000 (06:45 -0400)]
Fix attribute handling

2 years agoInitial implementation
Yechan Bae [Thu, 23 Sep 2021 07:51:10 +0000 (03:51 -0400)]
Initial implementation

2 years agoAuto merge of #7741 - surechen:fix_if_then_panic, r=flip1995
bors [Fri, 1 Oct 2021 10:04:19 +0000 (10:04 +0000)]
Auto merge of #7741 - surechen:fix_if_then_panic, r=flip1995

Make if_then_panic handle situation of BinOpKind::And || BinOpKind::Or

fixes #7731

Make if_then_panic handle situation of cond.kind = ExprKind::DropTemps(ExprKind::Binary(BinOpKind::And || BinOpKind::Or, left, right), ..) =

changelog: [`if_then_panic`] Fix suggestion for more complex conditions

2 years agouse sugg::Sugg::maybe_par
surechen [Fri, 1 Oct 2021 05:13:09 +0000 (13:13 +0800)]
use sugg::Sugg::maybe_par

2 years agoRollup merge of #88782 - asquared31415:issue-79559, r=cjgillot
Manish Goregaokar [Fri, 1 Oct 2021 01:05:20 +0000 (18:05 -0700)]
Rollup merge of #88782 - asquared31415:issue-79559, r=cjgillot

Fix ICE when `start` lang item has wrong generics

In my previous pr #87875 I missed the requirements on the `start` lang item due to its relative difficulty to test and opting for more conservative estimates.  This fixes that by updating the requirement to be exactly one generic type.

The `start` lang item should have exactly one generic type for the return type of the `main` fn ptr passed to it.  I believe having zero would previously *sometimes* compile (often with the use of `fn() -> ()` as the fn ptr but it was likely UB to call if the return type of `main` was not `()` as far as I know) however it also sometimes would not for various errors including ICEs and LLVM errors depending on exact situations.  Having more than 1 generic has always failed with an ICE because only the one generic type is expected and provided.

Fixes #79559, fixes #73584, fixes #83117 (all duplicates)
Relevant to #9307

r? ````@cjgillot````

2 years agoAuto merge of #7338 - camsteffen:shadow, r=llogic
bors [Thu, 30 Sep 2021 19:08:22 +0000 (19:08 +0000)]
Auto merge of #7338 - camsteffen:shadow, r=llogic

Re-write shadow lints

changelog: Move shadow_unrelated to restriction
changelog: The shadow lints find a lot more shadows and are not limited to certain patterns

Drastically simplifies the implementation. Catches a lot more cases.

I removed the "initialization happens here" note. It is not helpful IMO.

Closes #318
Fixes #2890
Fixes #6563
Fixes #7588
Fixes #7620

2 years agoRemove shadow allows
Cameron Steffen [Mon, 27 Sep 2021 22:19:33 +0000 (17:19 -0500)]
Remove shadow allows

2 years agoRewrite shadow lint
Cameron Steffen [Sun, 10 Jan 2021 23:51:43 +0000 (17:51 -0600)]
Rewrite shadow lint

2 years agoRemove initialization note from shadow lint
Cameron Steffen [Mon, 11 Jan 2021 15:10:24 +0000 (09:10 -0600)]
Remove initialization note from shadow lint

2 years agoMove shadow_unrelated to restriction
Cameron Steffen [Sat, 25 Sep 2021 22:14:34 +0000 (17:14 -0500)]
Move shadow_unrelated to restriction

2 years agoDo not pass hir::Crate to lints.
Camille GILLOT [Sun, 12 Sep 2021 09:58:27 +0000 (11:58 +0200)]
Do not pass hir::Crate to lints.

2 years agoAuto merge of #7677 - surechen:edit_large_enum_variant, r=camsteffen
bors [Thu, 30 Sep 2021 12:45:17 +0000 (12:45 +0000)]
Auto merge of #7677 - surechen:edit_large_enum_variant, r=camsteffen

fix bug for large_enum_variants

Fix the discussion problem in the issue of https://github.com/rust-lang/rust-clippy/issues/7666#issuecomment-919654291

About the false positive problem of case:
```rust
enum LargeEnum6 {
    A,
    B([u8;255]),
    C([u8;200]),
}
```

changelog: Fix largest_enum_variant wrongly identifying the second largest variant.

2 years agofix issue #7731
surechen [Thu, 30 Sep 2021 11:06:42 +0000 (19:06 +0800)]
fix issue #7731

Make if_then_else handle situation of cond.kind = ExprKind::DropTemps(ExprKind::Binary(BinOpKind::And || BinOpKind::Or, left, right), ..) =

2 years agoAuto merge of #7684 - surechen:solve_derivable_impls, r=flip1995
bors [Thu, 30 Sep 2021 08:19:58 +0000 (08:19 +0000)]
Auto merge of #7684 - surechen:solve_derivable_impls, r=flip1995

fix for issue #7683

Fixes #7683.

For Repeat  [x; y] (x is the type and y is the times to repeat) . When y > 32, the compiler will report an error:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7148558162685e91056e0550797ea74c

Because https://github.com/rust-lang/rust/blob/6cdd42f9f8dd4e5e5ba0aa816bc4c99ab8b102f9/library/std/src/primitive_docs.rs#L538
/// Arrays of sizes from 0 to 32 (inclusive) implement [`Default`] trait
/// if the element type allows it. As a stopgap, trait implementations are
/// statically generated up to size 32.

So here to detect this situation.

changelog: [`derivable_impls`]: No longer lints when arrays bigger than 32 elements are involved

2 years agoAuto merge of #7673 - mikerite:include-generated-code, r=giraffate
bors [Thu, 30 Sep 2021 03:58:47 +0000 (03:58 +0000)]
Auto merge of #7673 - mikerite:include-generated-code, r=giraffate

Move code generated by `update_lints` to includes

Move code generated by `update_lints` to includes

changelog: none

2 years agoFix comment in `update_lints`
mikerite [Thu, 30 Sep 2021 03:11:39 +0000 (05:11 +0200)]
Fix comment in `update_lints`

Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2 years agoArrays of sizes from 0 to 32 (inclusive) implement [Default] trait, edit method is_de...
surechen [Sat, 18 Sep 2021 10:35:17 +0000 (18:35 +0800)]
Arrays of sizes from 0 to 32 (inclusive) implement [Default] trait, edit method is_default_equivalent() to satisfy with this.

2 years agofix bug for large_enum_variants
surechen [Thu, 16 Sep 2021 08:42:36 +0000 (16:42 +0800)]
fix bug for large_enum_variants

2 years agoAvoid more invocations of hir_crate query.
Camille GILLOT [Sat, 11 Sep 2021 23:11:22 +0000 (01:11 +0200)]
Avoid more invocations of hir_crate query.

2 years agoAdd includes to pre-commit hook
Michael Wright [Sat, 18 Sep 2021 04:57:03 +0000 (06:57 +0200)]
Add includes to pre-commit hook

2 years agoAdd test module for `update_lints`
Michael Wright [Sat, 18 Sep 2021 04:43:39 +0000 (06:43 +0200)]
Add test module for `update_lints`

2 years agoMove `update_lints` specific code out of `lib`
Michael Wright [Sat, 18 Sep 2021 04:43:39 +0000 (06:43 +0200)]
Move `update_lints` specific code out of `lib`

2 years agoFix lint register code format
Michael Wright [Sat, 18 Sep 2021 04:43:39 +0000 (06:43 +0200)]
Fix lint register code format

Also change the generation functions to return `String` instead of
`Vec<String>`. This makes sense now as the updates aren't line oriented
anymore.

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 agoMerge commit 'cb7915b00c235e9b5861564f3be78dba330980ee' into clippyup
flip1995 [Tue, 28 Sep 2021 17:03:12 +0000 (18:03 +0100)]
Merge commit 'cb7915b00c235e9b5861564f3be78dba330980ee' into clippyup

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