]> git.lizzy.rs Git - rust.git/log
rust.git
16 months agoAuto merge of #107267 - cjgillot:keep-aggregate, r=oli-obk
bors [Sat, 4 Feb 2023 15:17:32 +0000 (15:17 +0000)]
Auto merge of #107267 - cjgillot:keep-aggregate, r=oli-obk

Do not deaggregate MIR

This turns out to simplify a lot of things.
I haven't checked the consequences for miri yet.

cc `@JakobDegen`
r? `@oli-obk`

16 months agoAuto merge of #107618 - chriswailes:linker-arg, r=albertlarsan68
bors [Sat, 4 Feb 2023 11:22:31 +0000 (11:22 +0000)]
Auto merge of #107618 - chriswailes:linker-arg, r=albertlarsan68

Add a linker argument back to boostrap.py

In https://github.com/rust-lang/rust/pull/101783 I accidentally removed a load-bearing linker argument.  This PR adds it back in.

r? jyn514

16 months agoAuto merge of #107591 - krasimirgg:llvm-17-pgoopts, r=cuviper
bors [Sat, 4 Feb 2023 03:41:57 +0000 (03:41 +0000)]
Auto merge of #107591 - krasimirgg:llvm-17-pgoopts, r=cuviper

llvm-wrapper: adapt for LLVM API changes

Adapts the wrapper for https://github.com/llvm/llvm-project/commit/516e301752560311d2cd8c2b549493eb0f98d01b, where the constructor of PGOOptions gained a new FileSystem argument. Adapted to use the real file system, similarly to the changes inside of LLVM:
https://github.com/llvm/llvm-project/commit/516e301752560311d2cd8c2b549493eb0f98d01b#diff-f409934ba27ad86494f3012324e9a3995b56e0743609ded7a387ba62bbf5edb0R236

Found via our experimental Rust + LLVM at HEAD bot: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/16853#01860e2e-5eba-4f07-8359-0325913ff410/219-517

16 months agoAuto merge of #107650 - compiler-errors:rollup-4pntchf, r=compiler-errors
bors [Fri, 3 Feb 2023 22:37:53 +0000 (22:37 +0000)]
Auto merge of #107650 - compiler-errors:rollup-4pntchf, r=compiler-errors

Rollup of 8 pull requests

Successful merges:

 - #106887 (Make const/fn return params more suggestable)
 - #107519 (Add type alias for raw OS errors)
 - #107551 ( Replace `ConstFnMutClosure` with const closures )
 - #107595 (Retry opening proc-macro DLLs a few times on Windows.)
 - #107615 (Replace nbsp in all rustdoc code blocks)
 - #107621 (Intern external constraints in new solver)
 - #107631 (loudly tell people when they change `Cargo.lock`)
 - #107632 (Clarifying that .map() returns None if None.)

Failed merges:

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

16 months agoRollup merge of #107632 - ameknite:issue-107622-fix, r=jyn514
Michael Goulet [Fri, 3 Feb 2023 22:15:24 +0000 (14:15 -0800)]
Rollup merge of #107632 - ameknite:issue-107622-fix, r=jyn514

Clarifying that .map() returns None if None.

Fix #107622

16 months agoRollup merge of #107631 - BoxyUwU:triagebot_cargo_lock, r=compiler-errors
Michael Goulet [Fri, 3 Feb 2023 22:15:24 +0000 (14:15 -0800)]
Rollup merge of #107631 - BoxyUwU:triagebot_cargo_lock, r=compiler-errors

loudly tell people when they change `Cargo.lock`

It keeps happening that people accidentally commit changes to `Cargo.lock` and then have to be told by a reviewer to undo this. I've also seen cases where PRs are merged that accidentally changed `Cargo.lock` during a rebase.. I figure that purposeful changes to `Cargo.lock` are likely rarer than these accidental ones?

16 months agoRollup merge of #107621 - compiler-errors:intern-external-constraints, r=lcnr
Michael Goulet [Fri, 3 Feb 2023 22:15:23 +0000 (14:15 -0800)]
Rollup merge of #107621 - compiler-errors:intern-external-constraints, r=lcnr

Intern external constraints in new solver

Makes the query response `Copy`, fixing a few FIXMEs.

16 months agoRollup merge of #107615 - notriddle:notriddle/nbsp, r=GuillaumeGomez
Michael Goulet [Fri, 3 Feb 2023 22:15:23 +0000 (14:15 -0800)]
Rollup merge of #107615 - notriddle:notriddle/nbsp, r=GuillaumeGomez

Replace nbsp in all rustdoc code blocks

Based on #106125 by `@dtolnay` — this PR fixes the line wrapping bug.

Fixes #106098. This makes code copyable from rustdoc rendered documentation into a Rust source file.

16 months agoRollup merge of #107595 - michaelwoerister:retry_proc_macro_loading, r=petrochenkov
Michael Goulet [Fri, 3 Feb 2023 22:15:22 +0000 (14:15 -0800)]
Rollup merge of #107595 - michaelwoerister:retry_proc_macro_loading, r=petrochenkov

Retry opening proc-macro DLLs a few times on Windows.

