]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #8580 - flip1995:rustup, r=flip1995
bors [Thu, 24 Mar 2022 13:29:13 +0000 (13:29 +0000)]
Auto merge of #8580 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

Nice small sync with only typo fixes

changelog: none

2 years agoBump nightly version -> 2022-03-24
flip1995 [Thu, 24 Mar 2022 13:22:43 +0000 (14:22 +0100)]
Bump nightly version -> 2022-03-24

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 24 Mar 2022 13:13:37 +0000 (14:13 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #8579 - yoav-lavi:squashed-master, r=flip1995
bors [Thu, 24 Mar 2022 12:57:08 +0000 (12:57 +0000)]
Auto merge of #8579 - yoav-lavi:squashed-master, r=flip1995

`unnecessary_join` lint

changelog: Adds a lint called ``[`unnecessary_join`]`` that detects cases of `.collect::<Vec<String>>.join("")` or `.collect::<Vec<_>>.join("")` on an iterator, suggesting `.collect::<String>()` instead

Fixes: https://github.com/rust-lang/rust-clippy/issues/8570
This is a reopen of https://github.com/rust-lang/rust-clippy/pull/8573

changelog: add lint [`unnecessary_join`]

2 years ago`unnecessary_join` lint
Yoav Lavi [Thu, 24 Mar 2022 12:18:18 +0000 (13:18 +0100)]
`unnecessary_join` lint

2 years agoAuto merge of #8232 - Jarcho:match_same_arm_860, r=xFrednet
bors [Mon, 21 Mar 2022 20:42:51 +0000 (20:42 +0000)]
Auto merge of #8232 - Jarcho:match_same_arm_860, r=xFrednet

`match_same_arms` fix

fixes #860
fixes #1140

changelog: Don't lint `match_same_arms` when an interposing arm's pattern would overlap

2 years agoAuto merge of #8561 - FoseFx:use_unwrap_or, r=xFrednet
bors [Mon, 21 Mar 2022 20:08:29 +0000 (20:08 +0000)]
Auto merge of #8561 - FoseFx:use_unwrap_or, r=xFrednet

add `or_then_unwrap`

Closes #8557

changelog: New lint [`or_then_unwrap`]

2 years agoAuto merge of #8520 - J-ZhengLi:issue8506, r=xFrednet
bors [Mon, 21 Mar 2022 19:51:56 +0000 (19:51 +0000)]
Auto merge of #8520 - J-ZhengLi:issue8506, r=xFrednet

fix suggestion on `[map_flatten]` being cropped causing possible information loss

fixes #8506

Multi-line suggestion given by the lint is missing its bottom part, which could potentially contains useful information about the fix.

---

changelog: [`map_flatten`]: Long suggestions will now be splitup into two help messages

2 years agoallowing [`map_flatten`] to split long suggestions
J-ZhengLi [Mon, 21 Mar 2022 06:11:22 +0000 (14:11 +0800)]
allowing [`map_flatten`] to split long suggestions
add new function `span_lint_and_sugg_` for edges in `clippy_utils::diagnostics`

2 years agorefactor: remove need for MethodCall matching
Max Baumann [Sun, 20 Mar 2022 23:04:37 +0000 (00:04 +0100)]
refactor: remove need for MethodCall matching

2 years agorefactor: use is_lang_ctor()
Max Baumann [Sun, 20 Mar 2022 22:54:04 +0000 (23:54 +0100)]
refactor: use is_lang_ctor()

2 years agofeat: change error message
Max Baumann [Sun, 20 Mar 2022 22:43:17 +0000 (23:43 +0100)]
feat: change error message

2 years agoAuto merge of #8559 - pickfire:patch-1, r=xFrednet
bors [Sun, 20 Mar 2022 22:32:12 +0000 (22:32 +0000)]
Auto merge of #8559 - pickfire:patch-1, r=xFrednet

Fix typo in bug report

repoduce -> reproduce

---

changelog: none

2 years agotest: add method chain test
Max Baumann [Sat, 19 Mar 2022 17:17:43 +0000 (18:17 +0100)]
test: add method chain test

2 years agofeat: make fixable
Max Baumann [Fri, 18 Mar 2022 22:18:36 +0000 (23:18 +0100)]
feat: make fixable

2 years agofeat: use span_lint_and_sugg
Max Baumann [Fri, 18 Mar 2022 21:44:56 +0000 (22:44 +0100)]
feat: use span_lint_and_sugg

2 years agorefactor: move into methods module
Max Baumann [Fri, 18 Mar 2022 20:11:54 +0000 (21:11 +0100)]
refactor: move into methods module

2 years agoAuto merge of #8562 - Jarcho:enum_tuple_variant_as_int, r=Manishearth
bors [Fri, 18 Mar 2022 15:54:45 +0000 (15:54 +0000)]
Auto merge of #8562 - Jarcho:enum_tuple_variant_as_int, r=Manishearth

Add lint `cast_enum_constructor`

fixes: #1116

changelog: Add lint `cast_enum_constructor`

2 years agofeat: add comment
Max Baumann [Fri, 18 Mar 2022 13:45:48 +0000 (14:45 +0100)]
feat: add comment

2 years agoAuto merge of #8543 - dswij:8393, r=giraffate
bors [Fri, 18 Mar 2022 00:42:18 +0000 (00:42 +0000)]
Auto merge of #8543 - dswij:8393, r=giraffate

`unnecessary_lazy_eval` show suggestions on multiline lint

Closes #8393

changelog: [`unnecessary_lazy_eval`] now shows suggestions for long-line lints

2 years agofix: ran update_lints
Max Baumann [Fri, 18 Mar 2022 00:12:39 +0000 (01:12 +0100)]
fix: ran update_lints

2 years agorefactor: rename lint to or_then_unwrap
Max Baumann [Fri, 18 Mar 2022 00:04:33 +0000 (01:04 +0100)]
refactor: rename lint to or_then_unwrap

2 years agoAdd lint `cast_enum_constructor`
Jason Newcomb [Thu, 17 Mar 2022 20:04:45 +0000 (16:04 -0400)]
Add lint `cast_enum_constructor`

2 years agofeat: add tests and fix existing ones
Max Baumann [Thu, 17 Mar 2022 23:51:26 +0000 (00:51 +0100)]
feat: add tests and fix existing ones

2 years agofeat: rename variable in example
Max Baumann [Thu, 17 Mar 2022 23:34:24 +0000 (00:34 +0100)]
feat: rename variable in example

2 years agorefactor: use pattern matching for MethodCall arguments
Max Baumann [Thu, 17 Mar 2022 23:23:55 +0000 (00:23 +0100)]
refactor: use pattern matching for MethodCall arguments

Co-authored-by: xFrednet <xFrednet@gmail.com>
2 years agoRollup merge of #94960 - codehorseman:master, r=oli-obk
Dylan DPC [Thu, 17 Mar 2022 21:55:05 +0000 (22:55 +0100)]
Rollup merge of #94960 - codehorseman:master, r=oli-obk

Fix many spelling mistakes

Signed-off-by: codehorseman <cricis@yeah.net>
2 years agoRollup merge of #94309 - eholk:issue-57017, r=tmandry
Dylan DPC [Thu, 17 Mar 2022 21:55:02 +0000 (22:55 +0100)]
Rollup merge of #94309 - eholk:issue-57017, r=tmandry

[generator_interior] Be more precise with scopes of borrowed places

Previously the generator interior type checking analysis would use the nearest temporary scope as the scope of a borrowed value. This ends up being overly broad for cases such as:

```rust
fn status(_client_status: &Client) -> i16 {
    200
}

fn main() {
    let client = Client;
    let g = move || match status(&client) {
        _status => yield,
    };
    assert_send(g);
}
```

In this case, the borrow `&client` could be considered in scope for the entirety of the `match` expression, meaning it would be viewed as live across the `yield`, therefore making the generator not `Send`.

In most cases, we want to use the enclosing expression as the scope for a borrowed value which will be less than or equal to the nearest temporary scope. This PR changes the analysis to use the enclosing expression as the scope for most borrows, with the exception of borrowed RValues which are true temporary values that should have the temporary scope. There's one further exception where borrows of a copy such as happens in autoref cases also should be ignored despite being RValues.

Joint work with `@nikomatsakis`

Fixes #57017

r? `@tmandry`

2 years agofix: fix clippy_lints
Max Baumann [Thu, 17 Mar 2022 18:52:07 +0000 (19:52 +0100)]
fix: fix clippy_lints

2 years agofix: fix broken dogfood tests
Max Baumann [Thu, 17 Mar 2022 18:29:59 +0000 (19:29 +0100)]
fix: fix broken dogfood tests

2 years agofix: fix tests
Max Baumann [Thu, 17 Mar 2022 18:13:44 +0000 (19:13 +0100)]
fix: fix tests

2 years agofeat: add use_unwrap_or
Max Baumann [Thu, 17 Mar 2022 17:57:28 +0000 (18:57 +0100)]
feat: add use_unwrap_or

2 years agoAuto merge of #8552 - Jarcho:ptr_arg_8495, r=xFrednet
bors [Thu, 17 Mar 2022 17:05:26 +0000 (17:05 +0000)]
Auto merge of #8552 - Jarcho:ptr_arg_8495, r=xFrednet

Don't lint `ptr_arg` on `&mut Cow<_>`

fixes: #8495

changelog: Don't lint `ptr_arg` on `&mut Cow<_>`

2 years agoFix typo in bug report
Ivan Tham [Thu, 17 Mar 2022 14:53:27 +0000 (22:53 +0800)]
Fix typo in bug report

repoduce -> reproduce

2 years agoAdd some comments
dswij [Thu, 17 Mar 2022 06:33:09 +0000 (14:33 +0800)]
Add some comments

2 years agoFix mixed enum variant kinds + code cleanup
Jason Newcomb [Thu, 17 Mar 2022 03:55:38 +0000 (23:55 -0400)]
Fix mixed enum variant kinds + code cleanup

2 years agoAuto merge of #8553 - Jarcho:transmute_undefined_8499, r=llogiq
bors [Wed, 16 Mar 2022 19:27:44 +0000 (19:27 +0000)]
Auto merge of #8553 - Jarcho:transmute_undefined_8499, r=llogiq

Don't lint `transmute_undefined_repr` when changing the type of generic params

Partially fixes #8499

changelog: Don't lint `transmute_undefined_repr` when changing the type of generic params

2 years agoImprove message for `match_single_arms`
Jason Newcomb [Sat, 22 Jan 2022 02:30:34 +0000 (21:30 -0500)]
Improve message for `match_single_arms`

2 years agoHandle slice patterns in `match_same_arms`
Jason Newcomb [Thu, 6 Jan 2022 19:54:57 +0000 (14:54 -0500)]
Handle slice patterns in `match_same_arms`

2 years agoUse `DroplessArena` when allocating `ResolvedPat`s
Jason Newcomb [Thu, 6 Jan 2022 18:37:37 +0000 (13:37 -0500)]
Use `DroplessArena` when allocating `ResolvedPat`s
Fix tuple handling in `match_same_arms`

2 years agoCheck if there are any overlapping patterns between equal arm bodies in `match_same_arm`
Jason Newcomb [Thu, 6 Jan 2022 07:54:35 +0000 (02:54 -0500)]
Check if there are any overlapping patterns between equal arm bodies in `match_same_arm`

2 years agoDon't lint `transmute_undefined_repr` when changing the type of generic params
Jason Newcomb [Wed, 16 Mar 2022 16:54:32 +0000 (12:54 -0400)]
Don't lint `transmute_undefined_repr` when changing the type of generic params

2 years agoDon't lint `ptr_arg` on `&mut Cow<_>`
Jason Newcomb [Wed, 16 Mar 2022 16:00:27 +0000 (12:00 -0400)]
Don't lint `ptr_arg` on `&mut Cow<_>`

2 years agoresolve the conflict in compiler/rustc_session/src/parse.rs
codehorseman [Wed, 16 Mar 2022 12:12:30 +0000 (20:12 +0800)]
resolve the conflict in compiler/rustc_session/src/parse.rs

Signed-off-by: codehorseman <cricis@yeah.net>
2 years agoAuto merge of #8544 - nellorocca:dev/5757, r=flip1995
bors [Wed, 16 Mar 2022 09:55:39 +0000 (09:55 +0000)]
Auto merge of #8544 - nellorocca:dev/5757, r=flip1995

Moved ``[try_err]`` to restriction

Fixes #5757

changelog: Moved try_err lint to rescrition for #5757

2 years agoAuto merge of #8547 - Jarcho:transmute_8501, r=flip1995
bors [Wed, 16 Mar 2022 09:39:22 +0000 (09:39 +0000)]
Auto merge of #8547 - Jarcho:transmute_8501, r=flip1995

More `transmute_undefined_repr` fixes

fixes: #8498
fixes: #8501
fixes: #8503

changelog: Allow `transumte_undefined_repr` between fat pointers and `(usize, usize)`
changelog: Allow `transumte_undefined_repr` when one side is a union
changelog: Fix `transumte_undefined_repr` on tuples with one non-zero-sized type.

2 years agoAuto merge of #8546 - KisaragiEffective:patch-1, r=llogiq
bors [Wed, 16 Mar 2022 06:20:45 +0000 (06:20 +0000)]
Auto merge of #8546 - KisaragiEffective:patch-1, r=llogiq

[`collapsible_if`] fix typo in code-block kind specifier

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: [`collapsible_if`] fix typo in code-block kind specifier

2 years agoFix checking transmutes with adjusted types
Jason Newcomb [Wed, 16 Mar 2022 02:47:18 +0000 (22:47 -0400)]
Fix checking transmutes with adjusted types

2 years agoDon't lint `transmute_undefined_repr` on unions.
Jason Newcomb [Wed, 16 Mar 2022 02:38:15 +0000 (22:38 -0400)]
Don't lint `transmute_undefined_repr` on unions.

2 years agoSmall simplification to `transmute_undefined_repr`
Jason Newcomb [Wed, 16 Mar 2022 02:33:26 +0000 (22:33 -0400)]
Small simplification to `transmute_undefined_repr`

2 years agoDon't lint fat pointer to `(usize, usize)` conversion in `transmute_undefined_repr`
Jason Newcomb [Wed, 16 Mar 2022 02:31:07 +0000 (22:31 -0400)]
Don't lint fat pointer to `(usize, usize)` conversion in `transmute_undefined_repr`

2 years agoFix `transmute_undefined_repr` for single element tuples
Jason Newcomb [Wed, 16 Mar 2022 01:51:07 +0000 (21:51 -0400)]
Fix `transmute_undefined_repr` for single element tuples

2 years agofix typo in code-block kind specifier
Kisaragi [Wed, 16 Mar 2022 01:19:19 +0000 (10:19 +0900)]
fix typo in code-block kind specifier

2 years agofix typo in code-block kind specifier
Kisaragi [Tue, 15 Mar 2022 23:50:30 +0000 (08:50 +0900)]
fix typo in code-block kind specifier

2 years agoLint list updated
Paolo Gentili [Tue, 15 Mar 2022 18:38:40 +0000 (19:38 +0100)]
Lint list updated

2 years agoMoved lint to `restriction`
Paolo Gentili [Tue, 15 Mar 2022 13:24:07 +0000 (14:24 +0100)]
Moved lint to `restriction`

2 years ago`unnecessary_lazy_eval` show suggestions on multiline lint
dswij [Tue, 15 Mar 2022 13:29:17 +0000 (21:29 +0800)]
`unnecessary_lazy_eval` show suggestions on multiline lint

2 years agoAuto merge of #8541 - flip1995:iter_with_drain_ambulance, r=giraffate
bors [Tue, 15 Mar 2022 09:02:38 +0000 (09:02 +0000)]
Auto merge of #8541 - flip1995:iter_with_drain_ambulance, r=giraffate

Move iter_with_drain to nursery

cc #8538 #8539

r? `@giraffate`

changelog: Move [`iter_with_drain`] to nursery

2 years agoMove iter_with_drain to nursery
flip1995 [Tue, 15 Mar 2022 08:46:49 +0000 (09:46 +0100)]
Move iter_with_drain to nursery

2 years agoAuto merge of #8509 - smoelius:fix-8507, r=giraffate
bors [Tue, 15 Mar 2022 01:08:47 +0000 (01:08 +0000)]
Auto merge of #8509 - smoelius:fix-8507, r=giraffate

Fix `unncessary_to_owned` false positive

Fix #8507

changelog: none

2 years agofix typos
Dylan DPC [Tue, 15 Mar 2022 01:00:08 +0000 (02:00 +0100)]
fix typos

2 years agoAuto merge of #8537 - xFrednet:7923-single-component-path-imports-for-macros, r=llogiq
bors [Mon, 14 Mar 2022 23:39:50 +0000 (23:39 +0000)]
Auto merge of #8537 - xFrednet:7923-single-component-path-imports-for-macros, r=llogiq

Allow `single_component_path_imports` for all macros

Closes: https://github.com/rust-lang/rust-clippy/issues/7923
It can be useful to have `use macro_name` regardless of the visibility. This removes the visibility filter.

changelog: [`single_component_path_imports`]: no longer triggers on macros

2 years agoAuto merge of #8536 - xFrednet:8062-applicability-search-is-some, r=camsteffen
bors [Mon, 14 Mar 2022 22:12:25 +0000 (22:12 +0000)]
Auto merge of #8536 - xFrednet:8062-applicability-search-is-some, r=camsteffen

Make `search_is_some`s suggestion `MachineApplicable`

My biggest PR to date, about 0.3 Lines have been changed!

Closes https://github.com/rust-lang/rust-clippy/issues/8062

The suggestion seems to work well, as we've received no error reports since the implementation in December. This PR therefore promotes the suggestion to `MachineApplicable`. The tests already include `.fixed` files :)

changelog: [`search_is_some`]: Make more suggestions `MachineApplicable`

2 years agoAllow `single_component_path_imports` for all macros
xFrednet [Mon, 14 Mar 2022 21:39:36 +0000 (22:39 +0100)]
Allow `single_component_path_imports` for all macros

2 years agoMake `search_is_some`s suggestion `MachineApplicable`
xFrednet [Mon, 14 Mar 2022 21:02:10 +0000 (22:02 +0100)]
Make `search_is_some`s suggestion `MachineApplicable`

2 years agoMerge commit 'dc5423ad448877e33cca28db2f1445c9c4473c75' into clippyup
flip1995 [Mon, 14 Mar 2022 11:02:53 +0000 (12:02 +0100)]
Merge commit 'dc5423ad448877e33cca28db2f1445c9c4473c75' into clippyup

2 years agoAuto merge of #8534 - flip1995:rustup, r=flip1995
bors [Mon, 14 Mar 2022 10:34:17 +0000 (10:34 +0000)]
Auto merge of #8534 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2022-03-14
flip1995 [Mon, 14 Mar 2022 10:29:39 +0000 (11:29 +0100)]
Bump nightly version -> 2022-03-14

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Mon, 14 Mar 2022 10:29:18 +0000 (11:29 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #8422 - buttercrab:only_used_in_recursion, r=llogiq
bors [Sun, 13 Mar 2022 16:11:25 +0000 (16:11 +0000)]
Auto merge of #8422 - buttercrab:only_used_in_recursion, r=llogiq

new lint: `only_used_in_recursion`

changed:
- added `only_used_in_recursion`.
- fixed code that variables are only used in recursion.
- this would not lint when `unused_variable`

This fixes: #8390

-----

changelog: add lint [`only_used_in_recursion`]

2 years agoadd clearing return vars
Jaeyong Sung [Sun, 13 Mar 2022 15:13:57 +0000 (00:13 +0900)]
add clearing return vars

2 years agoAuto merge of #8471 - J-ZhengLi:master-issue7040, r=llogiq
bors [Sun, 13 Mar 2022 14:49:56 +0000 (14:49 +0000)]
Auto merge of #8471 - J-ZhengLi:master-issue7040, r=llogiq

new lint that detects useless match expression

fixes #7040

changelog: Add new  lint [`needless_match`] under complexity lint group

2 years agoImprove `AdtDef` interning.
Nicholas Nethercote [Fri, 4 Mar 2022 20:28:41 +0000 (07:28 +1100)]
Improve `AdtDef` interning.

This commit makes `AdtDef` use `Interned`. Much the commit is tedious
changes to introduce getter functions. The interesting changes are in
`compiler/rustc_middle/src/ty/adt.rs`.

2 years agoRemove is_autoref parameter
Eric Holk [Fri, 11 Mar 2022 01:24:08 +0000 (17:24 -0800)]
Remove is_autoref parameter

2 years agoremove parameters that are only used in recursion
Jaeyong Sung [Thu, 10 Mar 2022 07:06:35 +0000 (16:06 +0900)]
remove parameters that are only used in recursion

2 years agofix build error
Jaeyong Sung [Thu, 10 Mar 2022 06:53:53 +0000 (15:53 +0900)]
fix build error

2 years agoadd checking for `x -> x` and `ref x -> x` and related test cases.
J-ZhengLi [Thu, 10 Mar 2022 06:46:58 +0000 (14:46 +0800)]
add checking for `x -> x` and `ref x -> x` and related test cases.

2 years agofix to lint Self::function
Jaeyong Sung [Thu, 10 Mar 2022 06:46:40 +0000 (15:46 +0900)]
fix to lint Self::function

2 years agoAuto merge of #8070 - CrazyRoka:update-gh-pages-checkbox-styles, r=camsteffen
bors [Thu, 10 Mar 2022 03:08:34 +0000 (03:08 +0000)]
Auto merge of #8070 - CrazyRoka:update-gh-pages-checkbox-styles, r=camsteffen

Improve styles of filtering options for Clippy's lint list

Partially solves #7958

Updated styles for filtering options. It now uses dropdown menus.

![image](https://user-images.githubusercontent.com/19844144/144608479-cdd9de0b-f101-4d49-a135-0969efb01a11.png)

changelog: none

2 years agorename lint to `needless_match`
J-ZhengLi [Thu, 10 Mar 2022 01:44:25 +0000 (09:44 +0800)]
rename lint to `needless_match`
and change its lint group to "complexity"

2 years agoadd `#[rustc_pass_by_value]` to more types
lcnr [Tue, 8 Mar 2022 14:39:52 +0000 (15:39 +0100)]
add `#[rustc_pass_by_value]` to more types

2 years agofix a bug that caused internal test fail
J-ZhengLi [Tue, 8 Mar 2022 10:15:11 +0000 (18:15 +0800)]
fix a bug that caused internal test fail

2 years agoadd nop if-let expression check.
J-ZhengLi [Tue, 8 Mar 2022 09:37:53 +0000 (17:37 +0800)]
add nop if-let expression check.
re-design test cases as some of them are not worth the effort to check.

2 years agoAuto merge of #94706 - matthiaskrgr:rollup-l5erynr, r=matthiaskrgr
bors [Mon, 7 Mar 2022 18:06:31 +0000 (18:06 +0000)]
Auto merge of #94706 - matthiaskrgr:rollup-l5erynr, r=matthiaskrgr

Rollup of 4 pull requests

Successful merges:

 - #93350 (libunwind: readd link attrs to _Unwind_Backtrace)
 - #93827 (Stabilize const_fn_fn_ptr_basics, const_fn_trait_bound, and const_impl_trait)
 - #94696 (Remove whitespaces and use CSS to align line numbers to the right instead)
 - #94700 (rustdoc: Update minifier version)

Failed merges:

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

2 years agoUpdate clippy to new ExprUseVisitor delegate
Eric Holk [Sat, 26 Feb 2022 01:13:53 +0000 (17:13 -0800)]
Update clippy to new ExprUseVisitor delegate

2 years agoUpdate and fix clippy tests
Eric Holk [Fri, 11 Feb 2022 03:23:43 +0000 (19:23 -0800)]
Update and fix clippy tests

2 years agoStabilize const_fn_fn_ptr_basics and const_fn_trait_bound
Eric Holk [Wed, 9 Feb 2022 00:33:15 +0000 (16:33 -0800)]
Stabilize const_fn_fn_ptr_basics and const_fn_trait_bound

2 years agoadd basic code to check nop match blocks
J-ZhengLi [Mon, 7 Mar 2022 10:12:35 +0000 (18:12 +0800)]
add basic code to check nop match blocks
modify `manual_map_option` uitest because one test case has confliction.

2 years agoadd test for trait recursion
Jaeyong Sung [Mon, 7 Mar 2022 03:15:00 +0000 (12:15 +0900)]
add test for trait recursion

2 years agoClarify `Layout` interning.
Nicholas Nethercote [Fri, 4 Mar 2022 02:46:56 +0000 (13:46 +1100)]
Clarify `Layout` interning.

`Layout` is another type that is sometimes interned, sometimes not, and
we always use references to refer to it so we can't take any advantage
of the uniqueness properties for hashing or equality checks.

This commit renames `Layout` as `LayoutS`, and then introduces a new
`Layout` that is a newtype around an `Interned<LayoutS>`. It also
interns more layouts than before. Previously layouts within layouts
(via the `variants` field) were never interned, but now they are. Hence
the lifetime on the new `Layout` type.

Unlike other interned types, these ones are in `rustc_target` instead of
`rustc_middle`. This reflects the existing structure of the code, which
does layout-specific stuff in `rustc_target` while `TyAndLayout` is
generic over the `Ty`, allowing the type-specific stuff to occur in
`rustc_middle`.

The commit also adds a `HashStable` impl for `Interned`, which was
needed. It hashes the contents, unlike the `Hash` impl which hashes the
pointer.

2 years agoIntroduce `ConstAllocation`.
Nicholas Nethercote [Tue, 1 Mar 2022 20:15:04 +0000 (07:15 +1100)]
Introduce `ConstAllocation`.

Currently some `Allocation`s are interned, some are not, and it's very
hard to tell at a use point which is which.

This commit introduces `ConstAllocation` for the known-interned ones,
which makes the division much clearer. `ConstAllocation::inner()` is
used to get the underlying `Allocation`.

In some places it's natural to use an `Allocation`, in some it's natural
to use a `ConstAllocation`, and in some places there's no clear choice.
I've tried to make things look as nice as possible, while generally
favouring `ConstAllocation`, which is the type that embodies more
information. This does require quite a few calls to `inner()`.

The commit also tweaks how `PartialOrd` works for `Interned`. The
previous code was too clever by half, building on `T: Ord` to make the
code shorter. That caused problems with deriving `PartialOrd` and `Ord`
for `ConstAllocation`, so I changed it to build on `T: PartialOrd`,
which is slightly more verbose but much more standard and avoided the
problems.

2 years agoRollup merge of #94617 - pierwill:update-itertools, r=Mark-Simulacrum
Matthias Krüger [Sun, 6 Mar 2022 14:41:26 +0000 (15:41 +0100)]
Rollup merge of #94617 - pierwill:update-itertools, r=Mark-Simulacrum

Update `itertools`

Update to 0.10.1

2 years agoAuto merge of #8445 - asquared31415:slice_ptr_cast, r=llogiq
bors [Sun, 6 Mar 2022 07:46:56 +0000 (07:46 +0000)]
Auto merge of #8445 - asquared31415:slice_ptr_cast, r=llogiq

Llint for casting between raw slice pointers with different element sizes

This lint disallows using `as` to convert from a raw pointer to a slice (e.g. `*const [i32]`, `*mut [Foo]`) to any other raw pointer to a slice if the element types have different sizes.  When a raw slice pointer is cast, the data pointer and count metadata are preserved.  This means that when the size of the inner slice's element type changes, the total number of bytes pointed to by the count changes.  For example a `*const [i32]` with length 4 (four `i32` elements) is cast `as *const [u8]` the resulting pointer points to four `u8` elements at the same address, losing most of the data.  When the size *increases* the resulting pointer will point to *more* data, and accessing that data will be UB.

On its own, *producing* the pointer isn't actually a problem, but because any use of the pointer as a slice will either produce surprising behavior or cause UB I believe this is a correctness lint.  If the pointer is not intended to be used as a slice, the user should instead use any of a number of methods to produce just a data pointer including an `as` cast to a thin pointer (e.g. `p as *const i32`) or if the pointer is being created from a slice, the `as_ptr` method on slices.  Detecting the intended use of the pointer is outside the scope of this lint, but I believe this lint will also lead users to realize that a slice pointer is only for slices.

There is an exception to this lint when either of the slice element types are zero sized (e.g `*mut [()]`).  The total number of bytes pointed to by the slice with a zero sized element is zero.  In that case preserving the length metadata is likely intended as a workaround to get the length metadata of a slice pointer though a zero sized slice.

The lint does not forbid casting pointers to slices with the *same* element size as the cast was likely intended to reinterpret the data in the slice as some equivalently sized data and the resulting pointer will behave as intended.

---

changelog: Added ``[`cast_slice_different_sizes`]``, a lint that disallows using `as`-casts to convert between raw pointers to slices when the elements have different sizes.

2 years agoFix #8507
Samuel E. Moelius III [Sun, 6 Mar 2022 02:18:44 +0000 (21:18 -0500)]
Fix #8507

2 years agoFormat with `rustfmt_if_chain`
Samuel E. Moelius III [Sat, 5 Mar 2022 23:35:58 +0000 (18:35 -0500)]
Format with `rustfmt_if_chain`

2 years agoChange syntax for TyAlias where clauses
Jack Huey [Tue, 19 Oct 2021 22:45:48 +0000 (18:45 -0400)]
Change syntax for TyAlias where clauses

2 years agofix lint errors
Jaeyong Sung [Sat, 5 Mar 2022 12:49:36 +0000 (21:49 +0900)]
fix lint errors

2 years agodon't lint when implementing trait
Jaeyong Sung [Sat, 5 Mar 2022 12:39:00 +0000 (21:39 +0900)]
don't lint when implementing trait

2 years agoDo not point at whole file missing `fn main`
Esteban Kuber [Fri, 21 Jan 2022 00:15:39 +0000 (00:15 +0000)]
Do not point at whole file missing `fn main`

Only point at the end of the crate. We could try making it point at the
beginning of the crate, but that is confused with `DUMMY_SP`, causing
the output to be *worse*.

This change will make it so that VSCode will *not* underline the whole
file when `main` is missing, so other errors will be visible.

2 years agoAuto merge of #8504 - xFrednet:8502-allow-lint-without-reason, r=flip1995
bors [Fri, 4 Mar 2022 19:23:39 +0000 (19:23 +0000)]
Auto merge of #8504 - xFrednet:8502-allow-lint-without-reason, r=flip1995

Add lint to detect `allow` attributes without reason

I was considering putting this lint into the pedantic group. However, that would result in countless warnings for existing projects. Having it in restriction also seems good to me :upside_down_face: (And now I need sleep :zzz: )

---

changelog: New lint [`allow_lint_without_reason`] (Requires the `lint_reasons` feature)

Closes: rust-lang/rust-clippy#8502