Skip to content

Rollup of 6 pull requests#155115

Merged
rust-bors[bot] merged 16 commits intorust-lang:mainfrom
JonathanBrouwer:rollup-RePrRPQ
Apr 10, 2026
Merged

Rollup of 6 pull requests#155115
rust-bors[bot] merged 16 commits intorust-lang:mainfrom
JonathanBrouwer:rollup-RePrRPQ

Conversation

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

Successful merges:

r? @ghost

Create a similar rollup

nnethercote and others added 16 commits March 30, 2026 14:15
Currently, `rustc_errors` depends on `rustc_abi`, which depends on
`rustc_error_messages`. This is a bit odd.

`rustc_errors` depends on `rustc_abi` for a single reason: `rustc_abi`
defines a type `TargetDataLayoutErrors` and `rustc_errors` impls
`Diagnostic` for that type.

We can get a more natural relationship by inverting the dependency,
moving the `Diagnostic` trait upstream. Then `rustc_abi` defines
`TargetDataLayoutErrors` and also impls `Diagnostic` for it.
`rustc_errors` is already pretty far upstream in the crate graph, it
doesn't hurt to push it a little further because errors are a very
low-level concept.
Error enum names should not be plural. Even though there are multiple
possible errors, each instance of an error enum describes a single
error. There are dozens of singular error enum names, and only two
plural error enum names. This commit makes them both singular.
Unconditionally pass -Zunstable-options in the `unpretty` and
`-Zno-codegen` (typecheck) paths in compiletest. This ensures
custom targets resolved via RUST_TARGET_PATH work consistently.

This is primarily needed when using non-built-in targets without
a .json extension.

Signed-off-by: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
This PR introduces a `#[diagnostic::on_unknown_item]` attribute that
allows crate authors to customize the error messages emitted by
unresolved imports. The main usecase for this is using this attribute as
part of a proc macro that expects a certain external module structure to
exist or certain dependencies to be there.

For me personally the motivating use-case are several derives in diesel,
that expect to refer to a `tabe` module. That is done either
implicitly (via the name of the type with the derive) or explicitly by
the user. This attribute would allow us to improve the error message in
both cases:

* For the implicit case we could explicity call out our
assumptions (turning the name into lower case, adding an `s` in the end)
+ point to the explicit variant as alternative
* For the explicit variant we would add additional notes to tell the
user why this is happening and what they should look for to fix the
problem (be more explicit about certain diesel specific assumptions of
the module structure)

I assume that similar use-cases exist for other proc-macros as well,
therefore I decided to put in the work implementing this new attribute.
I would also assume that this is likely not useful for std-lib internal
usage.
…r=jdonszelmann

Introduce a `#[diagnostic::on_unknown]` attribute

This PR introduces a `#[diagnostic::on_unknown]` attribute that allows crate authors to customize the error messages emitted by unresolved imports. The main usecase for this is using this attribute as part of a proc macro that expects a certain external module structure to exist or certain dependencies to be there.

For me personally the motivating use-case are several derives in diesel, that expect to refer to a `tabe` module. That is done either implicitly (via the name of the type with the derive) or explicitly by the user. This attribute would allow us to improve the error message in both cases:

* For the implicit case we could explicity call out our assumptions (turning the name into lower case, adding an `s` in the end)
+ point to the explicit variant as alternative
* For the explicit variant we would add additional notes to tell the user why this is happening and what they should look for to fix the problem (be more explicit about certain diesel specific assumptions of the module structure)

I assume that similar use-cases exist for other proc-macros as well, therefore I decided to put in the work implementing this new attribute. I would also assume that this is likely not useful for std-lib internal usage.

related rust-lang#152900 and rust-lang#128674
…ng-attrs, r=petrochenkov

Reject dangling attributes in where clauses

Report `attribute without where predicates` for trailing outer attributes in where clauses.

Closes rust-lang#155073 .
…_abi, r=davidtwco

Invert dependency between `rustc_errors` and `rustc_abi`.

Currently, `rustc_errors` depends on `rustc_abi`, which depends on `rustc_error_messages`. This is a bit odd.

`rustc_errors` depends on `rustc_abi` for a single reason: `rustc_abi` defines a type `TargetDataLayoutErrors` and `rustc_errors` impls `Diagnostic` for that type.

We can get a more natural relationship by inverting the dependency, moving the `Diagnostic` trait upstream. Then `rustc_abi` defines `TargetDataLayoutErrors` and also impls `Diagnostic` for it. `rustc_errors` is already pretty far upstream in the crate graph, it doesn't hurt to push it a little further because errors are a very low-level concept.

r? @davidtwco
…dtwco

Add suggestion to `.to_owned()` used on `Cow` when borrowing

fixes rust-lang#144792
supersedes rust-lang#144925 with the review comments addressed

the tests suggested from @Kivooeo from rust-lang#144925 (comment) didn't work entirely, because these tests failed due to error `[E0308]` mismatched types, which actually already provides a suggestion, that actually makes the code compile:

```
$ cargo check
error[E0308]: mismatched types
 --> src/main.rs:3:5
  |
1 | fn test_cow_suggestion() -> String {
  |                             ------ expected `std::string::String` because of return type
2 |     let os_string = std::ffi::OsString::from("test");
3 |     os_string.to_string_lossy().to_owned()
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `Cow<'_, str>`
  |
  = note: expected struct `std::string::String`
               found enum `std::borrow::Cow<'_, str>`
help: try using a conversion method
  |
3 |     os_string.to_string_lossy().to_owned().to_string()
  |                                           ++++++++++++
```

now this suggestion is of course not good or efficient code, but via clippy with `-Wclippy::nursery` lint group you can actually get to the correct code, so i don't think this is too much of an issue:

<details>
<summary>the clippy suggestions</summary>

```
$ cargo clippy -- -Wclippy::nursery
warning: this `to_owned` call clones the `Cow<'_, str>` itself and does not cause its contents to become owned
 --> src/main.rs:3:5
  |
3 |     os_string.to_string_lossy().to_owned().to_string()
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/beta/index.html#suspicious_to_owned
  = note: `#[warn(clippy::suspicious_to_owned)]` on by default
help: depending on intent, either make the `Cow` an `Owned` variant
  |
3 |     os_string.to_string_lossy().into_owned().to_string()
  |                                 ++
help: or clone the `Cow` itself
  |
3 -     os_string.to_string_lossy().to_owned().to_string()
3 +     os_string.to_string_lossy().clone().to_string()
  |
$ # apply first suggestion
$ cargo c -- -Wclippy::nursery
warning: redundant clone
 --> src/main.rs:3:45
  |
3 |     os_string.to_string_lossy().into_owned().to_string()
  |                                             ^^^^^^^^^^^^ help: remove this
  |
note: this value is dropped without further use
 --> src/main.rs:3:5
  |
3 |     os_string.to_string_lossy().into_owned().to_string()
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/beta/index.html#redundant_clone
  = note: `-W clippy::redundant-clone` implied by `-W clippy::nursery`
  = help: to override `-W clippy::nursery` add `#[allow(clippy::redundant_clone)]`
```

</details>

the actual error that we are looking for is error `[E0515]`, cannot return value referencing local variable, which was only present in the original issue due to automatic type inference assuming you want to return a cloned `Cow<'_, str>`, which is of course not possible. this is why i took the original test functions and turned them into closures, where it's less obvious that it's trying to return the wrong type.

r? davidtwco

(because you reviewed the last attempt)
(also, let me know if i should squash this down to one commit and add myself as the co-contributor)
…t-unstable, r=davidtwco

compiletest: pass -Zunstable-options for unpretty and no-codegen paths

When using custom targets via `RUST_TARGET_PATH`, compiletest does not
consistently pass `-Zunstable-options` in all code paths.

In particular, `unpretty` and `-Zno-codegen` (typecheck) paths invoke
rustc without `-Zunstable-options`, which causes failures when the
target is not built-in.

Pass `-Zunstable-options` in these code paths to ensure consistent
behavior when using custom targets.

This primarily affects setups using custom targets without `.json`
suffix (resolved via `RUST_TARGET_PATH`).
…, r=JonathanBrouwer

Make `rustc_attr_parsing::SharedContext::emit_lint` take a `MultiSpan` instead of a `Span`

I'll likely need it for rust-lang#153721 to allow emitting the lint on one attribute at a time instead of each of the wrong values.

r? @JonathanBrouwer
@rust-bors rust-bors bot added the rollup A PR which is a rollup label Apr 10, 2026
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 10, 2026
@JonathanBrouwer
Copy link
Copy Markdown
Contributor Author

@bors r+ rollup=never p=5

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 10, 2026

📌 Commit eb8e4f9 has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Apr 10, 2026
@JonathanBrouwer
Copy link
Copy Markdown
Contributor Author

Trying commonly failed jobs
@bors try jobs=dist-various-1,test-various,x86_64-gnu-aux,x86_64-gnu-llvm-21-3,x86_64-msvc-1,aarch64-apple,x86_64-mingw-1

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Apr 10, 2026
Rollup of 6 pull requests


try-job: dist-various-1
try-job: test-various
try-job: x86_64-gnu-aux
try-job: x86_64-gnu-llvm-21-3
try-job: x86_64-msvc-1
try-job: aarch64-apple
try-job: x86_64-mingw-1
@rust-bors

This comment has been minimized.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 10, 2026

☀️ Try build successful (CI)
Build commit: 8db16f0 (8db16f06651a427acfeae413fbdc2ee30ae9f768, parent: 8317fef20409adedaa7c385fa6e954867bf626fc)

@rust-bors rust-bors bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 10, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 10, 2026

☀️ Test successful - CI
Approved by: JonathanBrouwer
Duration: 3h 11m 56s
Pushing 02c7f9b to main...

@rust-bors rust-bors bot merged commit 02c7f9b into rust-lang:main Apr 10, 2026
13 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Apr 10, 2026
@rust-timer
Copy link
Copy Markdown
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#152901 Introduce a #[diagnostic::on_unknown] attribute f6ea05762c390c0d778ee486b71fc353193e8198 (link)
#154449 Invert dependency between rustc_errors and rustc_abi. f2609c34695a019d15558b2136c8f0264742ccd6 (link)
#154646 Add suggestion to .to_owned() used on Cow when borrowing 26c50d4356aade7312e49070aabb0154728c6693 (link)
#154993 compiletest: pass -Zunstable-options for unpretty and no-co… b8da7e0d2002392d507570b641b3e698746d041c (link)
#155078 Reject dangling attributes in where clauses 3e4669ee9526f295bb4d7547897e33de27158e7f (link)
#155097 Make rustc_attr_parsing::SharedContext::emit_lint take a … 9fa0dd1b3d60d0290e8ed810fd5876a42d8f04dd (link)

previous master: b6100ccf71

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

@github-actions
Copy link
Copy Markdown
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing b6100cc (parent) -> 02c7f9b (this PR)

Test differences

Show 31 test diffs

Stage 1

  • [ui] tests/ui/diagnostic_namespace/on_unknown/incorrect-locations.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_unknown/incorrect_format_string.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_unknown/malformed_attribute.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_unknown/multiple_errors.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_unknown/unknown_import.rs: [missing] -> pass (J1)
  • [ui] tests/ui/feature-gates/feature-gate-diagnostic-on-unknown.rs: [missing] -> pass (J1)
  • [ui] tests/ui/parser/where-clause-attrs-without-predicate.rs: [missing] -> pass (J1)
  • [ui] tests/ui/suggestions/cow-into-owned-suggestion.rs: [missing] -> pass (J1)

Stage 2

  • [ui] tests/ui/diagnostic_namespace/on_unknown/incorrect-locations.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_unknown/incorrect_format_string.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_unknown/malformed_attribute.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_unknown/multiple_errors.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_unknown/unknown_import.rs: [missing] -> pass (J0)
  • [ui] tests/ui/feature-gates/feature-gate-diagnostic-on-unknown.rs: [missing] -> pass (J0)
  • [ui] tests/ui/parser/where-clause-attrs-without-predicate.rs: [missing] -> pass (J0)
  • [ui] tests/ui/suggestions/cow-into-owned-suggestion.rs: [missing] -> pass (J0)

Additionally, 15 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 02c7f9bec0fd583160f8bcccb830216023b07bee --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-gnu-aux: 2h 20m -> 1h 49m (-21.9%)
  2. dist-aarch64-apple: 1h 57m -> 1h 39m (-15.1%)
  3. dist-aarch64-llvm-mingw: 1h 49m -> 1h 34m (-13.3%)
  4. aarch64-msvc-2: 1h 39m -> 1h 52m (+12.9%)
  5. dist-apple-various: 1h 37m -> 1h 49m (+12.6%)
  6. aarch64-apple: 3h 27m -> 3h 3m (-11.4%)
  7. dist-x86_64-apple: 2h 3m -> 2h 16m (+10.9%)
  8. aarch64-gnu: 2h 5m -> 2h 18m (+10.4%)
  9. x86_64-msvc-ext2: 1h 57m -> 1h 45m (-10.0%)
  10. dist-aarch64-msvc: 1h 37m -> 1h 47m (+9.4%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (02c7f9b): comparison URL.

Overall result: ❌ regressions - please read:

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

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

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.3% [0.3%, 0.3%] 1
Regressions ❌
(secondary)
0.4% [0.1%, 0.7%] 13
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.3%, 0.3%] 1

Max RSS (memory usage)

Results (primary -0.1%, secondary -3.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
10.1% [10.1%, 10.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-5.3% [-7.8%, -2.7%] 2
Improvements ✅
(secondary)
-3.8% [-5.5%, -2.1%] 2
All ❌✅ (primary) -0.1% [-7.8%, 10.1%] 3

Cycles

Results (secondary -4.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.8% [-8.4%, -2.2%] 8
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 491.232s -> 491.759s (0.11%)
Artifact size: 394.07 MiB -> 394.19 MiB (0.03%)

@rustbot rustbot added the perf-regression Performance regression. label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. rollup A PR which is a rollup T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants