Skip to content

Rollup of 4 pull requests - #161782

Closed
JonathanBrouwer wants to merge 41 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-4ebLb4O
Closed

Rollup of 4 pull requests#161782
JonathanBrouwer wants to merge 41 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-4ebLb4O

Conversation

@JonathanBrouwer

Copy link
Copy Markdown
Member

Successful merges:

r? @ghost

Create a similar rollup

maxdexh and others added 30 commits August 24, 2026 19:21
…08 notes

The `for<...>` prefixes in `cmp_fn_sig` are built from the region map
returned by `name_all_regions`. That map also contained regions that are
bound by an enclosing binder and merely escape through the binder being
named, so nested binders in expected/found notes listed lifetimes they
don't bind, printing invalid types such as
`&mut for<'a> fn(for<'a> fn(&'a ()))` for `&mut for<'a> fn(fn(&'a ()))`.

Key the folder's map by the region's binder offset and only return the
regions actually bound by the binder being named. The offset in the key
also fixes a latent collision between a bound and an escaping region
sharing the same bound variable index. The printed text is unaffected:
the `name` closure already skips escaping regions when writing to the
printer, which is why diagnostic labels were already correct.
ChrisDenton and others added 11 commits August 25, 2026 18:15
This can affect drop order
Enforce even more library clippy lints in CI

Once again, this is best reviewed commit-by-commit since each commit fixes a lint.

I've bundled together a large(ish) number of lints because I feel they shouldn't be controversial and don't touch too much code. A large chunk of them is just telling clippy that, for example, implementing `is_digit` by calling `is_digit` just isn't going to work. I have reviewed each and every fix myself but please do double or triple check my working!
Replace `Allocator + Clone` with `AllocatorClone` in btree

powered by ripgrep

r? nia-e
…nting, r=jackh726

Don't list escaping bound regions in nested `for<...>` binders of E0308 notes

The expected/found notes of "one type is more general than the other" errors could print types that are not even valid syntax, repeating lifetimes from an outer binder inside nested `for<...>` lists:

```
= note: expected mutable reference `&mut for<'a> fn(for<'a> fn(&'a ()))`
           found mutable reference `&mut fn(fn(&()))`
```

The expected type here is actually `&mut for<'a> fn(fn(&'a ()))`, the inner fn pointer binds nothing. In the example from rust-lang#111365 the note printed `for<'o> fn(for<'a, 'o> fn(&'a (), &'o ()))` even though the inner binder only binds `'a`.

The cause is in how `cmp_fn_sig` builds its `for<...>` prefixes. It calls `name_all_regions` and joins every region of the returned map into the list. But `RegionFolder` folded every region at or above the depth of the binder being printed (`db >= self.current_index`), so regions that are bound by an enclosing binder and merely escape through the current one also ended up in the map. The pretty printer's own text output already skipped those regions via a special case in the naming closure (which is why the labels of these diagnostics were correct, see rust-lang#102392), but the returned map kept them, and `cmp_fn_sig` recurses through nested fn pointers one binder at a time, so every nested `for<...>` list picked up all the outer lifetimes. That special case also rebound the escaping region to `self.current_index`, i.e. shifted its De Bruijn index down so that it looked like it was bound by the current binder.

This PR makes `RegionFolder` only fold regions bound by the binder being named (`db == self.current_index`). Escaping regions are left untouched: they keep their index, and they already carry a name because the enclosing binder named them when it was folded (`cmp_fn_sig` recurses on the folded value). This makes the rust-lang#102392 special case in the naming closure dead, so it is removed along with the two `DebruijnIndex` parameters it needed.

With this change, the two examples above print:

```
= note: expected mutable reference `&mut for<'a> fn(fn(&'a ()))`
           found mutable reference `&mut fn(fn(&()))`
```

```
= note: expected fn pointer `for<'o> fn(for<'a> fn(&'a (), &'o ()))`
           found fn pointer `fn(for<'a> fn(&'a (), &'a ()))`
```

The `found` line of `tests/ui/nll/relate_tys/placeholder-outlives-existential.rs` also loses its leaked binders and now matches the type written in the test's source.

Fixes rust-lang#134410

This also fixes the leaked outer lifetimes reported in rust-lang#111365, but I left that issue open since it additionally asks for renaming of shadowed lifetimes (`for<'a> fn(for<'a> ...)` for two distinct lifetimes both named `'a` in the source), which is a separate problem.
…nBrouwer

Add codegen test for disjunction fed to unreachable_unchecked

Closes rust-lang#115026
@rust-bors rust-bors Bot added the rollup A PR which is a rollup label Aug 25, 2026
@rustbot rustbot added 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. labels Aug 25, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rollup A PR which is a rollup 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants