Skip to content

Rollup of 8 pull requests#158288

Closed
jhpratt wants to merge 21 commits into
rust-lang:mainfrom
jhpratt:rollup-dCKKQ7j
Closed

Rollup of 8 pull requests#158288
jhpratt wants to merge 21 commits into
rust-lang:mainfrom
jhpratt:rollup-dCKKQ7j

Conversation

@jhpratt

@jhpratt jhpratt commented Jun 23, 2026

Copy link
Copy Markdown
Member

Successful merges:

r? @ghost

Create a similar rollup

Dnreikronos and others added 21 commits June 21, 2026 15:42
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.
This reverts commit 7bc5016.
…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
…, r=petrochenkov

Resolver: local/external split of  `resolve_ident_in_module_non_globs_unadjusted`

This PR splits the function `resolve_ident_in_module_non_globs_unadjusted` into 2 variants:
- one for local modules, which is the same work as before
- other for external modules, which requires less work

In preperations for parallel import resolution and overall resolver refactor.

r? @petrochenkov
…_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.
…white

 fix escaping placeholder check in next solver normalization folder

r? @BoxyUwU @adwinwhite
…-light-chevrolet-my-mama-taught-me-wrong-from-right, r=jieyouxu

triagebot: Stop pinging myself

rust-lang/team#2523
… r=tgross35,jhpratt

slice_split_once: bounds check optimization note

Tracking issue: rust-lang#112811

~~Use unchecked sub-slicing operations for `<T>::split_once` and `<T>::rsplit_once`.~~
Note that unchecked sub-slicing operations are equivalent to the current checked sub-slicing operations.
@rust-bors rust-bors Bot added the rollup A PR which is a rollup label Jun 23, 2026
@rustbot rustbot added A-meta Area: Issues & PRs about the rust-lang/rust repository itself 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jun 23, 2026
@jhpratt

jhpratt commented Jun 23, 2026

Copy link
Copy Markdown
Member Author

@bors r+ rollup=never p=5

@rust-bors

rust-bors Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d9761b8 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 23, 2026
@rust-bors

This comment has been minimized.

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

Successful merges:

 - #157960 (delegation: add support for infers in generics)
 - #158105 (Extract all instance shim variants into new `ShimKind` enum)
 - #158207 (Resolver: local/external split of  `resolve_ident_in_module_non_globs_unadjusted` )
 - #158222 (format: ignore println newline in foreign format hints)
 - #158252 (Use `cfg_select` in `std::os`)
 - #158257 ( fix escaping placeholder check in next solver normalization folder)
 - #158274 (triagebot: Stop pinging myself)
 - #158282 (slice_split_once: bounds check optimization note)
@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 23, 2026
@rust-bors

rust-bors Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

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

@jhpratt

jhpratt commented Jun 23, 2026

Copy link
Copy Markdown
Member Author

@bors treeclosed=5

@bors retry

@rust-bors

rust-bors Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Tree closed for PRs with priority less than 5.

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

rust-bors Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

⌛ Testing commit d9761b8 with merge aa4ec99...

Workflow: https://github.com/rust-lang/rust/actions/runs/28009432778

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

Successful merges:

 - #157960 (delegation: add support for infers in generics)
 - #158105 (Extract all instance shim variants into new `ShimKind` enum)
 - #158207 (Resolver: local/external split of  `resolve_ident_in_module_non_globs_unadjusted` )
 - #158222 (format: ignore println newline in foreign format hints)
 - #158252 (Use `cfg_select` in `std::os`)
 - #158257 ( fix escaping placeholder check in next solver normalization folder)
 - #158274 (triagebot: Stop pinging myself)
 - #158282 (slice_split_once: bounds check optimization note)
@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-ohos-aarch64
##[endgroup]
    Updating crates.io index
error: failed to get `idna_adapter` as a dependency of package `idna v1.0.3`
    ... which satisfies dependency `idna = "^1.0"` of package `cookie_store v0.21.1`
    ... which satisfies dependency `cookie_store = "^0.21.1"` of package `ureq v3.0.8`
    ... which satisfies dependency `ureq = "^3"` of package `citool v0.1.0 (/home/runner/work/rust/rust/src/ci/citool)`

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

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

Caused by:
  download of id/na/idna_adapter 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.

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

dist-i686-msvc is stuck on lint-docs again :c

@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 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.

Auto build was cancelled due to the PR being closed. Cancelled workflows:

@jhpratt jhpratt deleted the rollup-dCKKQ7j branch June 23, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-meta Area: Issues & PRs about the rust-lang/rust repository itself 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.