]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRevert "!: this is the commit that demonstrates the ICE"
Nathaniel Hamovitz [Tue, 19 Oct 2021 00:18:07 +0000 (17:18 -0700)]
Revert "!: this is the commit that demonstrates the ICE"

This reverts commit d85f903c91d909534003ee2ff0e16316b20687dc.

2 years ago!: this is the commit that demonstrates the ICE
Nathaniel Hamovitz [Tue, 19 Oct 2021 00:07:51 +0000 (17:07 -0700)]
!: this is the commit that demonstrates the ICE

2 years agoDon't need `rustc_attr` anymore
Nathaniel Hamovitz [Mon, 18 Oct 2021 23:53:17 +0000 (16:53 -0700)]
Don't need `rustc_attr` anymore

2 years agoImprove help message
Nathaniel Hamovitz [Mon, 18 Oct 2021 23:53:05 +0000 (16:53 -0700)]
Improve help message

2 years agoAll five `has_repr_attr` agree + are correct
Nathaniel Hamovitz [Mon, 18 Oct 2021 22:33:11 +0000 (15:33 -0700)]
All five `has_repr_attr` agree + are correct

2 years agoExploring emitting other sorts of `span`s
Nathaniel Hamovitz [Mon, 18 Oct 2021 14:02:00 +0000 (07:02 -0700)]
Exploring emitting other sorts of `span`s

2 years agoBetter testcase names
Nathaniel Hamovitz [Mon, 18 Oct 2021 11:59:03 +0000 (04:59 -0700)]
Better testcase names

2 years agoOne more test
Nathaniel Hamovitz [Mon, 18 Oct 2021 11:22:43 +0000 (04:22 -0700)]
One more test

2 years agoStill renaming lmao
Nathaniel Hamovitz [Mon, 18 Oct 2021 10:56:49 +0000 (03:56 -0700)]
Still renaming lmao

2 years agoImprove doc and span messages
Nathaniel Hamovitz [Mon, 18 Oct 2021 10:52:57 +0000 (03:52 -0700)]
Improve doc and span messages

2 years agoRename stderr
Nathaniel Hamovitz [Mon, 18 Oct 2021 10:52:37 +0000 (03:52 -0700)]
Rename stderr

2 years agoRename lint
Nathaniel Hamovitz [Mon, 18 Oct 2021 10:45:08 +0000 (03:45 -0700)]
Rename lint

2 years agorun rustfmt
Nathaniel Hamovitz [Mon, 18 Oct 2021 10:16:10 +0000 (03:16 -0700)]
run rustfmt

2 years agoTidy import + update expected stderr
Nathaniel Hamovitz [Mon, 18 Oct 2021 10:13:48 +0000 (03:13 -0700)]
Tidy import + update expected stderr

2 years agoTidy imports
Nathaniel Hamovitz [Mon, 18 Oct 2021 10:04:50 +0000 (03:04 -0700)]
Tidy imports

2 years agoCheck for tuple structs
Nathaniel Hamovitz [Mon, 18 Oct 2021 10:03:48 +0000 (03:03 -0700)]
Check for tuple structs

2 years agoRefactor ZS array detection again and this one seems great 👍
Nathaniel Hamovitz [Mon, 18 Oct 2021 07:51:30 +0000 (00:51 -0700)]
Refactor ZS array detection again and this one seems great 👍

2 years agoupdate testsuite and expand `if_chain`
Nathaniel Hamovitz [Mon, 18 Oct 2021 00:28:45 +0000 (17:28 -0700)]
update testsuite and expand `if_chain`

2 years agoTidy comments + tests; revert 'size-is-zero' detection
Nathaniel Hamovitz [Sun, 17 Oct 2021 05:03:08 +0000 (22:03 -0700)]
Tidy comments + tests; revert 'size-is-zero' detection

2 years agotried to simplify but it doesn't work :/
Nathaniel Hamovitz [Sun, 17 Oct 2021 00:49:13 +0000 (17:49 -0700)]
tried to simplify but it doesn't work :/

2 years agointermediate step
Nathaniel Hamovitz [Sat, 16 Oct 2021 23:13:14 +0000 (16:13 -0700)]
intermediate step

2 years agoadd multiple `get_attrs` and `includes_repr` and they all work!
Nathaniel Hamovitz [Sat, 16 Oct 2021 22:26:10 +0000 (15:26 -0700)]
add multiple `get_attrs` and `includes_repr` and they all work!

2 years agoRan `dev bless`!
Nathaniel Hamovitz [Sat, 16 Oct 2021 09:26:08 +0000 (02:26 -0700)]
Ran `dev bless`!

2 years agooutput looks fantastic
Nathaniel Hamovitz [Sat, 16 Oct 2021 09:01:17 +0000 (02:01 -0700)]
output looks fantastic

2 years agoit works i think (incl some `dbg`s)
Nathaniel Hamovitz [Sat, 16 Oct 2021 07:51:09 +0000 (00:51 -0700)]
it works i think (incl some `dbg`s)

2 years agoImplement getting an array of attributes!
Nathaniel Hamovitz [Sat, 16 Oct 2021 06:44:39 +0000 (23:44 -0700)]
Implement getting an array of attributes!

2 years agoImplement detecting trailing zero-sized array
Nathaniel Hamovitz [Fri, 15 Oct 2021 23:16:27 +0000 (16:16 -0700)]
Implement detecting trailing zero-sized array

2 years agoayy it compiles! ship it, right? 😎 /s
Nathaniel Hamovitz [Fri, 15 Oct 2021 08:31:26 +0000 (01:31 -0700)]
ayy it compiles! ship it, right? 😎 /s

why was `rustc_lint_defs` not already externed in `lib.rs`?
and how was r-a able to find it but cargo wasn't? 🤔

2 years agoWell it builds
Nathaniel Hamovitz [Fri, 15 Oct 2021 07:13:42 +0000 (00:13 -0700)]
Well it builds

2 years agoAdd boilerplate and basic tests
Nathaniel Hamovitz [Fri, 15 Oct 2021 03:08:38 +0000 (20:08 -0700)]
Add boilerplate and basic tests

2 years agoAuto merge of #7835 - mikerite:unneeded-allow-20211018, r=xFrednet
bors [Mon, 18 Oct 2021 07:25:12 +0000 (07:25 +0000)]
Auto merge of #7835 - mikerite:unneeded-allow-20211018, r=xFrednet

Remove unneeded allow

Remove unneeded allow

changelog: none

2 years agoRemove unneeded allow
Michael Wright [Mon, 18 Oct 2021 06:46:11 +0000 (08:46 +0200)]
Remove unneeded allow

2 years agoRollup merge of #89990 - petrochenkov:idempty, r=wesleywiser
Matthias Krüger [Mon, 18 Oct 2021 06:13:30 +0000 (08:13 +0200)]
Rollup merge of #89990 - petrochenkov:idempty, r=wesleywiser

rustc_span: `Ident::invalid` -> `Ident::empty`

The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s as well.

2 years agoAuto merge of #7832 - narpfel:implicit-saturating-sub-false-positive-else, r=giraffate
bors [Mon, 18 Oct 2021 00:22:48 +0000 (00:22 +0000)]
Auto merge of #7832 - narpfel:implicit-saturating-sub-false-positive-else, r=giraffate

Fix false positive of `implicit_saturating_sub` with `else` clause

Fixes #7831

changelog: Fix false positive of [`implicit_saturating_sub`] with `else` clause

2 years agorustc_span: `Ident::invalid` -> `Ident::empty`
Vadim Petrochenkov [Sun, 17 Oct 2021 20:20:30 +0000 (23:20 +0300)]
rustc_span: `Ident::invalid` -> `Ident::empty`

The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s.

2 years agoAdd reference to another doc with explanation
Dmitry Borodin [Sun, 17 Oct 2021 16:59:36 +0000 (18:59 +0200)]
Add reference to another doc with explanation

Add reference to another doc that explains which repository should be passed in this command since this is not covered in the command help itself.

2 years agoRollup merge of #89963 - r00ster91:parenthesisparentheses, r=nagisa
Matthias Krüger [Sun, 17 Oct 2021 16:18:59 +0000 (18:18 +0200)]
Rollup merge of #89963 - r00ster91:parenthesisparentheses, r=nagisa

Some "parenthesis" and "parentheses" fixes

"Parenthesis" is the singular (e.g. one `(` or one `)`) and "parentheses" is the plural (multiple `(` or `)`s) and this is not hard to mix up so here are some fixes for that.

Inspired by #89958

2 years agoFix false positive of `implicit_saturating_sub` with `else` clause
Paul Gey [Sun, 17 Oct 2021 13:56:59 +0000 (15:56 +0200)]
Fix false positive of `implicit_saturating_sub` with `else` clause

Fixes #7831

2 years agoSome "parenthesis" and "parentheses" fixes
r00ster91 [Sun, 17 Oct 2021 10:04:01 +0000 (12:04 +0200)]
Some "parenthesis" and "parentheses" fixes

2 years agoAuto merge of #7827 - zvavybir:master, r=xFrednet
bors [Sat, 16 Oct 2021 19:07:37 +0000 (19:07 +0000)]
Auto merge of #7827 - zvavybir:master, r=xFrednet

Fixed naive doc formatting for `#[must_use]` lints

The documentation of a few lints around the `#[must_use]` attribute had a few times "[`#[must_use]`]" (without the parentheses, but with the `[]`) and once the "`" was missing.

changelog: Fixed naive doc formatting for `#[must_use]` lints ([`must_use_unit`], [`double_must_use`], [`must_use_candidate`], [`let_underscore_must_use`])

2 years agoFixed naive doc formatting for `#[must_use]` lints
Matthias Kaak [Sat, 16 Oct 2021 15:23:34 +0000 (15:23 +0000)]
Fixed naive doc formatting for `#[must_use]` lints

2 years agoAuto merge of #7743 - smoelius:master, r=camsteffen
bors [Fri, 15 Oct 2021 17:05:13 +0000 (17:05 +0000)]
Auto merge of #7743 - smoelius:master, r=camsteffen

Add `format_in_format_args` and `to_string_in_format_args` lints

Fixes #7667 and #7729

I put these in `perf` since that was one of `@jplatte's` suggestions, and `redundant_clone` (which I consider to be similar) lives there as well.

However, I am open to changing the category or anything else.

r? `@camsteffen`

changelog: Add `format_in_format_args` and `to_string_in_format_args` lints

2 years agoRemove redundant `to_string`s
Samuel E. Moelius III [Thu, 30 Sep 2021 11:38:03 +0000 (07:38 -0400)]
Remove redundant `to_string`s

2 years agoFix adjacent tests
Samuel E. Moelius III [Thu, 30 Sep 2021 11:40:46 +0000 (07:40 -0400)]
Fix adjacent tests

2 years agoAdd `format_in_format_args` and `to_string_in_format_args` lints
Samuel E. Moelius III [Thu, 30 Sep 2021 11:45:03 +0000 (07:45 -0400)]
Add `format_in_format_args` and `to_string_in_format_args` lints

Fixes #7667 and #7729

2 years agoAuto merge of #7823 - mikerite:match-overlapping-arm-20211015, r=xFrednet
bors [Fri, 15 Oct 2021 12:42:16 +0000 (12:42 +0000)]
Auto merge of #7823 - mikerite:match-overlapping-arm-20211015, r=xFrednet

Some small improvements to the `match_overlapping_arm` tests

changelog: none

2 years agoAuto merge of #7824 - dswij:unnecessary_sort_by, r=llogiq
bors [Fri, 15 Oct 2021 11:16:57 +0000 (11:16 +0000)]
Auto merge of #7824 - dswij:unnecessary_sort_by, r=llogiq

`unnecessary_sort_by` checks if argument implements `Ord` trait

closes #7822

changelog: [`unnecessary_sort_by`] now checks if argument implements `Ord` trait

2 years agoAdd test on `unnecessary_sort_by` when argument does not implement `Ord`
dswij [Fri, 15 Oct 2021 10:06:02 +0000 (18:06 +0800)]
Add test on `unnecessary_sort_by` when argument does not implement `Ord`

2 years ago`unnecessary_sort_by` only warns if argument impl `Ord` trait
dswij [Fri, 15 Oct 2021 10:00:02 +0000 (18:00 +0800)]
`unnecessary_sort_by` only warns if argument impl `Ord` trait

2 years agoFix clippy with changed macro statement spans
Cameron Steffen [Thu, 14 Oct 2021 18:28:30 +0000 (13:28 -0500)]
Fix clippy with changed macro statement spans

2 years agoAdd unbounded pats to `match_overlapping_arm` tests
Michael Wright [Fri, 15 Oct 2021 04:25:11 +0000 (06:25 +0200)]
Add unbounded pats to `match_overlapping_arm` tests

2 years agoRefactor overlapping arm tests
Michael Wright [Fri, 15 Oct 2021 04:20:28 +0000 (06:20 +0200)]
Refactor overlapping arm tests

Make the `println!`s match the patterns. Currently they are using the
deprecated syntax for inclusive ranges and extra spacing.

2 years agoAuto merge of #7815 - nhamovitz:patch-1, r=giraffate
bors [Wed, 13 Oct 2021 23:44:42 +0000 (23:44 +0000)]
Auto merge of #7815 - nhamovitz:patch-1, r=giraffate

Fix typo in example for `match_result_ok`

changelog: Fix typo in example for ``[`match_result_ok`]``

2 years agoAuto merge of #7805 - aDotInTheVoid:transmute-num-bits, r=camsteffen
bors [Wed, 13 Oct 2021 19:40:33 +0000 (19:40 +0000)]
Auto merge of #7805 - aDotInTheVoid:transmute-num-bits, r=camsteffen

Add lint transmute_num_to_bytes

Closes #7803

changelog: [`transmute_num_to_bytes`] new lint

2 years agoFix typo in example for `match_result_ok`
nhamovitz [Wed, 13 Oct 2021 19:12:46 +0000 (12:12 -0700)]
Fix typo in example for `match_result_ok`

2 years agoAdd lint transmute_num_to_bytes
Nixon Enraght-Moony [Mon, 11 Oct 2021 22:46:49 +0000 (23:46 +0100)]
Add lint transmute_num_to_bytes

Closes #7803

changelog: [`transmute_num_to_bytes`] new lint

2 years agoAuto merge of #7788 - flip1995:eq_if_let_sugg, r=giraffate
bors [Wed, 13 Oct 2021 12:04:57 +0000 (12:04 +0000)]
Auto merge of #7788 - flip1995:eq_if_let_sugg, r=giraffate

Do not expand macros in equatable_if_let suggestion

Fixes #7781

Let's use Hacktoberfest as a motivation to start contributing PRs myself again :)

changelog: [`equatable_if_let`]: No longer expands macros in the suggestion

2 years agoUpdate clippy ui output
Oli Scherer [Wed, 13 Oct 2021 11:06:14 +0000 (11:06 +0000)]
Update clippy ui output

2 years agoAuto merge of #7682 - Qwaz:uninit_vec, r=xFrednet
bors [Tue, 12 Oct 2021 21:04:13 +0000 (21:04 +0000)]
Auto merge of #7682 - Qwaz:uninit_vec, r=xFrednet

Implement uninit_vec lint

changelog: add the new lint [`uninit_vec`]

Fix #7681

2 years agoUpdate lint description for new() and default()
Yechan Bae [Tue, 12 Oct 2021 20:01:58 +0000 (16:01 -0400)]
Update lint description for new() and default()

2 years agoAuto merge of #7806 - Serial-ATA:lint-match-case-mismatch, r=llogiq
bors [Tue, 12 Oct 2021 18:39:09 +0000 (18:39 +0000)]
Auto merge of #7806 - Serial-ATA:lint-match-case-mismatch, r=llogiq

Add match_str_case_mismatch lint

changelog: Added a new lint [`match_str_case_mismatch`]

Fixes #7440

2 years agoAuto merge of #7808 - Veykril:patch-1, r=xFrednet
bors [Tue, 12 Oct 2021 11:42:23 +0000 (11:42 +0000)]
Auto merge of #7808 - Veykril:patch-1, r=xFrednet

Bring [`manual_split_once`] docs in line with other lint docs

changelog: none

2 years agoAdd a suggestion
Serial [Tue, 12 Oct 2021 11:13:19 +0000 (07:13 -0400)]
Add a suggestion

2 years agoAuto merge of #89770 - jkugelman:must-use-from-and-into, r=joshtriplett
bors [Tue, 12 Oct 2021 09:43:37 +0000 (09:43 +0000)]
Auto merge of #89770 - jkugelman:must-use-from-and-into, r=joshtriplett

Add #[must_use] to From::from and Into::into

Risk of churn: **High**
Magic 8-Ball says: **Outlook not so good**

I figured I'd put this out there. If we don't do it now maybe we save it for a rainy day.

Parent issue: #89692

r? `@joshtriplett`

2 years agoBring `manual_split_once` docs in line with other lint docs
Lukas Wirth [Tue, 12 Oct 2021 07:42:42 +0000 (09:42 +0200)]
Bring `manual_split_once` docs in line with other lint docs

2 years agoDon't run examples
Serial [Tue, 12 Oct 2021 00:40:13 +0000 (20:40 -0400)]
Don't run examples

2 years agoAdd match_str_case_mismatch lint
Serial [Tue, 12 Oct 2021 00:19:34 +0000 (20:19 -0400)]
Add match_str_case_mismatch lint

2 years agoAuto merge of #7791 - JamesHinshelwood:reason-in-disallowed-type, r=giraffate
bors [Tue, 12 Oct 2021 00:17:37 +0000 (00:17 +0000)]
Auto merge of #7791 - JamesHinshelwood:reason-in-disallowed-type, r=giraffate

Allow giving reasons for `disallowed_types`

Similar to #7609 but for the `disallowed_type` lint. The permitted form of configuration is the same as for `disallowed_methods`.

changelog: Allow giving reasons for [`disallowed_type`]

2 years agoAdd #[must_use] to From::from and Into::into
John Kugelman [Mon, 11 Oct 2021 14:13:50 +0000 (10:13 -0400)]
Add #[must_use] to From::from and Into::into

2 years agoAuto merge of #7793 - mikerite:new_lint-msrv-2, r=Manishearth
bors [Mon, 11 Oct 2021 17:41:00 +0000 (17:41 +0000)]
Auto merge of #7793 - mikerite:new_lint-msrv-2, r=Manishearth

Add option to `new_lint` to generate MSRV enabled lint

changelog: none

2 years agoDeprecate mem_discriminant_non_enum
flip1995 [Mon, 11 Oct 2021 08:10:16 +0000 (10:10 +0200)]
Deprecate mem_discriminant_non_enum

This lint has been uplifted and is now included in
enum_intrinsics_non_enums.

2 years agoRename `disallowed` to `conf_disallowed`
James Hinshelwood [Mon, 11 Oct 2021 07:28:32 +0000 (08:28 +0100)]
Rename `disallowed` to `conf_disallowed`

Co-authored-by: James Hinshelwood <james.hinshelwood@bigpayme.com>
2 years agoAdd reason config example for disallowed_type
James Hinshelwood [Mon, 11 Oct 2021 07:25:30 +0000 (08:25 +0100)]
Add reason config example for disallowed_type

Co-authored-by: James Hinshelwood <james.hinshelwood@bigpayme.com>
2 years agoAuto merge of #7795 - ThibsG:MutMut6922, r=giraffate
bors [Mon, 11 Oct 2021 01:14:53 +0000 (01:14 +0000)]
Auto merge of #7795 - ThibsG:MutMut6922, r=giraffate

Fix FP in external macros for `mut_mut` lint

Fix FP in `mut_mut` lint when type is defined in external macros.

fixes: #6922

changelog: [`mut_mut`] Fix FP when type is defined in external macros

2 years agoAuto merge of #7800 - 1nF0rmed:no-lint-in-match-single-amp, r=llogiq
bors [Sun, 10 Oct 2021 11:13:05 +0000 (11:13 +0000)]
Auto merge of #7800 - 1nF0rmed:no-lint-in-match-single-amp, r=llogiq

Refactor `clippy::match_ref_pats` to check for multiple reference patterns

fixes #7740

When there is only one pattern, to begin with, i.e. a single deref(`&`), then in such cases we suppress `clippy::match_ref_pats`.
This is done by checking the count of the reference pattern and emitting `clippy::match_ref_pats` when more than one pattern is present.

Removed certain errors in the `stderr` tests as they would not be triggered.

changelog: Refactor `clippy::match_ref_pats` to check for multiple reference patterns

2 years agoAdds additional tests for lint
1nF0rmed [Sun, 10 Oct 2021 09:16:28 +0000 (14:46 +0530)]
Adds additional tests for lint

2 years agoRefactor to check for multiple reference patterns
1nF0rmed [Sat, 9 Oct 2021 17:00:12 +0000 (22:30 +0530)]
Refactor to check for multiple reference patterns

2 years agoFix FP in external macros for `mut_mut` lint
ThibsG [Sat, 9 Oct 2021 13:54:16 +0000 (15:54 +0200)]
Fix FP in external macros for `mut_mut` lint

2 years agoAuto merge of #7794 - ThibsG:FieldReassignDefault6312, r=llogiq
bors [Sat, 9 Oct 2021 13:44:36 +0000 (13:44 +0000)]
Auto merge of #7794 - ThibsG:FieldReassignDefault6312, r=llogiq

Fix false positive when `Drop` and `Copy` involved in `field_reassign_with_default` lint

Fix FP in `field_reassign_with_default` lint when type implements `Drop` but not all fields are `Copy`.

fixes: #6312

changelog: [`field_reassign_with_default`] Fix FP when `Drop` and `Copy` are involved

2 years agoFix false positive when `Drop` and `Copy` involved
ThibsG [Sat, 9 Oct 2021 12:56:33 +0000 (14:56 +0200)]
Fix false positive when `Drop` and `Copy` involved

2 years agoAddress internal lints
Yechan Bae [Sat, 9 Oct 2021 09:59:53 +0000 (05:59 -0400)]
Address internal lints

2 years agoImproved error message for set_len() on empty Vec
Yechan Bae [Thu, 7 Oct 2021 15:53:08 +0000 (11:53 -0400)]
Improved error message for set_len() on empty Vec

2 years agoAdd testcases
Yechan Bae [Thu, 7 Oct 2021 15:18:01 +0000 (11:18 -0400)]
Add testcases

2 years agoAddress PR comments
Yechan Bae [Tue, 5 Oct 2021 15:43:44 +0000 (11:43 -0400)]
Address PR comments

2 years agoExtract get_vec_init_kind and share it
Yechan Bae [Sun, 3 Oct 2021 04:23:57 +0000 (00:23 -0400)]
Extract get_vec_init_kind and share it

2 years agoAdd #allow attribute to suppress FP #7698
Yechan Bae [Tue, 21 Sep 2021 13:56:56 +0000 (09:56 -0400)]
Add #allow attribute to suppress FP #7698

2 years agoImprove error messages
Yechan Bae [Mon, 20 Sep 2021 19:32:53 +0000 (15:32 -0400)]
Improve error messages

2 years agoHandle PR feedbacks first round
Yechan Bae [Fri, 17 Sep 2021 18:42:32 +0000 (14:42 -0400)]
Handle PR feedbacks first round

2 years agoFix clippy lints
Yechan Bae [Fri, 17 Sep 2021 07:27:31 +0000 (03:27 -0400)]
Fix clippy lints

2 years agoImplement uninit_vec lint
Yechan Bae [Fri, 17 Sep 2021 06:55:26 +0000 (02:55 -0400)]
Implement uninit_vec lint

2 years agoUse `indoc` for formatting
Michael Wright [Sat, 9 Oct 2021 03:58:05 +0000 (05:58 +0200)]
Use `indoc` for formatting

2 years agoFix `clippy::too-many-arguments` violation
Michael Wright [Sat, 9 Oct 2021 03:58:05 +0000 (05:58 +0200)]
Fix `clippy::too-many-arguments` violation

2 years agoAdd `--msrv` option to `new_lint` command
Michael Wright [Sat, 9 Oct 2021 03:58:05 +0000 (05:58 +0200)]
Add `--msrv` option to `new_lint` command

2 years agoAuto merge of #7789 - flip1995:double_semi_if_nothing_returned, r=camsteffen
bors [Fri, 8 Oct 2021 21:30:16 +0000 (21:30 +0000)]
Auto merge of #7789 - flip1995:double_semi_if_nothing_returned, r=camsteffen

Don't trigger semicolon_if_nothing_returned in expanded code

Fixes #7768

Before, this lint didn't trigger on macros. With rust-lang/rust#88175
this isn't enough anymore. In this PR a `WhileLoop` desugaring kind was
introduced. This overrides the span of expanded expressions when
lowering the while loop. So if a while loop is in a macro, the
expressions that it expands to are no longer marked with
`ExpnKind::Macro`, but with `ExpnKind::Desugaring`. In general, this is
the correct behavior and the same that is done for `ForLoop`s. It just
tripped up this lint.

r? `@camsteffen`

changelog: [`semicolon_if_nothing_returned`]: Fix regression on macros containing while loops

2 years agoAllow giving reasons for `disallowed_types`
James Hinshelwood [Fri, 8 Oct 2021 19:45:44 +0000 (20:45 +0100)]
Allow giving reasons for `disallowed_types`

Co-authored-by: James Hinshelwood <james.hinshelwood@bigpayme.com>
2 years agoDon't trigger semicolon_if_nothing_returned in expanded code
flip1995 [Fri, 8 Oct 2021 14:16:56 +0000 (16:16 +0200)]
Don't trigger semicolon_if_nothing_returned in expanded code

Before this lint didn't trigger on macros. With rust-lang/rust#88175
this isn't enough anymore. In this PR a `WhileLoop` desugaring kind was
introduced. This overrides the span of expanded expressions when
lowering the while loop. So if a while loop is in a macro, the
expressions that it expands to are no longer marked with
`ExpnKind::Macro`, but with `ExpnKind::Desugaring`. In general, this is
the correct behavior and the same that is done for `ForLoop`s. It just
tripped up this lint.

2 years agoDo not expand macros in equatable_if_let suggestion
flip1995 [Fri, 8 Oct 2021 13:26:10 +0000 (15:26 +0200)]
Do not expand macros in equatable_if_let suggestion

2 years agoAuto merge of #7748 - Serial-ATA:lint-undocumented-unsafe, r=flip1995
bors [Fri, 8 Oct 2021 07:29:26 +0000 (07:29 +0000)]
Auto merge of #7748 - Serial-ATA:lint-undocumented-unsafe, r=flip1995

Add undocumented_unsafe_blocks lint

changelog: Added a new lint [`undocumented_unsafe_blocks`]

Fixes #7464, #7238 (?)

2 years agoAdd undocumented_unsafe_blocks lint
Serial [Sat, 2 Oct 2021 03:25:48 +0000 (23:25 -0400)]
Add undocumented_unsafe_blocks lint

2 years agoAuto merge of #7705 - michaelsproul:fn_to_numeric_cast_any, r=camsteffen
bors [Thu, 7 Oct 2021 14:14:19 +0000 (14:14 +0000)]
Auto merge of #7705 - michaelsproul:fn_to_numeric_cast_any, r=camsteffen

Restriction lint for function pointer casts

The existing lints for function pointer casts cover the cases where a cast is non-portable or would result in truncation, however there's currently no way to forbid numeric function pointer casts entirely.

I've added a new lint `fn_to_numeric_cast_any`, which allows one to ban _all_ numeric function pointer casts, including to `usize`. This is useful if you're writing high-level Rust and want to opt-out of potentially surprising behaviour, avoiding silent bugs from forgotten parentheses, e.g.

```rust
fn foo() -> u32 {
    10
}

fn main() {
    let _ = foo as usize; // oops, forgot to call foo and got a random address instead!
}
```

~~I'm open to suggestions for the naming of the lint, because `fn_to_numeric_cast_any` is a bit clunky. Ideally I'd call this lint `fn_to_numeric_cast`, but that name is already taken for the more specific lint~~. We've stuck with `fn_to_numeric_cast_any` to avoid renaming the existing lint, or choosing a different name that's too generic (like `fn_cast`).

I'm also open to changing the suggestion behaviour, as adding parentheses is only one of many possible ways to fix the lint.

changelog: add ``[`fn_to_numeric_cast_any`]`` restriction lint