]> git.lizzy.rs Git - rust.git/log
rust.git
18 months agoAuto merge of #10010 - flip1995:rustup, r=flip1995
bors [Thu, 1 Dec 2022 13:21:51 +0000 (13:21 +0000)]
Auto merge of #10010 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

18 months agoBump nightly version -> 2022-12-01
Philipp Krones [Thu, 1 Dec 2022 11:55:29 +0000 (12:55 +0100)]
Bump nightly version -> 2022-12-01

18 months agoMerge remote-tracking branch 'upstream/master' into rustup
Philipp Krones [Thu, 1 Dec 2022 11:39:42 +0000 (12:39 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

18 months agoAuto merge of #10007 - Jarcho:issue_10005, r=giraffate
bors [Thu, 1 Dec 2022 07:20:06 +0000 (07:20 +0000)]
Auto merge of #10007 - Jarcho:issue_10005, r=giraffate

Fix ICE in `result_large_err` with uninhabited enums

fixes #10005
changelog: `result_large_err`: Fix ICE with uninhabited enums

18 months agoFix ICE in `result large_err` with uninhabited enums
Jason Newcomb [Thu, 1 Dec 2022 02:44:18 +0000 (21:44 -0500)]
Fix ICE in `result large_err` with uninhabited enums

18 months agoAuto merge of #9943 - dswij:pr-9940, r=Jarcho
bors [Wed, 30 Nov 2022 21:23:10 +0000 (21:23 +0000)]
Auto merge of #9943 - dswij:pr-9940, r=Jarcho

manual_let_else: keep macro call on suggestion blocks

Closes #9940

changelog: [`manual_let_else`]: Do not expand macro calls on suggestions

18 months agoAuto merge of #10001 - Jarcho:issue_9866, r=llogiq
bors [Wed, 30 Nov 2022 19:54:25 +0000 (19:54 +0000)]
Auto merge of #10001 - Jarcho:issue_9866, r=llogiq

Fix ICE in `unused_rounding`

fixes #9866
changelog: `unused_rounding`: Fix ICE when using the `_` separator

18 months agoAuto merge of #9996 - Jarcho:issue_9906, r=Alexendoo
bors [Wed, 30 Nov 2022 19:40:22 +0000 (19:40 +0000)]
Auto merge of #9996 - Jarcho:issue_9906, r=Alexendoo

Fix `unnecessary_cast` suggestion when taking a reference

fixes #9906
changelog: `unnecessary_cast`: Fix suggestion when taking a reference

18 months agoAuto merge of #9997 - Jarcho:issue_9901, r=llogiq
bors [Wed, 30 Nov 2022 19:29:40 +0000 (19:29 +0000)]
Auto merge of #9997 - Jarcho:issue_9901, r=llogiq

Don't lint `explicit_auto_deref` when the initial type is neither a reference, nor a receiver

fixes #9901
fixes #9777
changelog: `explicit_auto_deref`: Don't lint when the initial value is neither a reference, nor a receiver

18 months agoFix ICE in `unused_rounding`
Jason Newcomb [Wed, 30 Nov 2022 17:31:38 +0000 (12:31 -0500)]
Fix ICE in `unused_rounding`

18 months agoAuto merge of #9987 - Jarcho:issue_9957, r=flip1995
bors [Wed, 30 Nov 2022 16:31:56 +0000 (16:31 +0000)]
Auto merge of #9987 - Jarcho:issue_9957, r=flip1995

Don't cross contexts while building the suggestion for `redundant_closure_call`

fixes #9957

changelog: `redundant_closure_call`: Don't cross macro contexts while building the suggestion

18 months agoDon't lint `explicit_auto_deref` when the initial type is neither a reference, nor...
Jason Newcomb [Wed, 30 Nov 2022 16:15:49 +0000 (11:15 -0500)]
Don't lint `explicit_auto_deref` when the initial type is neither a reference, nor a receiver

18 months agoFix `unnecessary_cast` suggestion when taking a reference
Jason Newcomb [Wed, 30 Nov 2022 15:48:53 +0000 (10:48 -0500)]
Fix `unnecessary_cast` suggestion when taking a reference

18 months agoDon't cross contexts while building the suggestion for `redundant_closure_call`
Jason Newcomb [Tue, 29 Nov 2022 15:36:43 +0000 (10:36 -0500)]
Don't cross contexts while building the suggestion for `redundant_closure_call`

18 months agoAuto merge of #9989 - xFrednet:9986-move-safety-thingy, r=flip1995
bors [Wed, 30 Nov 2022 12:44:45 +0000 (12:44 +0000)]
Auto merge of #9989 - xFrednet:9986-move-safety-thingy, r=flip1995

Move `unnecessary_unsafety_doc` to `pedantic`

This lint was added in #9822. I like the idea, but also agree with #9986 as well. I think it should at least not be warn-by-default. This is one of these cases, where I'd like a group between pedantic and restriction. But I believe that users using `#![warn(clippy::pedantic)]` will know how to enable the lint if they disagree with it.

---

Since the lint is new:

changelog: none

r? `@flip1995` since I'd suggest back porting this, the original PR was merged 16 days ago.

Closes: #9986 (While it doesn't address everything, I believe that this is the best compromise)
19 months agoMove `unnecessary_unsafety_doc` to `pedantic`
xFrednet [Tue, 29 Nov 2022 17:22:02 +0000 (18:22 +0100)]
Move `unnecessary_unsafety_doc` to `pedantic`

19 months agoAuto merge of #104905 - compiler-errors:normalization-changes, r=spastorino
bors [Wed, 30 Nov 2022 11:13:09 +0000 (11:13 +0000)]
Auto merge of #104905 - compiler-errors:normalization-changes, r=spastorino

Some initial normalization method changes

1. Rename `AtExt::normalize` to `QueryNormalizeExt::query_normalize` (using the `QueryNormalizer`)
2. Introduce `NormalizeExt::normalize` to replace `partially_normalize_associated_types_in` (using the `AssocTypeNormalizer`)
3. Rename `FnCtxt::normalize_associated_types_in` to `FnCtxt::normalize`
4. Remove some unused other normalization fns in `Inherited` and `FnCtxt`

Also includes one drive-by where we're no longer creating a `FnCtxt` inside of `check_fn`, but passing it in. This means we don't need such weird `FnCtxt` construction logic.

Stacked on top of #104835 for convenience.

r? types

19 months agoUse `snippet_with_context` instead of `_with_macro_callsite`
dswij [Wed, 30 Nov 2022 06:50:13 +0000 (14:50 +0800)]
Use `snippet_with_context` instead of `_with_macro_callsite`

19 months agoAuto merge of #9985 - ehuss:triagebot-autolabel, r=xFrednet
bors [Tue, 29 Nov 2022 13:30:15 +0000 (13:30 +0000)]
Auto merge of #9985 - ehuss:triagebot-autolabel, r=xFrednet

Add S-waiting-on-review autolabel.

This adds the S-waiting-on-review autolabel feature for new PRs.  This was previously handled by highfive, but I neglected to include it in #9963.

changelog: none

19 months agoAdd S-waiting-on-review autolabel.
Eric Huss [Tue, 29 Nov 2022 13:18:43 +0000 (05:18 -0800)]
Add S-waiting-on-review autolabel.

19 months agoAuto merge of #9975 - xFrednet:0000-refutable-slice-pedantic, r=llogiq
bors [Tue, 29 Nov 2022 11:16:01 +0000 (11:16 +0000)]
Auto merge of #9975 - xFrednet:0000-refutable-slice-pedantic, r=llogiq

Move `index_refutable_slice` to `pedantic`

During the creation, I out this lint into the nursery group to let it run in the wild before moving it to a commonly used group. This move never happened until now, though. It should be safe, as Clippy and I have been using it for months and there are no open issues for is :)

---

changelog: Move `index_refutable_slice` to `pedantic` (Now warn-by-default)
[#9975](https://github.com/rust-lang/rust-clippy/pull/9975)

19 months agoAuto merge of #9981 - Jarcho:issue_9954, r=flip1995
bors [Tue, 29 Nov 2022 09:49:46 +0000 (09:49 +0000)]
Auto merge of #9981 - Jarcho:issue_9954, r=flip1995

Don't lint `unnecessary_operation` in mixed macro contexts

fixes #9954

changelog: `unnecessary_operation`: Don't lint in mixed macro contexts.

19 months agoAuto merge of #9980 - Jarcho:issue_9960, r=xFrednet
bors [Tue, 29 Nov 2022 09:10:14 +0000 (09:10 +0000)]
Auto merge of #9980 - Jarcho:issue_9960, r=xFrednet

Don't lint `unnecessary_cast` in mixed macro context

fixes #9960

Time to start making a dent in this onslaught.

changelog: `unnecessary_cast`: Don't lint when the identifiers context differs from its binding's context for locals

19 months agoDon't lint `unnecessary_cast` in mixed macro context
Jason Newcomb [Tue, 29 Nov 2022 04:30:56 +0000 (23:30 -0500)]
Don't lint `unnecessary_cast` in mixed macro context

19 months agoDon't lint `unnecessary_operation` in mixed macro contexts
Jason Newcomb [Tue, 29 Nov 2022 04:56:02 +0000 (23:56 -0500)]
Don't lint `unnecessary_operation` in mixed macro contexts

19 months agoMove `index_refutable_slice` to `pedantic`
xFrednet [Mon, 28 Nov 2022 19:23:09 +0000 (20:23 +0100)]
Move `index_refutable_slice` to `pedantic`

19 months agoFnCtxt normalization stuff
Michael Goulet [Fri, 25 Nov 2022 17:28:50 +0000 (17:28 +0000)]
FnCtxt normalization stuff

19 months agopartially_normalize_... -> At::normalize
Michael Goulet [Fri, 25 Nov 2022 17:11:15 +0000 (17:11 +0000)]
partially_normalize_... -> At::normalize

19 months agoAuto merge of #9865 - nyurik:allow-mixed, r=xFrednet
bors [Mon, 28 Nov 2022 17:22:36 +0000 (17:22 +0000)]
Auto merge of #9865 - nyurik:allow-mixed, r=xFrednet

Add allow-mixed-uninlined-format-args config

Implement `allow-mixed-uninlined-format-args` config param to change the behavior of the `uninlined_format_args` lint. Now it is a part of `style` per [Zulip chat](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/.60uninlined_format_args.60.20category), and won't propose inlining in case of a mixed usage, e.g. `print!("{} {}", var, 1+2)`. If the user sets `allow-mixed-uninlined-format-args` config param to `false`, the lint would behave like it did before -- proposing to inline args even in the mixed case.

---

changelog: [`uninlined_format_args`]: Added a new config `allow-mixed-uninlined-format-args` to allow the lint, if only some arguments can be inlined
[#9865](https://github.com/rust-lang/rust-clippy/pull/9865)
changelog: Moved [`uninlined_format_args`] to `style` (Now warn-by-default)
[#9865](https://github.com/rust-lang/rust-clippy/pull/9865)

19 months agoRollup merge of #104804 - nnethercote:MetaItemLit, r=petrochenkov
Matthias Krüger [Mon, 28 Nov 2022 16:25:46 +0000 (17:25 +0100)]
Rollup merge of #104804 - nnethercote:MetaItemLit, r=petrochenkov

Rename `ast::Lit` as `ast::MetaItemLit`.

And some other literal cleanups.

r? `@petrochenkov`

19 months agofix clippy tests
Esteban Küber [Mon, 28 Nov 2022 08:41:31 +0000 (00:41 -0800)]
fix clippy tests

19 months agoRename `ast::Lit` as `ast::MetaItemLit`.
Nicholas Nethercote [Wed, 23 Nov 2022 04:39:42 +0000 (15:39 +1100)]
Rename `ast::Lit` as `ast::MetaItemLit`.

19 months agoAuto merge of #9967 - koka831:fix/9416, r=llogiq
bors [Sun, 27 Nov 2022 19:03:06 +0000 (19:03 +0000)]
Auto merge of #9967 - koka831:fix/9416, r=llogiq

Remove blank lines when needless_return returns no value

fix https://github.com/rust-lang/rust-clippy/issues/9416

changelog: [`needless_return`] improve result format

r? `@llogiq`

19 months agoAuto merge of #9963 - ehuss:highfive-triagebot, r=xFrednet
bors [Sun, 27 Nov 2022 16:20:05 +0000 (16:20 +0000)]
Auto merge of #9963 - ehuss:highfive-triagebot, r=xFrednet

Migrate from highfive to triagebot

This migrates this repository from using the highfive bot to using triagebot (aka rustbot).

This should not be merged without coordinating the removal of the highfive webhook and/or merging https://github.com/rust-lang/highfive/pull/435.

changelog: none

19 months agoaddressed review feedback
Yuri Astrakhan [Sun, 27 Nov 2022 15:34:13 +0000 (10:34 -0500)]
addressed review feedback

19 months agoMigrate from highfive to triagebot
Eric Huss [Mon, 24 Oct 2022 23:33:53 +0000 (16:33 -0700)]
Migrate from highfive to triagebot

19 months agoAdd allow-mixed-uninlined-format-args config
Yuri Astrakhan [Sun, 27 Nov 2022 15:12:51 +0000 (10:12 -0500)]
Add allow-mixed-uninlined-format-args config

Implement `allow-mixed-uninlined-format-args` config param to change the behavior of the `uninlined_format_args` lint. Now it is a part of `style`, and won't propose inlining in case of a mixed usage, e.g. `print!("{} {}", var, 1+2)`. If the user sets allow-mixed-uninlined-format-args config param to `false`, then it would behave like before, proposing to inline args even in the mixed case.

19 months agoAuto merge of #9919 - Alexendoo:configuration-link, r=xFrednet
bors [Sun, 27 Nov 2022 14:42:54 +0000 (14:42 +0000)]
Auto merge of #9919 - Alexendoo:configuration-link, r=xFrednet

Link to a list of configurable lints in documentation

changelog: none

19 months agoAuto merge of #104048 - cjgillot:split-lifetime, r=compiler-errors
bors [Sun, 27 Nov 2022 14:30:19 +0000 (14:30 +0000)]
Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errors

Separate lifetime ident from lifetime resolution in HIR

Drive-by: change how suggested generic args are computed.
Fixes https://github.com/rust-lang/rust/issues/103815

I recommend reviewing commit-by-commit.

19 months agoRefactor BytePos handling
koka [Sun, 27 Nov 2022 13:41:06 +0000 (22:41 +0900)]
Refactor BytePos handling

19 months agoRemove blank lines when needless_return returns no value
koka [Sun, 27 Nov 2022 13:01:21 +0000 (22:01 +0900)]
Remove blank lines when needless_return returns no value

fix https://github.com/rust-lang/rust-clippy/issues/9416

19 months agoAuto merge of #9860 - Alexendoo:msrv-outer-attr, r=Jarcho
bors [Sun, 27 Nov 2022 12:58:54 +0000 (12:58 +0000)]
Auto merge of #9860 - Alexendoo:msrv-outer-attr, r=Jarcho

Allow using `clippy::msrv` as an outer attribute

changelog: Allow specifying `#[clippy::msrv]` as an outer attribute

Probably not too useful to clippy users, but it makes the MSRV tests slightly cleaner

19 months agoAllow using `clippy::msrv` as an outer attribute
Alex Macleod [Sat, 19 Nov 2022 12:50:02 +0000 (12:50 +0000)]
Allow using `clippy::msrv` as an outer attribute

19 months agoLink to a list of configurable lints in documentation
Alex Macleod [Sun, 20 Nov 2022 13:27:55 +0000 (13:27 +0000)]
Link to a list of configurable lints in documentation

19 months agoAuto merge of #9950 - xFrednet:0000-improve-exit-docs, r=llogiq
bors [Sun, 27 Nov 2022 08:47:20 +0000 (08:47 +0000)]
Auto merge of #9950 - xFrednet:0000-improve-exit-docs, r=llogiq

Improve `EXIT` lint docs

Super simple change, hopefully fast and fun to review. Have a great start to the weekend!

changelog: none

19 months agoImprove `EXIT` lint docs
xFrednet [Fri, 25 Nov 2022 20:50:38 +0000 (21:50 +0100)]
Improve `EXIT` lint docs

19 months agoAuto merge of #9945 - kraktus:uninlined_multiple_lines, r=llogiq
bors [Fri, 25 Nov 2022 18:36:50 +0000 (18:36 +0000)]
Auto merge of #9945 - kraktus:uninlined_multiple_lines, r=llogiq

Re-enable `uninlined_format_args` on multiline `format!`

fix https://github.com/rust-lang/rust-clippy/issues/9719

There was an issue with the code suggestion which can be sometimes completely broken (fortunately when applied it's valid), so we do not show it.

changelog: [`uninlined_format_args`] re-enable for multiline format expression, but do not show the literal code suggestion in those cases

19 months agoAuto merge of #9944 - flip1995:move-syntax-tree-patterns, r=Manishearth
bors [Fri, 25 Nov 2022 15:59:47 +0000 (15:59 +0000)]
Auto merge of #9944 - flip1995:move-syntax-tree-patterns, r=Manishearth

Move syntax tree patterns RFC to the book

r? `@Manishearth`

Follow up to #3875

changelog: none

19 months agoAuto merge of #104846 - spastorino:santa-clauses-make-goals-early-christmas-🎄, r...
bors [Fri, 25 Nov 2022 15:59:31 +0000 (15:59 +0000)]
Auto merge of #104846 - spastorino:santa-clauses-make-goals-early-christmas-🎄, r=oli-obk

Branch Clause from Predicate

r? `@oli-obk`

This is part of what's proposed in https://github.com/rust-lang/compiler-team/issues/531

19 months agodogfood with expanded `uninlined_format_args`
kraktus [Fri, 25 Nov 2022 15:41:08 +0000 (16:41 +0100)]
dogfood with expanded `uninlined_format_args`

19 months agoRe-enable `uninlined_format_args` on multiline `format!`
kraktus [Fri, 25 Nov 2022 15:36:22 +0000 (16:36 +0100)]
Re-enable `uninlined_format_args` on multiline `format!`

But do not display the code suggestion which can be sometimes completely broken (fortunately when applied it's valid)

19 months agoAuto merge of #9851 - Veykril:unnecessary-safety-comment, r=giraffate
bors [Fri, 25 Nov 2022 12:55:24 +0000 (12:55 +0000)]
Auto merge of #9851 - Veykril:unnecessary-safety-comment, r=giraffate

Lint unnecessary safety comments

changelog: [`unnecessary_safety_comment`]: Add unnecessary safety comment lint

Addresses https://github.com/rust-lang/rust-clippy/issues/7954

This does not necessarily catch all occurences, as doing so would require checking all expressions in the entire source which seems rather expensive. Instead what the lint does is it checks items, statements and the tail expression of blocks for safety comments, then checks if those comments are necessary or not, then linting for the unnecessary ones.

I kept the tests in one file to check that the lints do not clash with each other.

19 months agoBook: Format syntax tree pattern proposal
Philipp Krones [Fri, 25 Nov 2022 10:39:36 +0000 (11:39 +0100)]
Book: Format syntax tree pattern proposal

19 months agoMove syntax tree patterns RFC to the book
Philipp Krones [Fri, 25 Nov 2022 10:39:04 +0000 (11:39 +0100)]
Move syntax tree patterns RFC to the book

19 months ago`manual_let_else`: Add test with expanded macros
dswij [Fri, 25 Nov 2022 10:04:31 +0000 (18:04 +0800)]
`manual_let_else`: Add test with expanded macros

19 months ago`manual_let_else`: keep macro call on suggestion blocks
dswij [Fri, 25 Nov 2022 10:04:17 +0000 (18:04 +0800)]
`manual_let_else`: keep macro call on suggestion blocks

19 months agoRollup merge of #104873 - RalfJung:therefore, r=Dylan-DPC
Matthias Krüger [Fri, 25 Nov 2022 09:44:40 +0000 (10:44 +0100)]
Rollup merge of #104873 - RalfJung:therefore, r=Dylan-DPC

RefCell::get_mut: fix typo

and fix the same typo in a bunch of other places

19 months agoAddress reviews
Lukas Wirth [Thu, 24 Nov 2022 08:47:50 +0000 (09:47 +0100)]
Address reviews

19 months agoSimplify
Lukas Wirth [Thu, 17 Nov 2022 14:17:28 +0000 (15:17 +0100)]
Simplify

19 months agoLint unnecessary safety comments on statements and block tail expressions
Lukas Wirth [Thu, 17 Nov 2022 14:14:03 +0000 (15:14 +0100)]
Lint unnecessary safety comments on statements and block tail expressions

19 months agoAdd some more test cases for undocumented_unsafe_blocks
Lukas Wirth [Thu, 17 Nov 2022 10:00:51 +0000 (11:00 +0100)]
Add some more test cases for undocumented_unsafe_blocks

19 months agoLint unnecessary safety comments on items
Lukas Wirth [Mon, 14 Nov 2022 12:42:47 +0000 (13:42 +0100)]
Lint unnecessary safety comments on items

19 months agoRefCell::get_mut: fix typo
Ralf Jung [Fri, 25 Nov 2022 07:47:59 +0000 (08:47 +0100)]
RefCell::get_mut: fix typo

and fix the same typo in a bunch of other places

19 months agoIntroduce PredicateKind::Clause
Santiago Pastorino [Thu, 24 Nov 2022 21:14:58 +0000 (18:14 -0300)]
Introduce PredicateKind::Clause

19 months agoSimplify a bunch of trait ref obligation creations
Oli Scherer [Fri, 18 Nov 2022 21:29:26 +0000 (21:29 +0000)]
Simplify a bunch of trait ref obligation creations

19 months agoAuto merge of #9941 - Alexendoo:syntax-tree-rfc-remark, r=Manishearth
bors [Thu, 24 Nov 2022 23:46:59 +0000 (23:46 +0000)]
Auto merge of #9941 - Alexendoo:syntax-tree-rfc-remark, r=Manishearth

Fix remark for `rfcs/0001-syntax-tree-patterns.md`

https://github.com/rust-lang/rust-clippy/actions/runs/3542472739/jobs/5948006255#step:6:37

Removes the unused definitions, for the line length I disabled the lint for now as I gather it's going to be moved into the book in the future

r? `@Manishearth`

changelog: none

19 months agoFix remark for `rfcs/0001-syntax-tree-patterns.md`
Alex Macleod [Thu, 24 Nov 2022 21:33:25 +0000 (21:33 +0000)]
Fix remark for `rfcs/0001-syntax-tree-patterns.md`

19 months agoAuto merge of #103693 - HKalbasi:master, r=oli-obk
bors [Thu, 24 Nov 2022 20:29:13 +0000 (20:29 +0000)]
Auto merge of #103693 - HKalbasi:master, r=oli-obk

Make rustc_target usable outside of rustc

I'm working on showing type size in rust-analyzer (https://github.com/rust-lang/rust-analyzer/pull/13490) and I currently copied rustc code inside rust-analyzer, which works, but is bad. With this change, I would become able to use `rustc_target` and `rustc_index` directly in r-a, reducing the amount of copy needed.

This PR contains some feature flag to put nightly features behind them to make crates buildable on the stable compiler + makes layout related types generic over index type + removes interning of nested layouts.

19 months agoUse kw::Empty for elided lifetimes in path.
Camille GILLOT [Sun, 6 Nov 2022 11:40:31 +0000 (11:40 +0000)]
Use kw::Empty for elided lifetimes in path.

19 months agoAuto merge of #104321 - Swatinem:async-gen, r=oli-obk
bors [Thu, 24 Nov 2022 17:14:42 +0000 (17:14 +0000)]
Auto merge of #104321 - Swatinem:async-gen, r=oli-obk

Avoid `GenFuture` shim when compiling async constructs

Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`.

The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim.

The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through.

---

Given this demo code:

```rust
pub async fn a(arg: u32) -> Backtrace {
    let bt = b().await;
    let _arg = arg;
    bt
}

pub async fn b() -> Backtrace {
    Backtrace::force_capture()
}
```

I would get the following with the latest stable compiler (on Windows):

```
   4: async_codegen::b::async_fn$0
             at .\src\lib.rs:10
   5: core::future::from_generator::impl$1::poll<enum2$<async_codegen::b::async_fn_env$0> >
             at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91
   6: async_codegen::a::async_fn$0
             at .\src\lib.rs:4
   7: core::future::from_generator::impl$1::poll<enum2$<async_codegen::a::async_fn_env$0> >
             at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91
```

whereas now I get a much cleaner stack trace:

```
   3: async_codegen::b::async_fn$0
             at .\src\lib.rs:10
   4: async_codegen::a::async_fn$0
             at .\src\lib.rs:4
```

19 months agomove some layout logic to rustc_target::abi::layout
hkalbasi [Tue, 1 Nov 2022 16:20:30 +0000 (19:50 +0330)]
move some layout logic to rustc_target::abi::layout

19 months agoAvoid `GenFuture` shim when compiling async constructs
Arpad Borsos [Fri, 18 Nov 2022 21:56:22 +0000 (22:56 +0100)]
Avoid `GenFuture` shim when compiling async constructs

Previously, async constructs would be lowered to "normal" generators,
with an additional `from_generator` / `GenFuture` shim in between to
convert from `Generator` to `Future`.

The compiler will now special-case these generators internally so that
async constructs will *directly* implement `Future` without the need
to go through the `from_generator` / `GenFuture` shim.

The primary motivation for this change was hiding this implementation
detail in stack traces and debuginfo, but it can in theory also help
the optimizer as there is less abstractions to see through.

19 months agoRollup merge of #104742 - WaffleLapkin:forbidden-SUPER-deref, r=compiler-errors
Matthias Krüger [Thu, 24 Nov 2022 07:42:34 +0000 (08:42 +0100)]
Rollup merge of #104742 - WaffleLapkin:forbidden-SUPER-deref, r=compiler-errors

Make `deref_into_dyn_supertrait` lint the impl and not the usage

Proposed by ``@compiler-errors`` in https://github.com/rust-lang/rust/issues/89460#issuecomment-1320806785
r? ``@crlf0710``

19 months agoMerge pull request #3875 from fkohlgrueber/syntax-tree-patterns
Manish Goregaokar [Wed, 23 Nov 2022 22:24:17 +0000 (17:24 -0500)]
Merge pull request #3875 from fkohlgrueber/syntax-tree-patterns

RFC: syntax tree patterns

19 months agoFix clippy code
Esteban Küber [Thu, 3 Nov 2022 16:19:23 +0000 (09:19 -0700)]
Fix clippy code

19 months agoSeparate lifetime ident from resolution in HIR.
Camille GILLOT [Sat, 5 Nov 2022 22:41:07 +0000 (22:41 +0000)]
Separate lifetime ident from resolution in HIR.

19 months agoMove `get_associated_type` from `clippy` to `rustc_lint`
Maybe Waffle [Tue, 22 Nov 2022 19:52:46 +0000 (19:52 +0000)]
Move `get_associated_type` from `clippy` to `rustc_lint`

19 months agoRollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnr
Manish Goregaokar [Wed, 23 Nov 2022 03:54:38 +0000 (22:54 -0500)]
Rollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnr

Allow opaque types in trait impl headers and rely on coherence to reject unsound cases

r? ````@lcnr````

fixes #99840

19 months agoAuto merge of #9924 - Alexendoo:msrv-stack, r=Jarcho
bors [Tue, 22 Nov 2022 20:09:58 +0000 (20:09 +0000)]
Auto merge of #9924 - Alexendoo:msrv-stack, r=Jarcho

Add `clippy_utils::msrv::Msrv` to keep track of the current MSRV

changelog: Fix the scoping of the `#![clippy::msrv]` attribute

Fixes #6920

r? `@Jarcho`

19 months agoAuto merge of #9930 - smoelius:use-walk_generic_arg, r=Alexendoo
bors [Tue, 22 Nov 2022 19:07:05 +0000 (19:07 +0000)]
Auto merge of #9930 - smoelius:use-walk_generic_arg, r=Alexendoo

Use `walk_generic_arg`

This is a tiny followup to to #9743, now that https://github.com/rust-lang/rust/pull/103692 has landed.

r? `@Alexendoo`

changelog: none

19 months agoUse `walk_generic_arg`
Samuel Moelius [Tue, 22 Nov 2022 18:47:38 +0000 (13:47 -0500)]
Use `walk_generic_arg`

19 months agoAuto merge of #9750 - kraktus:lazy_eval, r=xFrednet
bors [Tue, 22 Nov 2022 17:21:23 +0000 (17:21 +0000)]
Auto merge of #9750 - kraktus:lazy_eval, r=xFrednet

Fix [`unnecessary_lazy_eval`] when type has significant drop

fix for https://github.com/rust-lang/rust-clippy/issues/9427#issuecomment-1295742590

However current implementation gives too many false positive, rending the lint almost useless.

I don't know what's the best way to check if a type has a "significant" drop (in the common meaning, not the internal rustc one, for example Option<(u8, u8)> should not be considered significant)

changelog: Fix [`unnecessary_lazy_eval`] when type has significant drop

19 months agoAuto merge of #104688 - flip1995:clippyup, r=Manishearth,flip1995
bors [Tue, 22 Nov 2022 17:09:06 +0000 (17:09 +0000)]
Auto merge of #104688 - flip1995:clippyup, r=Manishearth,flip1995

Update Clippy

r? `@Manishearth`

Sorry for taking so long. There were so many blockers and so little time. This situation should be mitigated with #104007 in the future.

19 months agoClippy: Workaround for let_chains issue
Philipp Krones [Tue, 22 Nov 2022 13:30:29 +0000 (14:30 +0100)]
Clippy: Workaround for let_chains issue

19 months agoAuto merge of #9796 - smoelius:issue-9771, r=flip1995
bors [Tue, 22 Nov 2022 12:50:08 +0000 (12:50 +0000)]
Auto merge of #9796 - smoelius:issue-9771, r=flip1995

Fix #9771 (`unnecessary_to_owned` false positive)

Fixes #9771

In that issue's example(s), the lint tried to add a `&` to a value, which implicitly changed the type of a field to a reference. The fix is to add the reference to `receiver_ty` (the type of the receiver of the `to_owned`-like method), before passing `receiver_ty` to `can_change_type`. `can_change_type` properly rejects the modified `receiver_ty`.

cc: `@mikerite` just because I think he was the author of `can_change_type`.

changelog: fix `unnecessary_to_owned` false positive which implicitly tried to change the type of a field to a reference

19 months agoAuto merge of #103578 - petrochenkov:nofict, r=nagisa
bors [Tue, 22 Nov 2022 10:17:09 +0000 (10:17 +0000)]
Auto merge of #103578 - petrochenkov:nofict, r=nagisa

Unreserve braced enum variants in value namespace

With this PR braced enum variants (`enum E { V { /*...*/ } }`) no longer take a slot in value namespace, so the special case mentioned in the note in https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md#braced-structs is removed.

Report - https://github.com/rust-lang/rust/pull/103578#issuecomment-1292594900.

19 months agoAuto merge of #9745 - matttpt:fix-redundant-closure-for-method-calls-suggestion,...
bors [Tue, 22 Nov 2022 09:20:50 +0000 (09:20 +0000)]
Auto merge of #9745 - matttpt:fix-redundant-closure-for-method-calls-suggestion, r=flip1995

Fix `redundant_closure_for_method_calls` suggestion

Fixes #7746. The issue turns out to be more general than raw pointers. The `redundant_closure_for_method_calls` lint produces incorrect suggestions when the method is associated with a type that must be enclosed in angle brackets or must be written with generic arguments substituted. For example:

```rust
fn main() {
    // Clippy's suggestion: [T; N]::as_slice
    // Correct suggestion:  <[u8; 3]>::as_slice
    let array_opt: Option<&[u8; 3]> = Some(&[4, 8, 7]);
    array_opt.map(|a| a.as_slice());

    // Clippy's suggestion: [T]::len
    // Correct suggestion:  <[u8]>::len
    let slice_opt: Option<&[u8]> = Some(b"slice");
    slice_opt.map(|s| s.len());

    // Clippy's suggestion: *const T::is_null
    // Correct suggestion:  <*const usize>::is_null
    let ptr_opt: Option<*const usize> = Some(&487);
    ptr_opt.map(|p| p.is_null());

    // Clippy's suggestion: dyn TestTrait::method_on_dyn
    // Correct suggestion:  <dyn TestTrait>::method_on_dyn
    let test_struct = TestStruct {};
    let dyn_opt: Option<&dyn TestTrait> = Some(&test_struct);
    dyn_opt.map(|d| d.method_on_dyn());
}

// For the trait object example:
trait TestTrait {}
struct TestStruct {}
impl TestTrait for TestStruct {}

impl dyn TestTrait + '_ {
    fn method_on_dyn(&self) -> bool {
        false
    }
}
```

The issue also affects references and tuples, though I had to patch the standard library with non-trait methods for those types to test that. Just in case, I also included handling for `!`, since it appeared to be possible to call methods on it with angle brackets. I just couldn't verify the resulting suggestion, since dead-code analysis eliminates the code first.

This is my first exposure to Rust compiler internals, so please let me know if I'm taking the wrong approach here!

changelog: [`redundant_closure_for_method_calls`]: add angle brackets and substitute generic arguments in suggestion when needed

19 months agoAuto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgr
bors [Tue, 22 Nov 2022 01:35:57 +0000 (01:35 +0000)]
Auto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgr

Rollup of 11 pull requests

Successful merges:

 - #103396 (Pin::new_unchecked: discuss pinning closure captures)
 - #104416 (Fix using `include_bytes` in pattern position)
 - #104557 (Add a test case for async dyn* traits)
 - #104559 (Split `MacArgs` in two.)
 - #104597 (Probe + better error messsage for `need_migrate_deref_output_trait_object`)
 - #104656 (Move tests)
 - #104657 (Do not check transmute if has non region infer)
 - #104663 (rustdoc: factor out common button CSS)
 - #104666 (Migrate alias search result to CSS variables)
 - #104674 (Make negative_impl and negative_impl_exists take the right types)
 - #104692 (Update test's cfg-if dependency to 1.0)

Failed merges:

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

19 months agoSplit `MacArgs` in two.
Nicholas Nethercote [Fri, 18 Nov 2022 00:24:21 +0000 (11:24 +1100)]
Split `MacArgs` in two.

`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's
used in two ways:
- For representing attribute macro arguments (e.g. in `AttrItem`), where all
  three variants are used.
- For representing function-like macros (e.g. in `MacCall` and `MacroDef`),
  where only the `Delimited` variant is used.

In other words, `MacArgs` is used in two quite different places due to them
having partial overlap. I find this makes the code hard to read. It also leads
to various unreachable code paths, and allows invalid values (such as
accidentally using `MacArgs::Empty` in a `MacCall`).

This commit splits `MacArgs` in two:
- `DelimArgs` is a new struct just for the "delimited arguments" case. It is
  now used in `MacCall` and `MacroDef`.
- `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro
  case. Its `Delimited` variant now contains a `DelimArgs`.

Various other related things are renamed as well.

These changes make the code clearer, avoids several unreachable paths, and
disallows the invalid values.

19 months agoUse `as_closure` helper method
Oli Scherer [Mon, 21 Nov 2022 15:52:01 +0000 (16:52 +0100)]
Use `as_closure` helper method

Co-authored-by: lcnr <rust@lcnr.de>
19 months agoStop passing the self-type as a separate argument.
Oli Scherer [Mon, 21 Nov 2022 12:24:53 +0000 (12:24 +0000)]
Stop passing the self-type as a separate argument.

19 months agoFix clippy's missing substs
Oli Scherer [Fri, 18 Nov 2022 19:58:07 +0000 (19:58 +0000)]
Fix clippy's missing substs

19 months agoAllow iterators instead of requiring slices that will get turned into iterators
Oli Scherer [Thu, 17 Nov 2022 13:00:35 +0000 (13:00 +0000)]
Allow iterators instead of requiring slices that will get turned into iterators

19 months agoClippy: Don't import GenericParamDefKind
Philipp Krones [Mon, 21 Nov 2022 20:04:59 +0000 (21:04 +0100)]
Clippy: Don't import GenericParamDefKind

19 months agoFix declare_clippy_lint crate
Philipp Krones [Mon, 21 Nov 2022 19:52:12 +0000 (20:52 +0100)]
Fix declare_clippy_lint crate

19 months agoMerge commit 'f4850f7292efa33759b4f7f9b7621268979e9914' into clippyup
Philipp Krones [Mon, 21 Nov 2022 19:34:47 +0000 (20:34 +0100)]
Merge commit 'f4850f7292efa33759b4f7f9b7621268979e9914' into clippyup

19 months agoAuto merge of #9770 - sgued:missnamed-getters, r=llogiq
bors [Mon, 21 Nov 2022 19:51:42 +0000 (19:51 +0000)]
Auto merge of #9770 - sgued:missnamed-getters, r=llogiq

Add new lint  [`misnamed-getters`]

```
changelog: Add new lint  [`misnamed-getters`]
```

Closes #9769

The current lint matches all methods with a body of just one expression under the form `(&mut?)? <expr>.field` where field doesn't match the name of the method but there is a field of the same type in `<expr>` that matches the name. This allows matching nested structs, for example for newtype wrappers. This may cast the net a bit too wide and cause false positives. I'll run [clippy_lint_tester](https://github.com/mikerite/clippy_lint_tester) on the top crates to see how frequently false positives happen.

There also may be room for improvement by checking that the replacement field would work taking into account implementations of `Deref` and `DerefMut` even if the types don't exactly match but I don't know yet how this could be done.

19 months agoUnreserve braced enum variants in value namespace
Vadim Petrochenkov [Tue, 25 Oct 2022 16:15:15 +0000 (20:15 +0400)]
Unreserve braced enum variants in value namespace

19 months agoAuto merge of #9881 - flip1995:rustup, r=flip1995
bors [Mon, 21 Nov 2022 19:16:14 +0000 (19:16 +0000)]
Auto merge of #9881 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

It took >4 weeks, but I finally got to do the sync 🎉

changelog: none

19 months agoFix custom ICE message test on windows
Philipp Krones [Mon, 21 Nov 2022 19:15:50 +0000 (20:15 +0100)]
Fix custom ICE message test on windows