Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #122830

Merged
merged 32 commits into from Mar 21, 2024
Merged

Rollup of 8 pull requests #122830

merged 32 commits into from Mar 21, 2024

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

Nadrieril and others added 30 commits March 19, 2024 02:20
This makes it consistent with `is_whole_expr` and `is_whole_block`.
It can't use `maybe_whole`, but it can match `maybe_whole` more closely.

Also add a test for a case that wasn't previously covered.
This requires changing `maybe_whole!` so it allows the value to be
modified.
It has no effect on anything in the test suite.
This commit combines `MatchedTokenTree` and `MatchedNonterminal`, which
are often considered together, into a single `MatchedSingle`. It shares
a representation with the newly-parameterized `ParseNtResult`.

This will also make things much simpler if/when variants from
`Interpolated` start being moved to `ParseNtResult`.
It uses very old language that is more confusing today than helpful,
including references to `SubstNt` that no longer exists. The comment
above `TokenStream` is better, and suffices for a basic understanding of
these types.
Backend and target selection is a mess: the target can override the
backend (via `Target::default_codegen_backend`), *and* the backend can
override the target (via `CodegenBackend::target_override`).

The code that handles this is ugly. It calls `build_target_config`
twice, once before getting the backend and once again afterward. It also
must check that both overrides aren't triggering at the same time.

This commit removes the latter override. It's used in rust-gpu but
@eddyb said via Zulip that removing it would be ok. This simplifies the
code greatly, and will allow some nice follow-up refactorings.
Because the underlying type is called `Target`. (There is also a
separate type called `TargetCfg`.)
This commit fixes several issues with the format string parsing of the
`#[diagnostic::on_unimplemented]` attribute that were pointed out by
@ehuss.
In detail it fixes:

* Appearing format specifiers (display, etc). For these we generate a
warning that the specifier is unsupported. Otherwise we ignore them
* Positional arguments. For these we generate a warning that positional
arguments are unsupported in that location and replace them with the
format string equivalent (so `{}` or `{n}` where n is the index of the
positional argument)
* Broken format strings with enclosed }. For these we generate a warning
about the broken format string and set the emitted message literally to
the provided unformatted string
* Unknown format specifiers. For these we generate an additional warning
about the unknown specifier. Otherwise we emit the literal string as
message.

This essentially makes those strings behave like `format!` with the
minor difference that we do not generate hard errors but only warnings.
After that we continue trying to do something unsuprising (mostly either
ignoring the broken parts or falling back to just giving back the
literal string as provided).

Fix rust-lang#122391
…er in the hidden type to the generic parameters of the definition of the opaque
Stop using `box PAT` syntax for deref patterns, as it's misleading and
also causes their semantics being tangled up.
…rors

Make `#[diagnostic::on_unimplemented]` format string parsing more robust

This commit fixes several issues with the format string parsing of the `#[diagnostic::on_unimplemented]` attribute that were pointed out by `@ehuss.`
In detail it fixes:

* Appearing format specifiers (display, etc). For these we generate a warning that the specifier is unsupported. Otherwise we ignore them
* Positional arguments. For these we generate a warning that positional arguments are unsupported in that location and replace them with the format string equivalent (so `{}` or `{n}` where n is the index of the positional argument)
* Broken format strings with enclosed }. For these we generate a warning about the broken format string and set the emitted message literally to the provided unformatted string
* Unknown format specifiers. For these we generate an additional warning about the unknown specifier. Otherwise we emit the literal string as message.

This essentially makes those strings behave like `format!` with the minor difference that we do not generate hard errors but only warnings. After that we continue trying to do something unsuprising (mostly either ignoring the broken parts or falling back to just giving back the literal string as provided).

Fix rust-lang#122391

r? `@compiler-errors`
…iler-errors

pattern analysis: add a custom test harness

There are two features of the pattern analysis code that are hard to test: the newly-added pattern complexity limit, and the computation of arm intersections. This PR adds some crate-specific tests for that, including an unmaintainable but pretty macro to help construct patterns.

r? `````@compiler-errors`````
Strip placeholders from hidden types before remapping generic parameter

When remapping generic parameters in the hidden type to the generic parameters of the definition of the opaque, we assume that placeholders cannot exist. Instead of just patching that site, I decided to handle it earlier, directly in `infer_opaque_types`, where we are already doing all the careful lifetime handling.

fixes rust-lang#122694

the reason that ICE now occurred was that we stopped treating `operation` as being in the defining scope, so the TAIT became part of the hidden type of the `async fn`'s opaque type instead of just bailing out as ambiguos

I think

```rust
use std::future::Future;

mod foo {
    type FutNothing<'a> = impl 'a + Future<Output = ()>;
    //~^ ERROR: unconstrained opaque type
}

async fn operation(_: &mut ()) -> () {
    //~^ ERROR: concrete type differs from previous
    call(operation).await
    //~^ ERROR: concrete type differs from previous
}

async fn call<F>(_f: F)
where
    for<'any> F: FnMut(&'any mut ()) -> foo::FutNothing<'any>,
{
    //~^ ERROR: expected generic lifetime parameter, found `'any`
}
```

would have already had the same ICE before rust-lang#121796
… r=petrochenkov

Interpolated cleanups

Various cleanups I made while working on attempts to remove `Interpolated`, that are worth merging now. Best reviewed one commit at a time.

r? `@petrochenkov`
add some comments to hir::ModuleItems

I've definitely been bitten by this in the past, where I assumed `items()` would give me *all* the items.
…r=Nadrieril

Implement macro-based deref!() syntax for deref patterns

Stop using `box PAT` syntax for deref patterns, and instead use a perma-unstable macro.

Blocked on rust-lang#122222

r? `@Nadrieril`
…WaffleLapkin

Remove `target_override`

Because the "target can override the backend" and "backend can override the target" situation is a mess. Details in the individual commits.

r? `@WaffleLapkin`
…eLapkin

Remove unnecessary braces from `bug`/`span_bug`

They make never fallback weird and are unnecessary

r? `@WaffleLapkin`
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Mar 21, 2024
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=8

@bors
Copy link
Contributor

bors commented Mar 21, 2024

📌 Commit 6ae51a5 has been approved by matthiaskrgr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 21, 2024
@bors
Copy link
Contributor

bors commented Mar 21, 2024

⌛ Testing commit 6ae51a5 with merge a0569fa...

@bors
Copy link
Contributor

bors commented Mar 21, 2024

☀️ Test successful - checks-actions
Approved by: matthiaskrgr
Pushing a0569fa to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 21, 2024
@bors bors merged commit a0569fa into rust-lang:master Mar 21, 2024
12 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Mar 21, 2024
@rust-timer
Copy link
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#122402 Make #[diagnostic::on_unimplemented] format string parsin… db57a8c0fdf9057ce45f08ff3a298abc8d090588 (link)
#122644 pattern analysis: add a custom test harness af247d2f0f256f9a085319cfc97ac8be79b78dd9 (link)
#122733 Strip placeholders from hidden types before remapping gener… 8bd9c6adfcd0184f77a80257583776fe07094033 (link)
#122752 Interpolated cleanups 0d0239cab8fed8961e74ff987a4dacf761d8e543 (link)
#122771 add some comments to hir::ModuleItems fdf87b138e469e4ea7498ddc629f25dc583c30eb (link)
#122793 Implement macro-based deref!() syntax for deref patterns 798e97d59c4a9377e4c0888c1a29da61bccb7f4e (link)
#122810 Remove target_override 13e46be0066a88958c1763fd9b1a025d1c26fe7c (link)
#122827 Remove unnecessary braces from bug/span_bug 23600371d7d8a194b94283e7b18b3b53b342e5e2 (link)

previous master: 7d01878bd0

In the case of a perf regression, run the following command for each PR you suspect might be the cause: @rust-timer build $SHA

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a0569fa): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 2
Improvements ✅
(primary)
-0.3% [-0.4%, -0.2%] 2
Improvements ✅
(secondary)
-1.2% [-1.7%, -0.8%] 8
All ❌✅ (primary) -0.3% [-0.4%, -0.2%] 2

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.9% [-5.7%, -2.1%] 2
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-3.0%, -1.5%] 12
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 672.198s -> 670.84s (-0.20%)
Artifact size: 314.86 MiB -> 314.97 MiB (0.03%)

@rustbot rustbot added the perf-regression Performance regression. label Mar 21, 2024
@rylev
Copy link
Member

rylev commented Mar 26, 2024

With only small regressions on stress tests, I think it's fine if we don't investigate this too deeply.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet