Skip to content

Rollup of 9 pull requests - #164991

Closed
JonathanBrouwer wants to merge 52 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-ryLHhKW
Closed

JonathanBrouwer wants to merge 52 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-ryLHhKW

Conversation

@JonathanBrouwer

@JonathanBrouwer JonathanBrouwer commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Successful merges:

r? @ghost

Create a similar rollup

estebank and others added 30 commits October 24, 2026 20:40
…pe being returned

```
error: lifetime may not live long enough
  --> $DIR/return-expr-with-implicit-trait-object-static-obligation.rs:11:24
   |
LL |         pub fn new(string: &str) -> Self {
   |                            - let's call the lifetime of this reference `'1`
LL |             Thing {
LL |                 chars: Box::new(string.chars()),
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^ coercion requires that `'1` must outlive `'static`
   |
note: this trait object introduces an implicit `'static` obligation
  --> $DIR/return-expr-with-implicit-trait-object-static-obligation.rs:5:20
   |
LL |     pub struct Thing {
LL |         chars: Box<dyn Iterator<Item = char>>,
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider introducing an explicit lifetime
   |
LL ~     pub struct Thing<'a> {
LL ~         chars: Box<dyn Iterator<Item = char> + 'a>,
   |
```
…nd add test for multiple `dyn Trait`s

```
error: lifetime may not live long enough
  --> $DIR/return-expr-with-implicit-trait-object-static-obligation.rs:126:25
   |
LL |         pub fn new(string: &str) -> Self {
   |                            - let's call the lifetime of this reference `'1`
LL |             Thing {
LL |                 chars: (Box::new(string.chars()), Box::new(string.chars())),
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^ coercion requires that `'1` must outlive `'static`
   |
note: these `dyn Trait`s introduce an implicit `'static` obligation
  --> $DIR/return-expr-with-implicit-trait-object-static-obligation.rs:120:21
   |
LL |     pub struct Thing {
LL |         chars: (Box<dyn Iterator<Item = char>>, Box<dyn Iterator<Item = char>>),
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^       ^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider introducing an explicit lifetime
   |
LL ~     pub struct Thing<'a> {
LL ~         chars: (Box<dyn Iterator<Item = char> + 'a>, Box<dyn Iterator<Item = char> + 'a>),
   |
```
```
error: lifetime may not live long enough
  --> $DIR/return-expr-with-implicit-trait-object-static-obligation.rs:24:13
   |
LL |       impl Thing<'_> {
   |                  -- lifetime `'2` introduced here
LL |           pub fn new(string: &str) -> Self {
   |                              -        ---- return type is `b::Thing<'2>`
   |                              |
   |                              let's call the lifetime of this reference `'1`
LL | /             Thing {
LL | |                 chars: Box::new(string.chars()),
LL | |             }
   | |_____________^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
```
```
error: lifetime may not live long enough
  --> $DIR/issue-52742.rs:12:9
   |
LL | impl Foo<'_, '_> {
   |              -- lifetime `'2` introduced here
LL |     fn take_bar(&mut self, b: Bar<'_>) {
   |                 ---------  -      -- lifetime `'1` introduced here
   |                 |          |
   |                 |          has type `Bar<'1>`
   |                 has type `&mut Foo<'_, '2>`
LL |         self.y = b.z
   |         ^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
```
When encountering a type mismatch in arguments of a call expr of an associated function, point not only at the `trait` but also the `impl`.

```
error[E0308]: mismatched types
   --> tests/ui/fn_traits/point-at-impl-in-call-argument-type-error.rs:9:21
    |
  9 |     let b = B::from(a); //~ ERROR: mismatched types
    |             ------- ^ expected `B`, found `A`
    |             |
    |             arguments to this function are incorrect
    |
note: associated function defined here
   --> library/core/src/convert/mod.rs:594:8
    |
588 | pub const trait From<T>: Sized {
...
594 |     fn from(value: T) -> Self;
    |        ^^^^
note: associated function provided through this `impl`
   --> library/core/src/convert/mod.rs:787:1
    |
787 | const impl<T> From<T> for T {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
…functions calling lower_attrs()

Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Point at `impl` through which associated function is provided

When encountering a type mismatch in arguments of a call expr of an associated function, point not only at the `trait` but also the `impl`.

```
error[E0308]: mismatched types
   --> tests/ui/fn_traits/point-at-impl-in-call-argument-type-error.rs:9:21
    |
  9 |     let b = B::from(a); //~ ERROR: mismatched types
    |             ------- ^ expected `B`, found `A`
    |             |
    |             arguments to this function are incorrect
    |
note: associated function defined here
   --> library/core/src/convert/mod.rs:594:8
    |
588 | pub const trait From<T>: Sized {
...
594 |     fn from(value: T) -> Self;
    |        ^^^^
note: associated function provided through this blanket `impl`
   --> library/core/src/convert/mod.rs:787:1
    |
787 | const impl<T> From<T> for T {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

Includes/conflicts with rust-lang#164695.

Fix rust-lang#104712.
…expr-2, r=oli-obk

Account for trait object with implicit `'static` lifetime in field type being returned

Point at `dyn Trait` in field of type definition when it introduces a `'static` obligation:

```
error: lifetime may not live long enough
  --> $DIR/return-expr-with-implicit-trait-object-static-obligation.rs:11:24
   |
LL |         pub fn new(string: &str) -> Self {
   |                            - let's call the lifetime of this reference `'1`
LL |             Thing {
LL |                 chars: Box::new(string.chars()),
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^ coercion requires that `'1` must outlive `'static`
   |
note: `dyn Trait` introduces an implicit `'static` obligation
  --> $DIR/return-expr-with-implicit-trait-object-static-obligation.rs:5:20
   |
LL |     pub struct Thing {
LL |         chars: Box<dyn Iterator<Item = char>>,
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider introducing an explicit lifetime
   |
LL ~     pub struct Thing<'a> {
LL ~         chars: Box<dyn Iterator<Item = char> + 'a>,
   |
```

Fix rust-lang#78547.

Point at introduction of unmet lifetime:

```
error: lifetime may not live long enough
  --> $DIR/return-expr-with-implicit-trait-object-static-obligation.rs:24:13
   |
LL |       impl Thing<'_> {
   |                  -- lifetime `'2` introduced here
LL |           pub fn new(string: &str) -> Self {
   |                              -        ---- return type is `b::Thing<'2>`
   |                              |
   |                              let's call the lifetime of this reference `'1`
LL | /             Thing {
LL | |                 chars: Box::new(string.chars()),
LL | |             }
   | |_____________^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
```

```
error: lifetime may not live long enough
  --> $DIR/issue-52742.rs:12:9
   |
LL | impl Foo<'_, '_> {
   |              -- lifetime `'2` introduced here
LL |     fn take_bar(&mut self, b: Bar<'_>) {
   |                 ---------  -      -- lifetime `'1` introduced here
   |                 |          |
   |                 |          has type `Bar<'1>`
   |                 has type `&mut Foo<'_, '2>`
LL |         self.y = b.z
   |         ^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
```
…er-const-param, r=khyperia

Self param after const param

closes: rust-lang#164570

The main issue here is that a const param before self could cause fn_has_self_parameter to incorrectly classify a function as a method, since removing the const param left self first. This PR fixes that by checking whether a const param has arg_pos == 0. It also adds a checked_sub now instead of vanilla '-'.

r? @khyperia
Switch from `insta` to `expect-test` in bootstrap

While I like `insta` a bit more for snapshot tests, it has a disadvantage that it requires installing a separate binary (`cargo insta`) for blessing *inline* snapshot tests. That is not very intuitive for people who need to bless inline bootstrap snapshots, and then realize that `x test bootstrap --bless` does nothing.

This PR switches from `insta` to `expect-test`, which allows updating inline snapshots via an environment variable while running `cargo test`, without requiring a separate binary. `expect-test` is a `rust-lang` (well, `rust-analyzer`) [repository](https://github.com/rust-analyzer/expect-test), so we should be good there, and it even removes two `dev` dependencies from bootstrap.

Changing the inline snapshots was a bit non-trivial to do with a regex (at least in my IDE) because we have to switch the argument order, which is not that simple across multiple lines. So I decided to try https://github.com/ast-grep/ast-grep. I used an LLM to propose the initial rewrite rule, and then modified it slightly and ran `ast-grep` to update the code. The applied rule was this:
```yaml
id: insta-to-expect-test
language: rust
rule:
  pattern: insta::assert_snapshot!($$$ARGS)
transform:
  LHS:
    replace:
      source: $$$ARGS
      replace: '(?s)^(?<lhs>.*?),\s*@(?<rhs>.*?)\s*,?\s*$'
      by: '${lhs}'
  RHS:
    replace:
      source: $$$ARGS
      replace: '(?s)^(?<lhs>.*?),\s*@(?<rhs>.*?)\s*,?\s*$'
      by: '${rhs}'
fix: expect_test::expect![[$RHS]].assert_eq(&$LHS)
```

You can test it in the `ast-grep` [playground](https://ast-grep.github.io/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InJ1c3QiLCJxdWVyeSI6IiIsInJld3JpdGUiOiJzb3VyY2U6ICQkJEFSR1NcbnJlcGxhY2U6ICcoP3MpXig/PGxocz4uKj8pLFxccypAKD88cmhzPi4qPylcXHMqLD9cXHMqJCdcbmJ5OiAnJHtyaHN9JyIsInN0cmljdG5lc3MiOiJzbWFydCIsInNlbGVjdG9yIjoiIiwiY29uZmlnIjoiaWQ6IGluc3RhLXRvLWV4cGVjdC10ZXN0XG5sYW5ndWFnZTogcnVzdFxucnVsZTpcbiAgcGF0dGVybjogaW5zdGE6OmFzc2VydF9zbmFwc2hvdCEoJCQkQVJHUylcbnRyYW5zZm9ybTpcbiAgTEhTOlxuICAgIHJlcGxhY2U6XG4gICAgICBzb3VyY2U6ICQkJEFSR1NcbiAgICAgIHJlcGxhY2U6ICcoP3MpXig/PGxocz4uKj8pLFxccypAKD88cmhzPi4qPylcXHMqLD9cXHMqJCdcbiAgICAgIGJ5OiAnJHtsaHN9J1xuICBSSFM6XG4gICAgcmVwbGFjZTpcbiAgICAgIHNvdXJjZTogJCQkQVJHU1xuICAgICAgcmVwbGFjZTogJyg/cyleKD88bGhzPi4qPyksXFxzKkAoPzxyaHM+Lio/KVxccyosP1xccyokJ1xuICAgICAgYnk6ICcke3Joc30nXG5maXg6IGV4cGVjdF90ZXN0OjpleHBlY3QhWyRSSFNdLmFzc2VydF9lcSgmJExIUykiLCJzb3VyY2UiOiJpbnN0YTo6YXNzZXJ0X3NuYXBzaG90IShcbiAgICAgICAgICAgIGN0eC5jb25maWcoXCJidWlsZFwiKVxuICAgICAgICAgICAgICAgIC5yZW5kZXJfc3RlcHMoKSwgQHJcIlxuICAgICAgICBbYnVpbGRdIGxsdm0gPGhvc3Q+XG4gICAgICAgIFtidWlsZF0gcnVzdGMgMCA8aG9zdD4gLT4gcnVzdGMgMSA8aG9zdD5cbiAgICAgICAgW2J1aWxkXSBydXN0YyAxIDxob3N0PiAtPiBzdGQgMSA8aG9zdD5cbiAgICAgICAgW2J1aWxkXSBydXN0ZG9jIDEgPGhvc3Q+XG4gICAgICAgIFwiLFxuICAgICAgICApOyJ9).

I used double brackets because it formatted better (IMO) with `x fmt`. Most of the diff comes from the this mechanical change. I split it into a separate commit for easier review.

I tried to replicate the disk snapshots as closely as possible, by even including the source file path in them, though I think it is not very useful. There are some newline changes in a few tests, I didn't feel like it is worth fixing those.

CC @Zalathar

I suppose that we should do the same for `citool`, I can send that as a follow-up.

Fixes: rust-lang#164837
…w-test, r=nnethercote

Add regression tests for rust-lang#156380

Adds two ui tests in `tests/ui/reborrow` for the two snippets in rust-lang#156380.

The first one (moving a `String` out of a `Reborrow` type twice) was fixed by rust-lang#156784. That PR has its own test but with a different struct, so this adds the exact repro from the issue.

The second one (getting two aliasing `&mut i32` through a generic field) had no test. It compiles on nightly-2026-08-28 and errors on nightly-2026-08-29, which points at rust-lang#159103.

I checked both by hand: they compile on nightly-2026-05-20 and error on the current nightly, with and without `-Znext-solver`.

Fixes rust-lang#156380

Disclaimer - AI was used to explore and get the understanding of the codebase. All the changes and tests are executed and reviewed by me personally. Thansk
@rust-bors rust-bors Bot added the rollup A PR which is a rollup label Oct 26, 2026
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-testsuite Area: The testsuite used to check the correctness of rustc O-apple Operating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS) O-linux Operating system: Linux O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-wasm Target: WASM (WebAssembly), http://webassembly.org/ O-windows Operating system: Windows 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-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. labels Oct 26, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member Author

@bors r+ p=5 force

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

@rust-bors

rust-bors Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c9de86d 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 Oct 26, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 26, 2026
Rollup of 9 pull requests


try-job: dist-various-1
try-job: test-various
try-job: test-x86_64-gnu-aux
try-job: test-x86_64-msvc-1
try-job: test-aarch64-apple-1
try-job: test-aarch64-apple-2
try-job: test-x86_64-mingw-1
try-job: test-i686-msvc
try-job: test-armhf-gnu
try-job: test-x86_64-gnu-llvm-22-3
@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 26, 2026
@rust-bors

rust-bors Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved due to being closed.

@rust-bors

rust-bors Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: edfd7f6 (edfd7f642019487588990682215f79f6d67ac1ba)
Base parent: 846e51f (846e51f66b1e7b49ba9e3988c58ccfe5817ce0a9)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-testsuite Area: The testsuite used to check the correctness of rustc O-apple Operating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS) O-linux Operating system: Linux O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-wasm Target: WASM (WebAssembly), http://webassembly.org/ O-windows Operating system: Windows rollup A PR which is a rollup S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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.

9 participants