Skip to content

Rollup of 4 pull requests#158270

Closed
jhpratt wants to merge 13 commits into
rust-lang:mainfrom
jhpratt:rollup-yZVD8FK
Closed

Rollup of 4 pull requests#158270
jhpratt wants to merge 13 commits into
rust-lang:mainfrom
jhpratt:rollup-yZVD8FK

Conversation

@jhpratt

@jhpratt jhpratt commented Jun 22, 2026

Copy link
Copy Markdown
Member

Successful merges:

r? @ghost

Create a similar rollup

Dnreikronos and others added 13 commits June 21, 2026 15:42
This reverts commit 7bc5016.
They tend to have similar handling -- e.g., they should be the only
input to the `mir_shims` query -- so it's cleaner to group them
together. This will also make potential future refactorings easier, such
as only carrying `GenericArgsRef` for instances that actually use it
(e.g., `Item`) but not others (e.g., `CloneShim`).

Many of the shim variants still have `Shim` at the end of their names.
To make the refactoring easier and keep the diff clean, I will trim
those suffixes off in the next commit.
It used to be much more prevalent before I extracted shims as their own enum.
…erics, r=petrochenkov

delegation: add support for infers in generics

This PR adds support for generating generic params for lifetimes and types/consts infers (`'_`. `_`). We support only single infers, if they are nested then we do nothing and eventually an error will be emitted after inheriting this unsound signature (i.e., `reuse foo::<Vec<_>>` is not supported).

The basic idea is:
```rust
fn foo<'a, 'b: 'b, T, const N: usize>() {}

reuse foo::<'_, String, _> as bar;

// Desugaring:
fn bar<'b, const N: usize>() {
  foo::<'b, String, N>()
}
```

So we generated params and lifetimes for provided infers. Note that in case of lifetimes we may have early and late bound lifetimes in child segment. We process only early-bound lifetimes as they are present in signature function generics (`tcx.generics_of(sig_id)`). Moreover since this PR we started to explicitly propagate early-bound lifetimes in generated delegation's call, so the warning about specifying lifetimes when late-bound lifetimes are present is suppressed for delegation segments.

Next, we limit the number of processed infers with the number of generic params in the signature function, so if we have `fn foo<X, Y>() {}` and we wrote `reuse foo::<_, _, _, _>;` we will not generate 4 generic params in delegation, we will generate 2 (`X` and `Y`), two remaining infers will not be processed and this will result in an error.

Considering free-to-trait reuses this PR extends the number of supported cases, as now we always generate `Self` generic param when needed:
```rust
trait Trait<'a, X> {
    fn method<'b, const M: usize>(&self) where 'b:'b { }
    fn r#static<'b, Y, const B: bool>() { }
}

impl <'a, X> Trait<'a, X> for () { }

reuse Trait::<'_, _>::method::<'_, _> as foo;
reuse <_ as Trait<'_, _>>::method::<'_, _> as foo1;
reuse <() as Trait<'_, _>>::method::<'_, _> as foo2;
reuse <_ as Trait<'_, _>>::r#static::<_, _> as foo3;
reuse <() as Trait<'_, _>>::r#static::<_, _> as foo4;
reuse Trait::<'_, _>::r#static::<_, _> as foo5;

// Desugaring:
#[attr = Inline(Hint)]
fn foo<'a, 'b, Self, X, const M: _>(self: _) -> _ where 'a:'a,
    'b:'b { <Self as Trait::<'a, X>>::method::<'b, M>(self) }
#[attr = Inline(Hint)]
fn foo1<'a, 'b, Self, X, const M: _>(self: _) -> _ where 'a:'a,
    'b:'b { <Self as Trait::<'a, X>>::method::<'b, M>(self) }
#[attr = Inline(Hint)]
fn foo2<'a, 'b, X, const M: _>(self: _) -> _ where 'a:'a,
    'b:'b { <() as Trait::<'a, X>>::method::<'b, M>(self) }
#[attr = Inline(Hint)]
fn foo3<'a, Self, X, Y, const B: _>() -> _ where
    'a:'a { <Self as Trait::<'a, X>>::r#static::<Y, B>() }
#[attr = Inline(Hint)]
fn foo4<'a, X, Y, const B: _>() -> _ where
    'a:'a { <() as Trait::<'a, X>>::r#static::<Y, B>() }
#[attr = Inline(Hint)]
fn foo5<'a, Self, X, Y, const B: _>() -> _ where
    'a:'a { <Self as Trait::<'a, X>>::r#static::<Y, B>() }
```
Note that we generated `Self` in `foo5` reuse. With that done the error about self-type specification is removed.

Finally this PR greatly simplifies generic args for signature inheritance generation code.

Part of rust-lang#118212.
r? @petrochenkov
Extract all instance shim variants into new `ShimKind` enum

They tend to have similar handling -- e.g., they should be the only
input to the `mir_shims` query -- so it's cleaner to group them
together. This will also make potential future refactorings easier, such
as only carrying `GenericArgsRef` for instances that actually use it
(e.g., `Item`) but not others (e.g., `CloneShim`).

cc https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/moving.20ty.3A.3AInstance.2Eargs.20into.20ty.3A.3AInstanceKind.20variants
r? @oli-obk
…_diagnostic, r=TaKO8Ki

format: ignore println newline in foreign format hints

fixes rust-lang#158216

`println!` adds a newline before the unused-arg diagnostic checks for printf-style formats. that made a trailing `%` look like `%` plus `
`, so rustc printed a weird unsupported conversion specifier note.

imo the least risky fix is to leave normal format parsing alone and only strip that synthetic newline for the foreign-format hint scan. idk if there is much more to do here, the ui tests cover the reported case plus the older trailing-percent baselines. lgtm to me, ltm this keeps the behavior narrow.
Use `cfg_select` in `std::os`

rust-lang#81969 replaced `cgf_if` with bare `cfg`, but since `cfg_select` is now built in, it shouldn't pose a problem to rust-analyzer any more, so we should be able to go back to better code.
@rust-bors rust-bors Bot added the rollup A PR which is a rollup label Jun 22, 2026
@rustbot rustbot added PG-exploit-mitigations Project group: Exploit mitigations 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. labels Jun 22, 2026
@jhpratt

jhpratt commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

@bors r+ rollup=never p=5

@rust-bors

rust-bors Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 0d29c91 has been approved by jhpratt

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 Jun 22, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 22, 2026
Rollup of 4 pull requests

Successful merges:

 - #157960 (delegation: add support for infers in generics)
 - #158105 (Extract all instance shim variants into new `ShimKind` enum)
 - #158222 (format: ignore println newline in foreign format hints)
 - #158252 (Use `cfg_select` in `std::os`)
@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 22, 2026
@rust-bors

rust-bors Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 5b30789 failed: CI. Failed job:

@jhpratt

jhpratt commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

@bors treeclosed=5

@bors retry

@rust-bors

rust-bors Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Tree closed for PRs with priority less than 5.

@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jun 22, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 22, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 22, 2026
Rollup of 4 pull requests

Successful merges:

 - #157960 (delegation: add support for infers in generics)
 - #158105 (Extract all instance shim variants into new `ShimKind` enum)
 - #158222 (format: ignore println newline in foreign format hints)
 - #158252 (Use `cfg_select` in `std::os`)
@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 22, 2026
@rust-bors

rust-bors Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

💔 Test for ab3b9c0 failed: CI. Failed job:

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

A job failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
  IMAGE: x86_64-gnu-distcheck
##[endgroup]
    Updating crates.io index
error: failed to get `simd-adler32` as a dependency of package `miniz_oxide v0.8.8`
    ... which satisfies dependency `miniz_oxide = "^0.8.5"` of package `flate2 v1.1.9`
    ... which satisfies dependency `flate2 = "^1.1.9"` of package `citool v0.1.0 (/home/runner/work/rust/rust/src/ci/citool)`

Caused by:
  failed to load source for dependency `simd-adler32`

Caused by:

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

A job failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
  DEPLOY: 1
  IMAGE: dist-aarch64-linux
##[endgroup]
    Updating crates.io index
error: failed to get `askama_derive` as a dependency of package `askama_macros v0.16.0`
    ... which satisfies dependency `askama_macros = "=0.16.0"` of package `askama v0.16.0`
    ... which satisfies dependency `askama = "^0.16.0"` of package `citool v0.1.0 (/home/runner/work/rust/rust/src/ci/citool)`

Caused by:
  failed to load source for dependency `askama_derive`

Caused by:
  unable to update registry `crates-io`

Caused by:
  download of as/ka/askama_derive failed

Caused by:
  curl failed

Caused by:

@jhpratt

jhpratt commented Jun 23, 2026

Copy link
Copy Markdown
Member Author

@bors treeclosed-

@rust-bors

rust-bors Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Tree is now open for merging.

@jhpratt jhpratt closed this Jun 23, 2026
@rust-bors

rust-bors Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved due to being closed.

@rust-bors rust-bors Bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 23, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 23, 2026
@jhpratt jhpratt deleted the rollup-yZVD8FK branch June 23, 2026 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PG-exploit-mitigations Project group: Exploit mitigations 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-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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants