Skip to content

consider subtyping when checking if an infer var is sized - #157820

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
WaffleLapkin:sized-infer-sub
Jul 6, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
WaffleLapkin:sized-infer-sub

Conversation

@WaffleLapkin

@WaffleLapkin WaffleLapkin commented Jun 12, 2026 •

Copy link
Copy Markdown
Member

View all comments

That is, when checking if an inference variable (say ?0) is sized, with this PR, we now check for obligations like ?1: Sized, where ?0 and ?1 are transitively related via subtyping (previously we were checking for ?0 = ?1). This is sound because subtyping cannot change sized-ness.

This fixes the 4-th point/issue from #155924. Specifically, it makes this code compile:

fn blah(e: !) {
    let source = Box::new(e);
    let _: Box<dyn Send> = source;
}

This also fixes tests/ui/impl-trait/unsized_coercion.rs on new solver, see #157820 (comment).

r? types

@WaffleLapkin WaffleLapkin added F-never_type `#![feature(never_type)]` T-types Relevant to the types team, which will review and decide on the PR/issue. labels Jun 12, 2026
@rustbot

rustbot commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

changes to inspect_obligations.rs

cc @lcnr

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 12, 2026
@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs Outdated
@rust-log-analyzer

This comment was marked as off-topic.

Comment on lines +23 to +24
/// Use subtyping. [`FnCtxt::obligations_for_self_ty`] will return obligations
/// where the self type is a subtype or a supertype of the provided vid.

@WaffleLapkin WaffleLapkin Jun 12, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not quite true.

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how so?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the PR description, you can have cases where both the self type and the provided vid are sub/super types of a shared related type.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah, the sub relation is "transitively related via subtyping", which is weaker than "is sub or super type"

@lcnr lcnr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm, needs a types team FCP

View changes since this review

@lcnr

lcnr commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

This also fixes tests/ui/impl-trait/unsized_coercion.rs on new solver, although I'm not exactly sure why.

if self.type_var_is_sized(v) =>

@WaffleLapkin WaffleLapkin Jun 16, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(starting a discussion here, as to not pollute the PR comments...

@lcnr re: #157820 (comment)

That is code in the old solver though, but the fix helped with the new solver.

The relevant code is here I think:

// FIXME: structurally normalize?
if self.fcx.tcx.is_lang_item(pred.def_id(), LangItem::Unsize)
&& let ty::Dynamic(..) = pred.skip_binder().trait_ref.args.type_at(1).kind()
&& let ty::Infer(ty::TyVar(vid)) = *pred.self_ty().skip_binder().kind()
&& self.fcx.type_var_is_sized(vid)
{
// We get here when trying to unsize a type variable to a `dyn Trait`,
// knowing that that variable is sized. Unsizing definitely has to happen in that case.
// If the variable weren't sized, we may not need an unsizing coercion.
// In general, we don't want to add coercions too eagerly since it makes error messages much worse.
ControlFlow::Continue(())

But my confusion is mostly from "why was this already working in the old solver?". The answer is probably that with the new trait solver opaques introduce inference variables differently, so that the Sized goal for them can only be detected if you consider subtyping. But I don't have the knowledge to back this idea up ^^'

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

But my confusion is mostly from "why was this already working in the old solver?"

old solver doesn't eagerly replace opaque types with inference vars when normalizing, so the infer var encountered by the coercion was equal to the opaque instead of a subtype

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that encountered an infer var at all, the coercion may just have encountered the opaque directly

@WaffleLapkin WaffleLapkin added the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label Jun 16, 2026
@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@WaffleLapkin

Copy link
Copy Markdown
Member Author

Proposal

When checking if an inference variable is sized, to infer if we need to do a coercion to a trait object or not, consider subtyping. That is, when checking if ?0 is sized, instead of looking for ?1: Sized where ?0 = ?1 (via root_var(a) == root_var(b)), look for ?1: Sized where ?0 and ?1 are transitively related via subtyping (sub_unification_table_root_var(a) == sub_unification_table_root_var(b)).

That is sound, because whatever something is sized, cannot change over subtyping. A: Sized <=> B: Sized when A <: B or A :> B.

This fixes one of the breakages from making Infallible = ! (4-th issue from #155924, breaks only one crate, but this feels reasonable to support). Specifically, this change allows the following code to compile:

fn blah(e: !) {
    let source = Box::new(e);
    let _: Box<dyn Send> = source;
}

// notably this already compiled before
fn bleh(e: !) {
    let _: Box<dyn Send> = Box::new(e);
}

It also fixes tests/ui/impl-trait/unsized_coercion.rs with new solver, which previously couldn't coerce an opaque to a trait object (see #157820 (comment)):

trait Trait {}
impl Trait for u32 {}

fn hello() -> Box<impl Trait> {
    if true {
        let x = hello();
        let y: Box<dyn Trait> = x;
    }
    Box::new(1u32)
}

@lcnr

lcnr commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

For a bit more context, we never used the sub_relations for obligations_for_self_ty and doing so in general is slightly dubious. However, subtyping must not change layout, so it can also not change whether something is Sized, making this entirely correct.

We removed sub_relations in #119989 as using it in generalization made caching for the old trait solver unsound. I then added it back in #140375 for the new solver where we do track it properly.

We do need the sub_relations for opaque type handling with the new solver and for diagnostics. I don't see us ever removing this and once the old solver has been removed, I also want to change the occurs check back to use sub_relations as that is sound once old-solver caching has been removed

@rfcbot fcp merge types

@rust-rfcbot

rust-rfcbot commented Jun 18, 2026 •

Copy link
Copy Markdown
Collaborator

@lcnr has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jun 18, 2026
@BoxyUwU

BoxyUwU commented Jun 19, 2026

Copy link
Copy Markdown
Member

I feel somewhat dubious of the back and forthing of sub relations and it feels unfortunate that this FCP is us FCPing something relating to whether or not to have sub relations 😅 In general I feel somewhat nervous about committing to stuff in the old solver based off of "the new solver needs X". The new solver has changed plenty (quite recently even, eager norm :3) so it feels weird to presume how it will wind up looking once we stabilize it.

I agree that realistically we should never have subtyping affect sizedness 🤔 If that did actually exist then &&T <: &&U couldn't hold as that'd change the layout of the inner reference. In theory the only way we could support this would be if we had subtyping between a sized and an unsized type, where the unsized type's metadata is a ZST I guess?

I'm not sure how likely that is to actually be something we want :3 And, tbh, in general I would quite like to move towards a world in which subtyping never affects trait solving (e.g. fixing the current jank around higher ranked subtyping) so I would also be opposed to having such subtyping in the first place (though it remains to be seen if such a world is even workable).

With that said I think I'll tick my box, it generally aligns with where I hope subtyping winds up in the long term. Also, avoiding breakage is nice and it's fairly easy to do in this case. We can always revisit this in the future if it winds up causing problems, realistically this probably isn't a one way door even if it'd be technically breaking to stop doing this?


On an actually reviewing this PR's diff POV it seems fine to me, just needs the FCP to go through 👍

@BoxyUwU BoxyUwU added S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 19, 2026
@lcnr

lcnr commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

I'm not sure how likely that is to actually be something we want :3 And, tbh, in general I would quite like to move towards a world in which subtyping never affects trait solving (e.g. fixing the current jank around higher ranked subtyping) so I would also be opposed to having such subtyping in the first place (though it remains to be seen if such a world is even workable).

@spastorino is working on this :>

I feel somewhat dubious of the back and forthing of sub relations and it feels unfortunate that this FCP is us FCPing something relating to whether or not to have sub relations 😅 In general I feel somewhat nervous about committing to stuff in the old solver based off of "the new solver needs X". The new solver has changed plenty (quite recently even, eager norm :3) so it feels weird to presume how it will wind up looking once we stabilize it.

I agree that "new solver currently does X" is a poor argument :> it turns out getting things to work is actually hard.

I think here I feel more confident as I really just want to go back to considering sub_relations in generalization as well as doing so avoids a lot of incorrect overflow errors and even hangs when diagnostics want to print the involved types after encountering overflow

@theemathas

Copy link
Copy Markdown
Contributor

Does this interact with #156770?

@jackh726

Copy link
Copy Markdown
Member

I think the logic here is sound, but the implementation here is scary: this feels very easy to misuse with a stray UseSubtyping::Yes

@lcnr

lcnr commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Does this interact with #156770?

don't expect so, no. this is likely caused by MIR borrowck not checking sizedness in the right way

@rust-bors rust-bors Bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 6, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 6, 2026
consider subtyping when checking if an infer var is sized

That is, when checking if an inference variable (say `?0`) is sized, with this PR, we now check for obligations like `?1: Sized`, where `?0` and `?1` are transitively related via subtyping (previously we were checking for `?0 = ?1`). This is sound because subtyping cannot change sized-ness.

This fixes the 4-th point/issue from rust-lang#155924. Specifically, it makes this code compile:

```rust
fn blah(e: !) {
    let source = Box::new(e);
    let _: Box<dyn Send> = source;
}
```

This also fixes `tests/ui/impl-trait/unsized_coercion.rs` on new solver, see rust-lang#157820 (comment).

r? types
rust-bors Bot pushed a commit that referenced this pull request Jul 6, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #156976 (enable eager `param_env` norm in new solver)
 - #158537 (Add `std::io::cursor::WriteThroughCursor`)
 - #158540 (Move `std::io::Seek` to `core::io`)
 - #157820 (consider subtyping when checking if an infer var is sized)
 - #158505 (Update POSIX edition links)
 - #158853 (Fix typo for link on nto-qnx.md)
 - #157466 (Better error message when bare type in impl parameter list)
 - #157966 (Emit a suggestion to cast the never type into a concrete type when it fails to satisfy an `impl Trait` bound)
 - #158381 (Expose debug scope of statement and terminator in rustc_public)
 - #158405 (rustc_target: Add ARMv8-M related target features)
 - #158770 (Weaken guarantee for `From<legacy::RangeInclusive> for RangeInclusive`)
 - #158820 (Fix rustdoc ICE on deprecated note in inlined re-export chain)
@rust-bors
rust-bors Bot merged commit 1d5fe4c into rust-lang:main Jul 6, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 6, 2026
rust-timer added a commit that referenced this pull request Jul 6, 2026
Rollup merge of #157820 - WaffleLapkin:sized-infer-sub, r=lcnr

consider subtyping when checking if an infer var is sized

That is, when checking if an inference variable (say `?0`) is sized, with this PR, we now check for obligations like `?1: Sized`, where `?0` and `?1` are transitively related via subtyping (previously we were checking for `?0 = ?1`). This is sound because subtyping cannot change sized-ness.

This fixes the 4-th point/issue from #155924. Specifically, it makes this code compile:

```rust
fn blah(e: !) {
    let source = Box::new(e);
    let _: Box<dyn Send> = source;
}
```

This also fixes `tests/ui/impl-trait/unsized_coercion.rs` on new solver, see #157820 (comment).

r? types
@WaffleLapkin
WaffleLapkin deleted the sized-infer-sub branch July 6, 2026 19:17
@JonathanBrouwer

Copy link
Copy Markdown
Member

@rust-timer build c173b3b

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (c173b3b): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary -0.6%, secondary 9.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
9.2% [9.2%, 9.2%] 1
Improvements ✅
(primary)
-0.6% [-0.6%, -0.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.6% [-0.6%, -0.6%] 1

Cycles

Results (secondary 6.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
6.2% [6.2%, 6.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (secondary 0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Bootstrap: 491.018s -> 489.205s (-0.37%)
Artifact size: 388.45 MiB -> 388.48 MiB (0.01%)

@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Jul 30, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 24, 2026
… r=JonathanBrouwer

stabilize never type

### This PR

- stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!)
- sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](rust-lang#155499 (comment)) and [refresher on never type fallback](rust-lang#155499 (comment)))
- makes `Infallible` an alias to `!`
- removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered)

### Cat
<img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" />

### Tracking

- rust-lang#35121
- rust-lang#148922

### FCPs

- rust-lang#123508 (comment) (stabilization plan, T-lang)
- rust-lang#155499 (comment) (never type stabilization modulo bugs, T-lang)
- rust-lang#155924 (comment) (make `Infallible = !`, T-libs)

### Related changes

- Lint bump: rust-lang#141937
- Rust 2024 edition change:
   - rust-lang#123748
   - rust-lang#123508
- Various changes to lessen the effect of the breaking changes:
   - rust-lang#157820
   - rust-lang#156047
   - rust-lang#160705
- Never type documentation changes: rust-lang#158370 (blocked on this pr)

### Experiments

- Fallback change and never type stabilization:
  - Run: rust-lang#155499 (comment)
  - Analysis: rust-lang#155499 (comment)
  - Status of backports: rust-lang#155499 (comment)
- Fallback change, never type stabilization and making `Infallible = !`: rust-lang#155500
- Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: rust-lang#155501
- Never type stabilization and `Infallible = !` change, _without_ fallback change: rust-lang#155657

---

Closes rust-lang#35121
Closes rust-lang#148922
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 24, 2026
… r=JonathanBrouwer

stabilize never type

### This PR

- stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!)
- sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](rust-lang#155499 (comment)) and [refresher on never type fallback](rust-lang#155499 (comment)))
- makes `Infallible` an alias to `!`
- removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered)

### Cat
<img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" />

### Tracking

- rust-lang#35121
- rust-lang#148922

### FCPs

- rust-lang#123508 (comment) (stabilization plan, T-lang)
- rust-lang#155499 (comment) (never type stabilization modulo bugs, T-lang)
- rust-lang#155924 (comment) (make `Infallible = !`, T-libs)

### Related changes

- Lint bump: rust-lang#141937
- Rust 2024 edition change:
   - rust-lang#123748
   - rust-lang#123508
- Various changes to lessen the effect of the breaking changes:
   - rust-lang#157820
   - rust-lang#156047
   - rust-lang#160705
- Never type documentation changes: rust-lang#158370 (blocked on this pr)

### Experiments

- Fallback change and never type stabilization:
  - Run: rust-lang#155499 (comment)
  - Analysis: rust-lang#155499 (comment)
  - Status of backports: rust-lang#155499 (comment)
- Fallback change, never type stabilization and making `Infallible = !`: rust-lang#155500
- Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: rust-lang#155501
- Never type stabilization and `Infallible = !` change, _without_ fallback change: rust-lang#155657

---

Closes rust-lang#35121
Closes rust-lang#148922
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 24, 2026
… r=JonathanBrouwer

stabilize never type

### This PR

- stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!)
- sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](rust-lang#155499 (comment)) and [refresher on never type fallback](rust-lang#155499 (comment)))
- makes `Infallible` an alias to `!`
- removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered)

### Cat
<img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" />

### Tracking

- rust-lang#35121
- rust-lang#148922

### FCPs

- rust-lang#123508 (comment) (stabilization plan, T-lang)
- rust-lang#155499 (comment) (never type stabilization modulo bugs, T-lang)
- rust-lang#155924 (comment) (make `Infallible = !`, T-libs)

### Related changes

- Lint bump: rust-lang#141937
- Rust 2024 edition change:
   - rust-lang#123748
   - rust-lang#123508
- Various changes to lessen the effect of the breaking changes:
   - rust-lang#157820
   - rust-lang#156047
   - rust-lang#160705
- Never type documentation changes: rust-lang#158370 (blocked on this pr)

### Experiments

- Fallback change and never type stabilization:
  - Run: rust-lang#155499 (comment)
  - Analysis: rust-lang#155499 (comment)
  - Status of backports: rust-lang#155499 (comment)
- Fallback change, never type stabilization and making `Infallible = !`: rust-lang#155500
- Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: rust-lang#155501
- Never type stabilization and `Infallible = !` change, _without_ fallback change: rust-lang#155657

---

Closes rust-lang#35121
Closes rust-lang#148922
rust-bors Bot pushed a commit that referenced this pull request Aug 24, 2026
…Brouwer

stabilize never type



### This PR

- stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!)
- sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](#155499 (comment)) and [refresher on never type fallback](#155499 (comment)))
- makes `Infallible` an alias to `!`
- removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered)

### Cat
<img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" />

### Tracking

- #35121
- #148922

### FCPs

- #123508 (comment) (stabilization plan, T-lang)
- #155499 (comment) (never type stabilization modulo bugs, T-lang)
- #155924 (comment) (make `Infallible = !`, T-libs)

### Related changes

- Lint bump: #141937
- Rust 2024 edition change:
   - #123748
   - #123508
- Various changes to lessen the effect of the breaking changes:
   - #157820
   - #156047
   - #160705
- Never type documentation changes: #158370 (blocked on this pr)

### Experiments

- Fallback change and never type stabilization:
  - Run: #155499 (comment)
  - Analysis: #155499 (comment)
  - Status of backports: #155499 (comment)
- Fallback change, never type stabilization and making `Infallible = !`: #155500
- Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: #155501
- Never type stabilization and `Infallible = !` change, _without_ fallback change: #155657

---

Closes #35121
Closes #148922
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 24, 2026
… r=JonathanBrouwer

stabilize never type

### This PR

- stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!)
- sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](rust-lang#155499 (comment)) and [refresher on never type fallback](rust-lang#155499 (comment)))
- makes `Infallible` an alias to `!`
- removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered)

### Cat
<img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" />

### Tracking

- rust-lang#35121
- rust-lang#148922

### FCPs

- rust-lang#123508 (comment) (stabilization plan, T-lang)
- rust-lang#155499 (comment) (never type stabilization modulo bugs, T-lang)
- rust-lang#155924 (comment) (make `Infallible = !`, T-libs)

### Related changes

- Lint bump: rust-lang#141937
- Rust 2024 edition change:
   - rust-lang#123748
   - rust-lang#123508
- Various changes to lessen the effect of the breaking changes:
   - rust-lang#157820
   - rust-lang#156047
   - rust-lang#160705
- Never type documentation changes: rust-lang#158370 (blocked on this pr)

### Experiments

- Fallback change and never type stabilization:
  - Run: rust-lang#155499 (comment)
  - Analysis: rust-lang#155499 (comment)
  - Status of backports: rust-lang#155499 (comment)
- Fallback change, never type stabilization and making `Infallible = !`: rust-lang#155500
- Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: rust-lang#155501
- Never type stabilization and `Infallible = !` change, _without_ fallback change: rust-lang#155657

---

Closes rust-lang#35121
Closes rust-lang#148922
rust-bors Bot pushed a commit that referenced this pull request Aug 24, 2026
…Brouwer

stabilize never type



### This PR

- stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!)
- sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](#155499 (comment)) and [refresher on never type fallback](#155499 (comment)))
- makes `Infallible` an alias to `!`
- removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered)

### Cat
<img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" />

### Tracking

- #35121
- #148922

### FCPs

- #123508 (comment) (stabilization plan, T-lang)
- #155499 (comment) (never type stabilization modulo bugs, T-lang)
- #155924 (comment) (make `Infallible = !`, T-libs)

### Related changes

- Lint bump: #141937
- Rust 2024 edition change:
   - #123748
   - #123508
- Various changes to lessen the effect of the breaking changes:
   - #157820
   - #156047
   - #160705
- Never type documentation changes: #158370 (blocked on this pr)

### Experiments

- Fallback change and never type stabilization:
  - Run: #155499 (comment)
  - Analysis: #155499 (comment)
  - Status of backports: #155499 (comment)
- Fallback change, never type stabilization and making `Infallible = !`: #155500
- Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: #155501
- Never type stabilization and `Infallible = !` change, _without_ fallback change: #155657

---

Closes #35121
Closes #148922
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Aug 25, 2026
…Brouwer

stabilize never type



### This PR

- stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!)
- sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](rust-lang/rust#155499 (comment)) and [refresher on never type fallback](rust-lang/rust#155499 (comment)))
- makes `Infallible` an alias to `!`
- removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered)

### Cat
<img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" />

### Tracking

- rust-lang/rust#35121
- rust-lang/rust#148922

### FCPs

- rust-lang/rust#123508 (comment) (stabilization plan, T-lang)
- rust-lang/rust#155499 (comment) (never type stabilization modulo bugs, T-lang)
- rust-lang/rust#155924 (comment) (make `Infallible = !`, T-libs)

### Related changes

- Lint bump: rust-lang/rust#141937
- Rust 2024 edition change:
   - rust-lang/rust#123748
   - rust-lang/rust#123508
- Various changes to lessen the effect of the breaking changes:
   - rust-lang/rust#157820
   - rust-lang/rust#156047
   - rust-lang/rust#160705
- Never type documentation changes: rust-lang/rust#158370 (blocked on this pr)

### Experiments

- Fallback change and never type stabilization:
  - Run: rust-lang/rust#155499 (comment)
  - Analysis: rust-lang/rust#155499 (comment)
  - Status of backports: rust-lang/rust#155499 (comment)
- Fallback change, never type stabilization and making `Infallible = !`: rust-lang/rust#155500
- Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: rust-lang/rust#155501
- Never type stabilization and `Infallible = !` change, _without_ fallback change: rust-lang/rust#155657

---

Closes rust-lang/rust#35121
Closes rust-lang/rust#148922
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Aug 28, 2026
…Brouwer

stabilize never type



### This PR

- stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!)
- sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](rust-lang/rust#155499 (comment)) and [refresher on never type fallback](rust-lang/rust#155499 (comment)))
- makes `Infallible` an alias to `!`
- removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered)

### Cat
<img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" />

### Tracking

- rust-lang/rust#35121
- rust-lang/rust#148922

### FCPs

- rust-lang/rust#123508 (comment) (stabilization plan, T-lang)
- rust-lang/rust#155499 (comment) (never type stabilization modulo bugs, T-lang)
- rust-lang/rust#155924 (comment) (make `Infallible = !`, T-libs)

### Related changes

- Lint bump: rust-lang/rust#141937
- Rust 2024 edition change:
   - rust-lang/rust#123748
   - rust-lang/rust#123508
- Various changes to lessen the effect of the breaking changes:
   - rust-lang/rust#157820
   - rust-lang/rust#156047
   - rust-lang/rust#160705
- Never type documentation changes: rust-lang/rust#158370 (blocked on this pr)

### Experiments

- Fallback change and never type stabilization:
  - Run: rust-lang/rust#155499 (comment)
  - Analysis: rust-lang/rust#155499 (comment)
  - Status of backports: rust-lang/rust#155499 (comment)
- Fallback change, never type stabilization and making `Infallible = !`: rust-lang/rust#155500
- Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: rust-lang/rust#155501
- Never type stabilization and `Infallible = !` change, _without_ fallback change: rust-lang/rust#155657

---

Closes rust-lang/rust#35121
Closes rust-lang/rust#148922
makai410 pushed a commit to makai410/rust that referenced this pull request Oct 1, 2026
…nathanBrouwer

Rollup of 12 pull requests

Successful merges:

 - rust-lang#156976 (enable eager `param_env` norm in new solver)
 - rust-lang#158537 (Add `std::io::cursor::WriteThroughCursor`)
 - rust-lang#158540 (Move `std::io::Seek` to `core::io`)
 - rust-lang#157820 (consider subtyping when checking if an infer var is sized)
 - rust-lang#158505 (Update POSIX edition links)
 - rust-lang#158853 (Fix typo for link on nto-qnx.md)
 - rust-lang#157466 (Better error message when bare type in impl parameter list)
 - rust-lang#157966 (Emit a suggestion to cast the never type into a concrete type when it fails to satisfy an `impl Trait` bound)
 - rust-lang#158381 (Expose debug scope of statement and terminator in rustc_public)
 - rust-lang#158405 (rustc_target: Add ARMv8-M related target features)
 - rust-lang#158770 (Weaken guarantee for `From<legacy::RangeInclusive> for RangeInclusive`)
 - rust-lang#158820 (Fix rustdoc ICE on deprecated note in inlined re-export chain)
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Oct 1, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#156976 (enable eager `param_env` norm in new solver)
 - rust-lang/rust#158537 (Add `std::io::cursor::WriteThroughCursor`)
 - rust-lang/rust#158540 (Move `std::io::Seek` to `core::io`)
 - rust-lang/rust#157820 (consider subtyping when checking if an infer var is sized)
 - rust-lang/rust#158505 (Update POSIX edition links)
 - rust-lang/rust#158853 (Fix typo for link on nto-qnx.md)
 - rust-lang/rust#157466 (Better error message when bare type in impl parameter list)
 - rust-lang/rust#157966 (Emit a suggestion to cast the never type into a concrete type when it fails to satisfy an `impl Trait` bound)
 - rust-lang/rust#158381 (Expose debug scope of statement and terminator in rustc_public)
 - rust-lang/rust#158405 (rustc_target: Add ARMv8-M related target features)
 - rust-lang/rust#158770 (Weaken guarantee for `From<legacy::RangeInclusive> for RangeInclusive`)
 - rust-lang/rust#158820 (Fix rustdoc ICE on deprecated note in inlined re-export chain)
dressupgeekout pushed a commit to dressupgeekout/pkgsrc-wip that referenced this pull request Oct 2, 2026
Pkgsrc changes:
 * Adapt to changes in vendored crate versions.
 * Version & checksum changes.

Upstream changes:

Version 1.99.0 (2026-10-01)
==========================

Language
--------
- [Add allow-by-default `raw_borrows_via_references` lint that
  checks for references that decay immediately into raw
  borrows](rust-lang/rust#138230)
- [Extend `unconditional_panic` lint to function calls that panic
  when the chunks/windows size is zero]
  (rust-lang/rust#153563)
- [Stabilize C-variadic function definitions]
  (rust-lang/rust#155697)
- [Stabilize the ability to use `#[unsafe(naked)]` functions to
  define C-variadic functions (`#![feature(c_variadic_naked_functions)]`).]
  (rust-lang/rust#159746)
- [Trait methods are now resolved on an adjusted never type (producing a FCW)]
  (rust-lang/rust#156047)
- [Coerce from inference variables to trait objects if the inference
  variable is related via subtyping to a type that is known to be `Sized`]
  (rust-lang/rust#157820)
- [Stabilize `#[my_macro] mod foo;`]
  (rust-lang/rust#157857). This allows
  outlined modules (`mod foo;`) anywhere in the body of a custom
  attribute or derive macro.
- [Fix the `overflowing_literals` lint with repeated negation]
  (rust-lang/rust#158302). For instance,
  it will now no longer lint on `--128_i8`, which is already detected
  by the `arithmetic_overflow` lint.
- [Add POSIX symbols to the `invalid_runtime_symbol_definitions`
  and `suspicious_runtime_symbol_definitions` lints]
  (rust-lang/rust#158522)
- [Lint unused `#[path]` attributes on inline modules]
  (rust-lang/rust#158835)
- [Enable `unreachable_cfg_select_predicates` lint as part of
  `unused` lint group] (rust-lang/rust#159179)
- [Stabilize passing 128-bit integers via vector registers with `asm!` on x86]
  (rust-lang/rust#159525)
- [Explicitly document that some allocations are allowed to grow
  in-place (but none are allowed to shrink)]
  (rust-lang/rust#159729)
- We now [guarantee]
  (rust-lang/rust#159730) that the contents
  of an `UnsafeCell` can be accessed without going through `get`
  - [The `invalid_reference_casting` lint was adjusted accordingly]
  (rust-lang/rust#159960)
- [Account for globally enabled target features in `global_asm!`]
  (rust-lang/rust#160594)
- [Warn if an invalid `doc` attribute is used on a macro invocation]
  (rust-lang/rust#161003)

Compiler
--------
- [Convert `-Ctarget-cpu` into a target-modifier for AVR, AMDGCN and NVPTX]
  (rust-lang/rust#150732)
- [Enable `static_position_independent_executables` on all gnu and musl targets]
  (rust-lang/rust#158510)
- When providing a suggestion about a missing method, rustc now
  prefers an exactly matching name from a [doc alias attribute]
  (https://doc.rust-lang.org/rustdoc/advanced-features.html#add-aliases-for-an-item-in-documentation-search)
  over a similarity search from other method names. If your new
  users sometimes expect a method under a different name, adding
  a doc alias will now help them find it via rustc suggestions, in
  addition to helping them find it via rustdoc search: [When
  suggesting method names, prefer *exact* doc aliases over similar
  names](rust-lang/rust#160369)

Platform Support
----------------
- [Promote `riscv64-unknown-linux-musl` to Tier 2 with host tools]
  (rust-lang/rust#158766)

Refer to Rust's [platform support page][platform-support-doc]
for more information on Rust's tiered platform support.

[platform-support-doc]: https://doc.rust-lang.org/rustc/platform-support.html

Libraries
---------
- Iteration on `RangeInclusive` (`a..=b` ranges) is now [optimized
  better in some circumstances]
  (rust-lang/rust#155114). As a side effect
  of this, the behavior of `RangeInclusive` values that has already
  been exhausted (as an iterator) has changed. For example, the
  return values of `start()` and `end()` on such ranges may return
  different values, and using such ranges as slice indexes may have
  different behavior. These behaviors were not guaranteed to be
  stable, so these changes are considered to not be breaking changes.
- [Relax `transmute_copy` to accept `?Sized` types]
  (rust-lang/rust#155989)
- [Update `transmute_copy` to use a non-unwinding panic]
  (rust-lang/rust#155989)
- [Don't escape U+FF9E and U+FF9F in `escape_debug_ext`]
  (rust-lang/rust#158057)
- [Re-export `core::fmt::NumBuffer` in `alloc` (and `std`)]
  (rust-lang/rust#161430)

Stabilized APIs
---------------

- [`IntoIterator` for `Box<[T; N]>`]
  (https://doc.rust-lang.org/stable/std/iter/trait.IntoIterator.html#impl-IntoIterator-for-Box%3C%5BT;+N%5D,+A%3E)
- [`IntoIterator` for `&Box<[T; N]>`]
  (https://doc.rust-lang.org/stable/std/iter/trait.IntoIterator.html#impl-IntoIterator-for-%26Box%3C%5BT;+N%5D,+A%3E)
- [`IntoIterator` for `&mut Box<[T; N]>`]
  (https://doc.rust-lang.org/stable/std/iter/trait.IntoIterator.html#impl-IntoIterator-for-%26mut+Box%3C%5BT;+N%5D,+A%3E)
- [`VecDeque::retain_back`]
  (https://doc.rust-lang.org/stable/std/collections/struct.VecDeque.html#method.retain_back)
- [`core::ffi::VaList`]
  (https://doc.rust-lang.org/stable/core/ffi/struct.VaList.html)
- [`Box::into_non_null`]
  (https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.into_non_null)
- [`Box::from_non_null`]
  (https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.from_non_null)
- [`Vec::into_parts`]
  (https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.into_parts)
- [`Vec::from_parts`]
  (https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.from_parts)
- [`core::mem::size_of_val_raw`]
  (https://doc.rust-lang.org/stable/core/mem/fn.size_of_val_raw.html)
- [`core::mem::align_of_val_raw`]
  (https://doc.rust-lang.org/stable/core/mem/fn.align_of_val_raw.html)
- [`core::alloc::Layout::for_value_raw`]
  (https://doc.rust-lang.org/stable/core/alloc/struct.Layout.html#method.for_value_raw)
- [`String::from_utf8_lossy_owned`]
  (https://doc.rust-lang.org/stable/std/string/struct.String.html#method.from_utf8_lossy_owned)
- [`string::FromUtf8Error::into_utf8_lossy`]
  (https://doc.rust-lang.org/stable/std/string/struct.FromUtf8Error.html#method.into_utf8_lossy)
- [`FusedIterator for StepBy<I>`]
  (https://doc.rust-lang.org/stable/std/iter/struct.StepBy.html#impl-FusedIterator-for-StepBy%3CI%3E)
- [`std::fs::set_times`]
  (https://doc.rust-lang.org/stable/std/fs/fn.set_times.html)
- [`std::fs::set_times_nofollow`]
  (https://doc.rust-lang.org/stable/std/fs/fn.set_times_nofollow.html)

Cargo
-----
- Add a new built-in profile `debug`. This is a preparation for
  transitioning the `dev` profile away from debugging to give a saner
  default for faster development iterations. Currently there is no
  difference between `dev` and `debug` profiles. [docs]
  (https://doc.rust-lang.org/nightly/cargo/reference/profiles.html#debug-1)
  [#17214] (rust-lang/cargo#17214)
- Workspace members on edition 2024 or later can now override an
  inherited workspace dependency's `default-features` field. For
  example, `serde = { workspace = true, default-features = false }`
  now turns off default features even when the workspace definition
  enables them. On earlier editions, `default-features = false` is
  ignored with a warning. ([RFC 3945]
  (rust-lang/rfcs#3945))
  [#17126](rust-lang/cargo#17126)
- Incremental compilation is now disabled by default when running
  in CI. CI is detected via the CI environment variable. [#17220]
  (rust-lang/cargo#17220)
  See also the [full Cargo changelog]
  (https://doc.rust-lang.org/nightly/cargo/CHANGELOG.html#cargo-199-2026-10-01)

Rustdoc
-----
- [Add new `unused_footnote_definition` rustdoc lint]
  (rust-lang/rust#137858)
- Smarter filtering of trait impls yields performance improvements
  of 20% on average and up to 40% on some real-world crates. ([1]
  (rust-lang/rust#159623),
  [2](rust-lang/rust#159721),
  [3](rust-lang/rust#159779),
  [4](rust-lang/rust#159854),
  [5](rust-lang/rust#159091))

Compatibility Notes
-------------------
- [Fully deprecate the legacy integral modules]
  (rust-lang/rust#146882). For example,
  `std::i32::MAX` should be accessed via `i32::MAX` instead.
- [Upgrade `no_mangle_generic_items` into hard error]
  (rust-lang/rust#154585)
- [The `Pin::new_unchecked` has had its safety invariants changed slightly]
  (rust-lang/rust#156935)
- [Do not promote references to extern statics]
  (rust-lang/rust#157641)
- [Ensure that the inferred types of `let` patterns typecheck]
  (rust-lang/rust#157841)
- [hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`]
  (rust-lang/rust#158247)
- [Fixed a bug where `#[repr(simd)]` was accidentally allowed on
  macro invocations on stable Rust]
  (rust-lang/rust#158523)
- [Abort const-eval when there are generics in the type of the
  value being produced]
  (rust-lang/rust#159504)
- [Attributes not applying to anything are now an error in code
  blocks in doc comments]
  (rust-lang/rust#159849)
- [`Box::leak`: tell people to avoid unleaking]
  (rust-lang/rust#160323)
- [PowerPC inline ASM: Fix scalar floats being in the wrong vector
  lane on little endian] (rust-lang/rust#160441)
- [Do not take `doc(cfg())` into account when filtering doctests]
  (rust-lang/rust#159014)
- [Infer anonymous lifetimes in the types of associated consts as `'static`]
  (rust-lang/rust#156508)
- Macros that expand to a semicolon now produce a warning lint
  (`semicolon_in_expressions_from_non_local_macros`) even when the
  macro comes from another crate. Previously, such warnings only
  appeared for macros from the same crate, to avoid showing warnings
  that can't be fixed locally; however, this masked problems, as
  integration tests from the crate providing the macro get compiled
  as a separate crate, so tests often wouldn't reveal this issue. If
  you encounter a lint like this, please make sure to report it to
  the crate providing the macro so they can fix it; don't just silence
  it in your own crate.
  - [`semicolon_in_expressions_from_macros`: Lint on non-local
    macros too] (rust-lang/rust#159222)
  - [Split non-local `semicolon_in_expressions_from_macros` into
    a separate lint] (rust-lang/rust#159700)

Internal Changes
----------------

These changes do not affect any public interfaces of Rust, but they represent
significant improvements to the performance or internals of rustc and related
tools.

- [Update to LLVM 23]
  (rust-lang/rust#158734)
ABHIRAM-CREATOR06 added a commit to ABHIRAM-CREATOR06/rust-analyzer that referenced this pull request Oct 2, 2026
When checking whether an inference variable is Sized (used during unsize coercions), 	ype_var_is_sized previously compared equality-only roots via 
oot_var. This meant that a Sized obligation on a variable related through subtyping (e.g. from Box::new(y) unsized to Box<dyn Send>) was missed, causing spurious type mismatches.

Thread a UseSubtyping flag (modeled on rust-lang/rust#157820) through obligations_for_self_ty, predicate_has_self_ty, and 	ype_matches_expected_vid. 	ype_var_is_sized passes Yes (since sizedness is preserved under subtyping), while all closure callers pass No.

Fixes rust-lang#23114
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. F-never_type `#![feature(never_type)]` finished-final-comment-period The final comment period is finished for this PR / Issue. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.