On Windows, the compiler [sometimes](https://users.rust-lang.org/t/error-loadlibraryexw-failed/77603) fails with the message `error: LoadLibraryExW failed` when trying to load a proc-macro crate. The error seems to occur intermittently, similar to https://github.com/rust-lang/rust/issues/86929, however, it seems to be almost impossible to reproduce outside of CI environments and thus very hard to debug. The fact that the error only occurs intermittently makes me think that this is a timing related issue.

This PR is an attempt to mitigate the issue by letting the compiler retry a few times when encountering this specific error (which resolved the issue described in https://github.com/rust-lang/rust/issues/86929).

16 months agoRollup merge of #107551 - fee1-dead-contrib:rm_const_fnmut_helper, r=oli-obk
Michael Goulet [Fri, 3 Feb 2023 22:15:22 +0000 (14:15 -0800)]
Rollup merge of #107551 - fee1-dead-contrib:rm_const_fnmut_helper, r=oli-obk

 Replace `ConstFnMutClosure` with const closures

Also fixes a parser bug. cc `@oli-obk` for compiler changes

16 months agoRollup merge of #107519 - joboet:raw_os_error_ty, r=Amanieu
Michael Goulet [Fri, 3 Feb 2023 22:15:21 +0000 (14:15 -0800)]
Rollup merge of #107519 - joboet:raw_os_error_ty, r=Amanieu

Add type alias for raw OS errors

Implement rust-lang/libs-team#173.

`@rustbot` label +S-waiting-on-ACP +T-libs-api

16 months agoRollup merge of #106887 - compiler-errors:suggest-types-more, r=oli-obk
Michael Goulet [Fri, 3 Feb 2023 22:15:21 +0000 (14:15 -0800)]
Rollup merge of #106887 - compiler-errors:suggest-types-more, r=oli-obk

Make const/fn return params more suggestable

Bumps const item type suggestions to MachineApplicable (fixes #106843), also replaces FnDef with FnPtr items in return type suggestions to make more things suggestable.

r? diagnostics

16 months agoMake const/fn return params more suggestable
Michael Goulet [Sat, 14 Jan 2023 22:55:27 +0000 (22:55 +0000)]
Make const/fn return params more suggestable

16 months agointern external constraints
Michael Goulet [Fri, 3 Feb 2023 02:29:52 +0000 (02:29 +0000)]
intern external constraints

16 months agonit fixed
Ame [Fri, 3 Feb 2023 17:41:59 +0000 (11:41 -0600)]
nit fixed

16 months agoClarifying that .map() returns None if None.
Ame [Fri, 3 Feb 2023 10:54:27 +0000 (04:54 -0600)]
Clarifying that .map() returns None if None.

16 months agoAuto merge of #107642 - Dylan-DPC:rollup-edcqhm5, r=Dylan-DPC
bors [Fri, 3 Feb 2023 17:53:49 +0000 (17:53 +0000)]
Auto merge of #107642 - Dylan-DPC:rollup-edcqhm5, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #107082 (Autotrait bounds on dyn-safe trait methods)
 - #107427 (Add candidates for DiscriminantKind builtin)
 - #107539 (Emit warnings on unused parens in index expressions)
 - #107544 (Improve `TokenCursor`.)
 - #107585 (Don't cause a cycle when formatting query description that references a FnDef)
 - #107633 (Fix suggestion for coercing Option<&String> to Option<&str>)

Failed merges:

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

16 months agoRollup merge of #107633 - clubby789:option-string-coerce-fix, r=Nilstrieb
Dylan DPC [Fri, 3 Feb 2023 17:34:52 +0000 (23:04 +0530)]
Rollup merge of #107633 - clubby789:option-string-coerce-fix, r=Nilstrieb

Fix suggestion for coercing Option<&String> to Option<&str>

Fixes #107604

This also makes the diagnostic `MachineApplicable`, and runs `rustfix` to check we're not producing incorrect code.

``@rustbot`` label +A-diagnostics

16 months agoRollup merge of #107585 - compiler-errors:fndef-sig-cycle, r=oli-obk
Dylan DPC [Fri, 3 Feb 2023 17:34:52 +0000 (23:04 +0530)]
Rollup merge of #107585 - compiler-errors:fndef-sig-cycle, r=oli-obk

Don't cause a cycle when formatting query description that references a FnDef

When a function returns `-> _`, we use typeck to compute what the resulting type of the body _should_ be. If we call another query inside of typeck and hit a cycle error, we attempt to report the cycle error which requires us to compute all of the query descriptions for the stack.

However, if one of the queries in that cycle has a query description that references this function as a FnDef type, we'll cause a *second* cycle error from within the cycle error reporting code, since rendering a FnDef requires us to compute its signature. This causes an unwrap to ICE, since during the *second* cycle reporting code, we try to look for a job that isn't in the active jobs list.

We can avoid this by using `with_no_queries!` when computing these query descriptions.

Fixes #107089

The only drawback is that the rendering of opaque types in cycles regresses a bit :| I'm open to alternate suggestions about how we may handle this...

16 months agoRollup merge of #107544 - nnethercote:improve-TokenCursor, r=petrochenkov
Dylan DPC [Fri, 3 Feb 2023 17:34:51 +0000 (23:04 +0530)]
Rollup merge of #107544 - nnethercote:improve-TokenCursor, r=petrochenkov

Improve `TokenCursor`.

Some small improvements, for things that were bugging me.

Best reviewed one commit at a time.

r? ``@petrochenkov``

16 months agoRollup merge of #107539 - PossiblyAShrub:unused-parens-in-index, r=lcnr
Dylan DPC [Fri, 3 Feb 2023 17:34:51 +0000 (23:04 +0530)]
Rollup merge of #107539 - PossiblyAShrub:unused-parens-in-index, r=lcnr

Emit warnings on unused parens in index expressions

Fixes: #96606.
I am not sure what the best term for "index expression" is. Is there a better term we could use?

16 months agoRollup merge of #107427 - detrumi:builtin-impl-candidates, r=compiler-errors
Dylan DPC [Fri, 3 Feb 2023 17:34:50 +0000 (23:04 +0530)]
Rollup merge of #107427 - detrumi:builtin-impl-candidates, r=compiler-errors

Add candidates for DiscriminantKind builtin

Part of #107379

16 months agoRollup merge of #107082 - dtolnay:autotraits, r=lcnr
Dylan DPC [Fri, 3 Feb 2023 17:34:49 +0000 (23:04 +0530)]
Rollup merge of #107082 - dtolnay:autotraits, r=lcnr

Autotrait bounds on dyn-safe trait methods

This PR is a successor to #106604 implementing the approach encouraged by https://github.com/rust-lang/rust/pull/106604#issuecomment-1387353737.

**I propose making it legal to use autotraits as trait bounds on the `Self` type of trait methods in a trait object.** https://github.com/rust-lang/rust/issues/51443#issuecomment-1374847313 justifies why this use case is particularly important in the context of the async-trait crate.

```rust
#![feature(auto_traits)]
#![deny(where_clauses_object_safety)]

auto trait AutoTrait {}

trait MyTrait {
    fn f(&self) where Self: AutoTrait;
}

fn main() {
    let _: &dyn MyTrait;
}
```

Previously this would fail with:

```console
error: the trait `MyTrait` cannot be made into an object
 --> src/main.rs:7:8
  |
7 |     fn f(&self) where Self: AutoTrait;
  |        ^
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #51443 <https://github.com/rust-lang/rust/issues/51443>
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
 --> src/main.rs:7:8
  |
6 | trait MyTrait {
  |       ------- this trait cannot be made into an object...
7 |     fn f(&self) where Self: AutoTrait;
  |        ^ ...because method `f` references the `Self` type in its `where` clause
  = help: consider moving `f` to another trait
```

In order for this to be sound without hitting #50781, **I further propose that we disallow handwritten autotrait impls that apply to trait objects.** Both of the following were previously allowed (_on nightly_) and no longer allowed in my proposal:

```rust
auto trait AutoTrait {}

trait MyTrait {}
impl AutoTrait for dyn MyTrait {}  // NOT ALLOWED

impl<T: ?Sized> AutoTrait for T {}  // NOT ALLOWED
```

(`impl<T> AutoTrait for T {}` remains allowed.)

After this change, traits with a default impl are implemented for a trait object **if and only if** the autotrait is one of the trait object's trait bounds (or a supertrait of a bound). In other words `dyn Trait + AutoTrait` always implements AutoTrait while `dyn Trait` never implements AutoTrait.

Fixes https://github.com/dtolnay/async-trait/issues/228.

r? `@lcnr`

16 months agoAutotrait bounds on dyn-safe trait methods
David Tolnay [Thu, 19 Jan 2023 09:24:45 +0000 (01:24 -0800)]
Autotrait bounds on dyn-safe trait methods

16 months agoDisallow impl autotrait for trait object
David Tolnay [Thu, 19 Jan 2023 06:43:05 +0000 (22:43 -0800)]
Disallow impl autotrait for trait object

16 months agoReplace nbsp in all rustdoc code blocks
Michael Howell [Thu, 2 Feb 2023 22:10:41 +0000 (15:10 -0700)]
Replace nbsp in all rustdoc code blocks

Co-Authored-By: David Tolnay <dtolnay@gmail.com>
16 months agoReplace `ConstFnMutClosure` with const closures
Deadbeef [Wed, 1 Feb 2023 05:56:04 +0000 (05:56 +0000)]
Replace `ConstFnMutClosure` with const closures

16 months agoAuto merge of #107599 - clubby789:debug-less-ref, r=nnethercote
bors [Fri, 3 Feb 2023 14:22:42 +0000 (14:22 +0000)]
Auto merge of #107599 - clubby789:debug-less-ref, r=nnethercote

Don't generate unecessary `&&self.field` in deriving Debug

Since unsized fields may only be the last one in a struct, we only need to generate a double reference (`&&self.field`) for the  final one.

cc `@nnethercote`

16 months agoFix suggestion for coercing Option<&String> to Option<&str>
clubby789 [Fri, 3 Feb 2023 11:10:24 +0000 (11:10 +0000)]
Fix suggestion for coercing Option<&String> to Option<&str>

16 months agoAuto merge of #107569 - petrochenkov:optattr, r=nnethercote
bors [Fri, 3 Feb 2023 11:19:03 +0000 (11:19 +0000)]
Auto merge of #107569 - petrochenkov:optattr, r=nnethercote

ast: Optimize list and value extraction primitives for attributes

It's not necessary to convert the whole attribute into a meta item to extract something specific.

16 months agoloudly tell people when `Cargo.lock` changes
Boxy [Fri, 3 Feb 2023 10:42:37 +0000 (10:42 +0000)]
loudly tell people when `Cargo.lock` changes

16 months agoUse new helper inside probe
Wilco Kusee [Fri, 3 Feb 2023 09:04:15 +0000 (10:04 +0100)]
Use new helper inside probe

16 months agoAuto merge of #107625 - matthiaskrgr:rollup-xr9oldy, r=matthiaskrgr
bors [Fri, 3 Feb 2023 08:07:47 +0000 (08:07 +0000)]
Auto merge of #107625 - matthiaskrgr:rollup-xr9oldy, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #106575 (Suggest `move` in nested closure when appropriate)
 - #106805 (Suggest `{var:?}` when finding `{?:var}` in inline format strings)
 - #107500 (Add tests to assert current behavior of large future sizes)
 - #107598 (Fix benchmarks in library/core with black_box)
 - #107602 (Parse and recover from type ascription in patterns)
 - #107608 (Use triple rather than arch for fuchsia test-runner)

Failed merges:

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

16 months agoRollup merge of #107608 - P1n3appl3:master, r=tmandry
Matthias Krüger [Fri, 3 Feb 2023 05:30:25 +0000 (06:30 +0100)]
Rollup merge of #107608 - P1n3appl3:master, r=tmandry

Use triple rather than arch for fuchsia test-runner

This allows the user of the test-runner script to specify a full triple rather than just an architecture which helps with the transition from the two component to three component target triples for fuchsia.

16 months agoRollup merge of #107602 - estebank:anon-enum-access, r=compiler-errors
Matthias Krüger [Fri, 3 Feb 2023 05:30:24 +0000 (06:30 +0100)]
Rollup merge of #107602 - estebank:anon-enum-access, r=compiler-errors

Parse and recover from type ascription in patterns

Reintroduce part of #106960, which was reverted in #107478.

r? `@compiler-errors`

16 months agoRollup merge of #107598 - chenyukang:yukang/fix-core-bench, r=thomcc
Matthias Krüger [Fri, 3 Feb 2023 05:30:24 +0000 (06:30 +0100)]
Rollup merge of #107598 - chenyukang:yukang/fix-core-bench, r=thomcc

Fix benchmarks in library/core with black_box

Fixes #107590

16 months agoRollup merge of #107500 - bryangarza:future-sizes-baseline-test, r=compiler-errors
Matthias Krüger [Fri, 3 Feb 2023 05:30:23 +0000 (06:30 +0100)]
Rollup merge of #107500 - bryangarza:future-sizes-baseline-test, r=compiler-errors

Add tests to assert current behavior of large future sizes

Based on a couple of sources:
- https://swatinem.de/blog/future-size/
- https://github.com/rust-lang/rust/issues/62958

16 months agoRollup merge of #106805 - madsravn:master, r=compiler-errors
Matthias Krüger [Fri, 3 Feb 2023 05:30:23 +0000 (06:30 +0100)]
Rollup merge of #106805 - madsravn:master, r=compiler-errors

Suggest `{var:?}` when finding `{?:var}` in inline format strings

Link to issue: https://github.com/rust-lang/rust/issues/106572

This is my first PR to this project, so hopefully I can get some good pointers with me from the first PR.

Currently my idea was to test out whether or not this is the correct solution to this issue and then hopefully expand upon the idea to not only work for Debug formatting but for all of  them. If this is a valid solution, I will create a new issue to give a better error message to a broader range of wrong-order formatting.

16 months agoRollup merge of #106575 - estebank:issue-64008, r=pnkfelix
Matthias Krüger [Fri, 3 Feb 2023 05:30:22 +0000 (06:30 +0100)]
Rollup merge of #106575 - estebank:issue-64008, r=pnkfelix

Suggest `move` in nested closure when appropriate

Fix #64008.

16 months agoAuto merge of #107543 - ehuss:protocol-sparse, r=jyn514
bors [Fri, 3 Feb 2023 04:49:50 +0000 (04:49 +0000)]
Auto merge of #107543 - ehuss:protocol-sparse, r=jyn514

Enable Cargo's sparse protocol in CI

This enables the sparse protocol in CI in order to exercise and dogfood it. This is intended test the production server in a real-world situation.

Closes #107342

16 months agoAuto merge of #107241 - clubby789:bootstrap-lto-off, r=simulacrum
bors [Fri, 3 Feb 2023 01:19:04 +0000 (01:19 +0000)]
Auto merge of #107241 - clubby789:bootstrap-lto-off, r=simulacrum

Add `rust.lto=off` to bootstrap and set as compiler/library default

Closes #107202

The issue mentions `embed-bitcode=on`, but here https://github.com/rust-lang/rust/blob/c8e6a9e8b6251bbc8276cb78cabe1998deecbed7/src/bootstrap/compile.rs#L379-L381
it appears that this is always set for std stage 1+, so I'm unsure if changes are needed here.

`@rustbot` label +A-bootstrap

16 months agoAdd a linker argument back to boostrap.py
Chris Wailes [Fri, 3 Feb 2023 00:10:43 +0000 (16:10 -0800)]
Add a linker argument back to boostrap.py

In https://github.com/rust-lang/rust/pull/101783 I accidentally removed
a load-bearing linker argument.  This PR adds it back in.

16 months agoBless 32bit.
Camille GILLOT [Wed, 1 Feb 2023 19:08:53 +0000 (19:08 +0000)]
Bless 32bit.

16 months agoIntroduce write_aggregate.
Camille GILLOT [Wed, 1 Feb 2023 18:59:27 +0000 (18:59 +0000)]
Introduce write_aggregate.

16 months agoAdd partial propagation test.
Camille GILLOT [Sun, 29 Jan 2023 12:50:27 +0000 (12:50 +0000)]
Add partial propagation test.

16 months agoBless tests.
Camille GILLOT [Wed, 25 Jan 2023 18:34:35 +0000 (18:34 +0000)]
Bless tests.

16 months agoStop deaggegating MIR.
Camille GILLOT [Wed, 25 Jan 2023 18:34:19 +0000 (18:34 +0000)]
Stop deaggegating MIR.

16 months agoStop deaggregating enums in MIR.
Camille GILLOT [Wed, 25 Jan 2023 18:34:19 +0000 (18:34 +0000)]
Stop deaggregating enums in MIR.

16 months agoHandle aggregates in DataflowConstProp.
Camille GILLOT [Tue, 24 Jan 2023 17:43:07 +0000 (17:43 +0000)]
Handle aggregates in DataflowConstProp.

16 months agoCodegen SetDiscriminant after field assignment.
Camille GILLOT [Sun, 29 Jan 2023 13:00:32 +0000 (13:00 +0000)]
Codegen SetDiscriminant after field assignment.

This matches the order in which deaggregation was performed.

16 months agoInterpret aggregates.
Camille GILLOT [Mon, 23 Jan 2023 22:15:55 +0000 (22:15 +0000)]
Interpret aggregates.

16 months agoPut a DefId in AggregateKind.
Camille GILLOT [Mon, 23 Jan 2023 22:15:33 +0000 (22:15 +0000)]
Put a DefId in AggregateKind.

16 months agoRename `Cursor`/`CursorRef` as `TokenTreeCursor`/`RefTokenTreeCursor`.
Nicholas Nethercote [Wed, 1 Feb 2023 01:58:04 +0000 (12:58 +1100)]
Rename `Cursor`/`CursorRef` as `TokenTreeCursor`/`RefTokenTreeCursor`.

This makes it clear they return token trees, and makes for a nice
comparison against `TokenCursor` which returns tokens.

16 months agoRemove `TokenCursorFrame`.
Nicholas Nethercote [Wed, 1 Feb 2023 01:43:13 +0000 (12:43 +1100)]
Remove `TokenCursorFrame`.

The motivation here is to eliminate the `Option<(Delimiter,
DelimSpan)>`, which is `None` for the outermost token stream and `Some`
for all other token streams.

We are already treating the innermost frame specially -- this is the
`frame` vs `stack` distinction in `TokenCursor`. We can push that
further so that `frame` only contains the cursor, and `stack` elements
contain the delimiters for their children. When we are in the outermost
token stream `stack` is empty, so there are no stored delimiters, which
is what we want because the outermost token stream *has* no delimiters.

This change also shrinks `TokenCursor`, which shrinks `Parser` and
`LazyAttrTokenStreamImpl`, which is nice.

16 months agoMake clear that `TokenTree::Token` shouldn't contain a delimiter.
Nicholas Nethercote [Wed, 1 Feb 2023 00:21:28 +0000 (11:21 +1100)]
Make clear that `TokenTree::Token` shouldn't contain a delimiter.

16 months agoImprove doc comment desugaring.
Nicholas Nethercote [Tue, 31 Jan 2023 23:53:00 +0000 (10:53 +1100)]
Improve doc comment desugaring.

Sometimes the parser needs to desugar a doc comment into `#[doc =
r"foo"]`. Currently it does this in a hacky way: by pushing a "fake" new
frame (one without a delimiter) onto the `TokenCursor` stack.

This commit changes things so that the token stream itself is modified
in place. The nice thing about this is that it means
`TokenCursorFrame::delim_sp` is now only `None` for the outermost frame.

16 months agoTweak misleading comment
Michael Goulet [Thu, 2 Feb 2023 23:02:21 +0000 (15:02 -0800)]
Tweak misleading comment

16 months agoDon't generate unecessary `&&self.field` in deriving Debug
clubby789 [Thu, 2 Feb 2023 15:39:00 +0000 (15:39 +0000)]
Don't generate unecessary `&&self.field` in deriving Debug

16 months agoUse triple rather than arch for fuchsia test runner
Joseph Ryan [Thu, 2 Feb 2023 19:23:48 +0000 (11:23 -0800)]
Use triple rather than arch for fuchsia test runner

16 months agoAuto merge of #107000 - GuillaumeGomez:fix-items-in-doc-hidden-block, r=notriddle...
bors [Thu, 2 Feb 2023 21:14:44 +0000 (21:14 +0000)]
Auto merge of #107000 - GuillaumeGomez:fix-items-in-doc-hidden-block, r=notriddle,petrochenkov

Fix handling of items inside a `doc(hidden)` block

Fixes #106373.

cc `@aDotInTheVoid`
r? `@notriddle`

16 months agoEmit warnings on unused parens/braces in index expressions
Aidan Olsen [Tue, 31 Jan 2023 23:48:08 +0000 (16:48 -0700)]
Emit warnings on unused parens/braces in index expressions

16 months agoAuto merge of #107601 - matthiaskrgr:rollup-07zaafe, r=matthiaskrgr
bors [Thu, 2 Feb 2023 17:56:53 +0000 (17:56 +0000)]
Auto merge of #107601 - matthiaskrgr:rollup-07zaafe, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #106919 (Recover `_` as `..` in field pattern)
 - #107493 (Improve diagnostic for missing space in range pattern)
 - #107515 (Improve pretty-printing of `HirIdValidator` errors)
 - #107524 (Remove both StorageLive and StorageDead in CopyProp.)
 - #107532 (Erase regions before doing uninhabited check in borrowck)
 - #107559 (Rename `rust_2015` → `is_rust_2015`)
 - #107577 (Reinstate the `hir-stats.rs` tests on stage 1.)

Failed merges:

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

16 months agoParse and recover from type ascription in patterns
Esteban Küber [Thu, 2 Feb 2023 16:42:21 +0000 (16:42 +0000)]
Parse and recover from type ascription in patterns

16 months agofix #107590, Fix benchmarks in library/core with black_box
yukang [Thu, 2 Feb 2023 15:43:07 +0000 (23:43 +0800)]
fix #107590, Fix benchmarks in library/core with black_box

16 months agoSuggest `move` in nested closure when appropriate
Esteban Küber [Sat, 7 Jan 2023 22:17:00 +0000 (22:17 +0000)]
Suggest `move` in nested closure when appropriate

Fix #64008.

16 months agoRollup merge of #107577 - nnethercote:reinstate-hir-stats, r=jyn514
Matthias Krüger [Thu, 2 Feb 2023 16:14:08 +0000 (17:14 +0100)]
Rollup merge of #107577 - nnethercote:reinstate-hir-stats, r=jyn514

Reinstate the `hir-stats.rs` tests on stage 1.

r? ```@the8472```

16 months agoRollup merge of #107559 - WaffleLapkin:is_it_2015¿, r=davidtwco
Matthias Krüger [Thu, 2 Feb 2023 16:14:08 +0000 (17:14 +0100)]
Rollup merge of #107559 - WaffleLapkin:is_it_2015¿, r=davidtwco

Rename `rust_2015` → `is_rust_2015`

r? ```@compiler-errors```
https://github.com/rust-lang/rust/pull/107508#discussion_r1092300088

16 months agoRollup merge of #107532 - compiler-errors:erase-regions-in-uninhabited, r=jackh726
Matthias Krüger [Thu, 2 Feb 2023 16:14:07 +0000 (17:14 +0100)]
Rollup merge of #107532 - compiler-errors:erase-regions-in-uninhabited, r=jackh726

Erase regions before doing uninhabited check in borrowck

~Also, fingerprint query keys/values when debug assertions are enabled. This should make it easier to check for issues like this without `-Cincremental`, and make UI tests a bit cleaner.~ edit: moving that to a separate PR

Fixes #107505

16 months agoRollup merge of #107524 - cjgillot:both-storage, r=RalfJung
Matthias Krüger [Thu, 2 Feb 2023 16:14:06 +0000 (17:14 +0100)]
Rollup merge of #107524 - cjgillot:both-storage, r=RalfJung

Remove both StorageLive and StorageDead in CopyProp.

Fixes https://github.com/rust-lang/rust/issues/107511

https://github.com/rust-lang/rust/pull/106908 removed StorageDead without the accompanying StorageLive. In loops, execution would see repeated StorageLive, without any StorageDead, which is UB.

So when removing storage statements, we have to remove both StorageLive and StorageDead.

~I also added a MIR validation pass for StorageLive. It may be a bit overzealous.~

16 months agoRollup merge of #107515 - Swatinem:hirvalidator, r=compiler-errors
Matthias Krüger [Thu, 2 Feb 2023 16:14:06 +0000 (17:14 +0100)]
Rollup merge of #107515 - Swatinem:hirvalidator, r=compiler-errors

Improve pretty-printing of `HirIdValidator` errors

This now uses `node_to_string` for both missing and seen Ids, which includes the snippet of code for which the Id was allocated. Also removes the duplicated printing of `HirId`, as `node_to_string` also includes that.

16 months agoRollup merge of #107493 - clubby789:range-fat-arrow-followup, r=estebank
Matthias Krüger [Thu, 2 Feb 2023 16:14:05 +0000 (17:14 +0100)]
Rollup merge of #107493 - clubby789:range-fat-arrow-followup, r=estebank

Improve diagnostic for missing space in range pattern

Improves the diagnostic in #107425 by turning it into a note explaining the parsing issue.

r? `@compiler-errors`

16 months agoRollup merge of #106919 - compiler-errors:underscore-typo-in-field-pat, r=jackh726
Matthias Krüger [Thu, 2 Feb 2023 16:14:05 +0000 (17:14 +0100)]
Rollup merge of #106919 - compiler-errors:underscore-typo-in-field-pat, r=jackh726

Recover `_` as `..` in field pattern

16 months agoRetry opening proc-macro DLLs a few times on Windows.
Michael Woerister [Thu, 2 Feb 2023 13:26:28 +0000 (14:26 +0100)]
Retry opening proc-macro DLLs a few times on Windows.

16 months agoImprove diagnostic for missing space in range pattern
clubby789 [Mon, 30 Jan 2023 23:47:10 +0000 (23:47 +0000)]
Improve diagnostic for missing space in range pattern

16 months agoAuto merge of #107478 - compiler-errors:anon-enum-tys-are-ambiguous, r=estebank
bors [Thu, 2 Feb 2023 12:01:17 +0000 (12:01 +0000)]
Auto merge of #107478 - compiler-errors:anon-enum-tys-are-ambiguous, r=estebank

Revert "Teach parser to understand fake anonymous enum syntax" and related commits

anonymous enum types are currently ambiguous in positions like:

* `|` operator: `a as fn() -> B | C`
* closure args: `|_: as fn() -> A | B`

I first tried to thread around `RecoverAnonEnum` into all these positions, but the resulting complexity in the compiler is IMO not worth it, or at least worth a bit more thinking time. In the mean time, let's revert this syntax for now, so we can go back to the drawing board.

Fixes #107461

cc: `@estebank` `@cjgillot` #106960

---
### Squashed revert commits:

Revert "review comment: Remove AST AnonTy"

This reverts commit 020cca8d36cb678e3ddc2ead41364be314d19e93.

Revert "Ensure macros are not affected"

This reverts commit 12d18e403139eeeeb339e8611b2bed4910864edb.

Revert "Emit fewer errors on patterns with possible type ascription"

This reverts commit c847a01a3b1f620c4fdb98c75805033e768975d1.

Revert "Teach parser to understand fake anonymous enum syntax"

This reverts commit 2d824206655bfb26cb5eed43490ee396542b153e.

16 months agoPR fixing wrong order of format parameters in strings. Issue #106572
Mads Ravn [Sun, 8 Jan 2023 22:48:41 +0000 (23:48 +0100)]
PR fixing wrong order of format parameters in strings. Issue #106572

Adding

Adding

Fixing small issues for PR

Adding tests

Removing unused binding

Changing the wording on note

Fixing PR comment

16 months agollvm-wrapper: adapt for LLVM API changes
Krasimir Georgiev [Thu, 2 Feb 2023 10:09:48 +0000 (10:09 +0000)]
llvm-wrapper: adapt for LLVM API changes

Adapts the wrapper for https://github.com/llvm/llvm-project/commit/516e301752560311d2cd8c2b549493eb0f98d01b,
where the constructor of PGOOptions gained a new FileSystem argument.
Adapted to use the real file system, similarly to the changes inside of
LLVM:
https://github.com/llvm/llvm-project/commit/516e301752560311d2cd8c2b549493eb0f98d01b#diff-f409934ba27ad86494f3012324e9a3995b56e0743609ded7a387ba62bbf5edb0R236

16 months agoAuto merge of #107584 - matthiaskrgr:rollup-vav4ljz, r=matthiaskrgr
bors [Thu, 2 Feb 2023 09:05:18 +0000 (09:05 +0000)]
Auto merge of #107584 - matthiaskrgr:rollup-vav4ljz, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #107201 (Remove confusing 'while checking' note from opaque future type mismatches)
 - #107312 (Add Style Guide rules for let-else statements)
 - #107488 (Fix syntax in `-Zunpretty-expanded` output for derived `PartialEq`.)
 - #107531 (Inline CSS background images directly into the CSS)
 - #107576 (Add proc-macro boilerplate to crt-static test)

Failed merges:

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

16 months agoUse `rust_2018` instead of `!is_rust_2015`
Maybe Waffle [Wed, 1 Feb 2023 10:44:59 +0000 (10:44 +0000)]
Use `rust_2018` instead of `!is_rust_2015`

16 months agoRename `rust_2015` => `is_rust_2015`
Maybe Waffle [Wed, 1 Feb 2023 10:42:20 +0000 (10:42 +0000)]
Rename `rust_2015` => `is_rust_2015`

16 months agoRecover _ as .. in field pattern
Michael Goulet [Sun, 15 Jan 2023 21:31:04 +0000 (21:31 +0000)]
Recover _ as .. in field pattern

16 months agoAdd a test
Michael Goulet [Mon, 30 Jan 2023 18:39:33 +0000 (18:39 +0000)]
Add a test

16 months agoRevert "Teach parser to understand fake anonymous enum syntax" and related commits
Michael Goulet [Mon, 30 Jan 2023 18:08:50 +0000 (18:08 +0000)]
Revert "Teach parser to understand fake anonymous enum syntax" and related commits

Revert "review comment: Remove AST AnonTy"

This reverts commit 020cca8d36cb678e3ddc2ead41364be314d19e93.

Revert "Ensure macros are not affected"

This reverts commit 12d18e403139eeeeb339e8611b2bed4910864edb.

Revert "Emit fewer errors on patterns with possible type ascription"

This reverts commit c847a01a3b1f620c4fdb98c75805033e768975d1.

Revert "Teach parser to understand fake anonymous enum syntax"

This reverts commit 2d824206655bfb26cb5eed43490ee396542b153e.

16 months agoRollup merge of #107576 - P1n3appl3:master, r=tmandry
Matthias Krüger [Thu, 2 Feb 2023 05:52:15 +0000 (06:52 +0100)]
Rollup merge of #107576 - P1n3appl3:master, r=tmandry

Add proc-macro boilerplate to crt-static test

I was seeing this failure when running ui tests with with a `-Cpanic=abort` stdlib targeting fuchsia:

```
---- [ui] tests/ui/proc-macro/crt-static.rs stdout ----
normalized stderr:
warning: building proc macro crate with `panic=abort` may crash the compiler should the proc-macro panic

warning: 1 warning emitted

The actual stderr differed from the expected stderr.
```

`force-host` was enough to stop it from running/failing, not sure if I should also add `needs-unwind`?

16 months agoRollup merge of #107531 - GuillaumeGomez:inline-images-in-css, r=notriddle
Matthias Krüger [Thu, 2 Feb 2023 05:52:15 +0000 (06:52 +0100)]
Rollup merge of #107531 - GuillaumeGomez:inline-images-in-css, r=notriddle

Inline CSS background images directly into the CSS

A nice advantage of this is that it removes a few entries in the list of static files.

r? ``@notriddle``

16 months agoRollup merge of #107488 - nnethercote:fix-PartialEq-syntax, r=RalfJung
Matthias Krüger [Thu, 2 Feb 2023 05:52:14 +0000 (06:52 +0100)]
Rollup merge of #107488 - nnethercote:fix-PartialEq-syntax, r=RalfJung

Fix syntax in `-Zunpretty-expanded` output for derived `PartialEq`.

If you do `derive(PartialEq)` on a packed struct, the output shown by `-Zunpretty=expanded` includes expressions like this:
```
{ self.x } == { other.x }
```
This is invalid syntax. This doesn't break compilation, because the AST nodes are constructed within the compiler. But it does mean anyone using `-Zunpretty=expanded` output as a guide for hand-written impls could get a nasty surprise.

This commit fixes things by instead using this form:
```
({ self.x }) == ({ other.x })
```

r? ``@RalfJung``

16 months agoRollup merge of #107312 - calebcartwright:style-let-else, r=joshtriplett
Matthias Krüger [Thu, 2 Feb 2023 05:52:13 +0000 (06:52 +0100)]
Rollup merge of #107312 - calebcartwright:style-let-else, r=joshtriplett

Add Style Guide rules for let-else statements

cc `@rust-lang/style` `@rust-lang/rustfmt`

[rendered](https://github.com/calebcartwright/rust/blob/c694d07c6413ba55caa10b9f8b853df7a7792e7c/src/doc/style-guide/src/statements.md#else-blocks-let-else-statements)

16 months agoRollup merge of #107201 - compiler-errors:confusing-async-fn-note, r=estebank
Matthias Krüger [Thu, 2 Feb 2023 05:52:13 +0000 (06:52 +0100)]
Rollup merge of #107201 - compiler-errors:confusing-async-fn-note, r=estebank

Remove confusing 'while checking' note from opaque future type mismatches

Maybe I'm just misinterpreting the wording of the note. The only value I can see in this note is that it points out where the async's opaque future is coming from, but the way it's doing it is misleading IMO.

For example:

```rust
note: while checking the return type of the `async fn`
  --> $DIR/dont-suggest-missing-await.rs:7:24
   |
LL | async fn make_u32() -> u32 {
   |                        ^^^ checked the `Output` of this `async fn`, found opaque type
```

We point at the type `u32` in the HIR, but then say "found opaque type". We also say "while checking"... but we're typechecking a totally different function when we get this type mismatch!

r? ``@estebank`` but feel free to reassign and/or take your time reviewing this. I'd be inclined to also discuss reworking the presentation of this type mismatch to restore some of these labels in a way that makes it more clear what it's trying to point out.

16 months agoDon't cause a cycle when formatting query description that references a FnDef
Michael Goulet [Thu, 2 Feb 2023 05:49:07 +0000 (05:49 +0000)]
Don't cause a cycle when formatting query description that references a FnDef

16 months agoAuto merge of #106925 - imWildCat:imWildCat/remove-hardcoded-ios-macbi-target-version...
bors [Thu, 2 Feb 2023 05:26:09 +0000 (05:26 +0000)]
Auto merge of #106925 - imWildCat:imWildCat/remove-hardcoded-ios-macbi-target-version, r=wesleywiser

Remove hardcoded iOS version of clang target for Mac Catalyst

## Background

From `clang` 13.x, `-target x86_64-apple-ios13.0-macabi` fails while linking:

```
  = note: clang: error: invalid version number in '-target x86_64-apple-ios13.0-macabi'
```

<details>
<summary>Verbose output</summary>

```
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="[removed]" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-Wl,-exported_symbols_list,/var/folders/p8/qpmzbsdn07g5gxykwfxxw7y40000gn/T/rustci8tkvp/list" "-target" "x86_64-apple-ios13.0-macabi" "/var/folders/p8/qpmzbsdn07g5gxykwfxxw7y40000gn/T/rustci8tkvp/symbols.o" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps/[user].[user].a2ccc648-cgu.0.rcgu.o" "-L" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps" "-L" "/path/to/my/[project]/[user]/target/release/deps" "-L" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/build/blake3-74e6ba91506ce712/out" "-L" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/build/blake3-74e6ba91506ce712/out" "-L" "/Users/[user]/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/x86_64-apple-ios-macabi/lib" "/var/folders/p8/qpmzbsdn07g5gxykwfxxw7y40000gn/T/rustci8tkvp/libblake3-343c1616c8f62c66.rlib" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps/libcompiler_builtins-15d4f20b641cf9ef.rlib" "-framework" "Security" "-framework" "CoreFoundation" "-framework" "Security" "-liconv" "-lSystem" "-lobjc" "-framework" "Security" "-framework" "Foundation" "-lc" "-lm" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk" "-Wl,-syslibroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk" "-L" "/Users/[user]/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/x86_64-apple-ios-macabi/lib" "-o" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps/lib[user].dylib" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-nodefaultlibs"
  = note: clang: error: invalid version number in '-target x86_64-apple-ios13.0-macabi'

warning: `[user]` (lib) generated 6 warnings
error: could not compile `[user]` due to previous error; 6 warnings emitted
```
</details>

### Minimal example

C code:

```c
#include <stdio.h>
void main() {
    int a = 1;
    int b = 2;
    int c = a + b;
    printf("%d", c);
}
```

`clang` command sample:

```
➜  202301 clang -target x86_64-apple-ios13.0-macabi main.c
clang: error: invalid version number in '-target x86_64-apple-ios13.0-macabi'
➜  202301 clang -target x86_64-apple-ios14.0-macabi main.c
main.c:2:1: warning: return type of 'main' is not 'int' [-Wmain-return-type]
void main() {
^
main.c:2:1: note: change return type to 'int'
void main() {
^~~~
int
1 warning generated.
➜  202301 clang -target x86_64-apple-ios15.0-macabi main.c
main.c:2:1: warning: return type of 'main' is not 'int' [-Wmain-return-type]
void main() {
^
main.c:2:1: note: change return type to 'int'
void main() {
^~~~
int
1 warning generated.
➜  202301 clang -target x86_64-apple-ios-macabi main.c
main.c:2:1: warning: return type of 'main' is not 'int' [-Wmain-return-type]
void main() {
^
main.c:2:1: note: change return type to 'int'
void main() {
^~~~
int
1 warning generated.

➜  202301 clang --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
```

This PR is a simplified version of #96392, inspired by https://github.com/rust-lang/cc-rs/pull/727

16 months agodocs(style-guide): add rules for let-else statements
Caleb Cartwright [Thu, 26 Jan 2023 01:43:06 +0000 (19:43 -0600)]
docs(style-guide): add rules for let-else statements

16 months agoAuto merge of #105670 - Xiretza:rustc_parse-diagnostics-4, r=davidtwco
bors [Thu, 2 Feb 2023 02:23:31 +0000 (02:23 +0000)]
Auto merge of #105670 - Xiretza:rustc_parse-diagnostics-4, r=davidtwco

rustc_parse: diagnostics migration, v4

This is all the `rustc_parse` migrations I have in store right now; unfortunately life is pretty busy right now, so I won't be able to do much more in the near future.

cc #100717

r? `@davidtwco`

16 months agoBless tests after rebase
Bryan Garza [Thu, 2 Feb 2023 01:38:14 +0000 (01:38 +0000)]
Bless tests after rebase

16 months agoUpdate test to not trigger stack overflow
Bryan Garza [Wed, 1 Feb 2023 21:09:24 +0000 (21:09 +0000)]
Update test to not trigger stack overflow

16 months agoMove ignore-pass to large-arg test
Bryan Garza [Tue, 31 Jan 2023 18:56:55 +0000 (18:56 +0000)]
Move ignore-pass to large-arg test

16 months agoUpdate based on PR comments
Bryan Garza [Tue, 31 Jan 2023 17:04:18 +0000 (17:04 +0000)]
Update based on PR comments

16 months agoAdd tests to assert current behavior of large future sizes
Bryan Garza [Tue, 31 Jan 2023 03:49:11 +0000 (03:49 +0000)]
Add tests to assert current behavior of large future sizes

Based on a couple of sources:
- https://swatinem.de/blog/future-size/
- https://github.com/rust-lang/rust/issues/62958

16 months agoReinstate the `hir-stats.rs` tests on stage 1.
Nicholas Nethercote [Wed, 1 Feb 2023 23:22:44 +0000 (10:22 +1100)]
Reinstate the `hir-stats.rs` tests on stage 1.

16 months agoAuto merge of #107574 - compiler-errors:back-to-old-mac-builders-pls, r=pietroalbini
bors [Wed, 1 Feb 2023 22:45:27 +0000 (22:45 +0000)]
Auto merge of #107574 - compiler-errors:back-to-old-mac-builders-pls, r=pietroalbini

Revert "switch to the macos-12-xl builder"

This reverts commit fcbae989ae790d5b9a0a23ceba242d0b0d4e6c5b.

This should fix the bors failures in https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/Every.20rust-lang.2Frust.20PR.20is.20failing.20bors

16 months agoAdd proc-macro boilerplate to crt-static test
Joseph Ryan [Wed, 1 Feb 2023 21:35:36 +0000 (13:35 -0800)]
Add proc-macro boilerplate to crt-static test