Rollup of 8 pull requests#158288
Closed
jhpratt wants to merge 21 commits into
Closed
Conversation
…xternal `module` variants.
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.
Member
Author
|
@bors r+ rollup=never p=5 |
Contributor
This comment has been minimized.
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)
Contributor
|
💔 Test for 5b283fc failed: CI. Failed job:
|
Member
Author
Contributor
|
Tree closed for PRs with priority less than 5. |
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)
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) |
Member
Author
|
@bors treeclosed- |
Contributor
|
Tree is now open for merging. |
Contributor
|
dist-i686-msvc is stuck on lint-docs again :c |
Contributor
|
This pull request was unapproved due to being closed. Auto build was cancelled due to the PR being closed. Cancelled workflows: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successful merges:
ShimKindenum #158105 (Extract all instance shim variants into newShimKindenum)resolve_ident_in_module_non_globs_unadjusted#158207 (Resolver: local/external split ofresolve_ident_in_module_non_globs_unadjusted)cfg_selectinstd::os#158252 (Usecfg_selectinstd::os)r? @ghost
Create a similar rollup