Skip to content

Force the correct type variable to never for method resolution on an adjusted never type - #163450

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
JonathanBrouwer:fix-never
Sep 29, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
JonathanBrouwer:fix-never

Conversation

@JonathanBrouwer

@JonathanBrouwer JonathanBrouwer commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Fixes the problem described in https://rust-lang.zulipchat.com/#narrow/channel/618216-t-types.2Fcall-for-participation/topic/method.20call.20on.20diverging.20infer.20doesn.27t.20constrain.20to.20never/near/627440568

The reason that the old code didn't work, as far as I understand, is that the subtype constraint root_ty <: ty is only evaluated after ty is unioned with &_, causing a mismatched type error when &_ is then given the subtype constraint.

This is fixed by demanding ty, rather than root_ty to be equal to never.

I asked lcnr whether they think there's a way to reproduce this on the old trait solver, they were unsure and I also am.
I think to be safe we should backport this to 1.100, since the never type stabilization is in 1.100 and there might be a way to break this code then.

r? @lcnr
cc @WaffleLapkin

@JonathanBrouwer JonathanBrouwer added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Sep 28, 2026
@rustbot rustbot added 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. labels Sep 28, 2026
@JonathanBrouwer JonathanBrouwer added T-types Relevant to the types team, which will review and decide on the PR/issue. beta-nominated Nominated for backporting to the compiler in the beta channel. and removed beta-nominated Nominated for backporting to the compiler in the beta channel. labels Sep 28, 2026
@lcnr

lcnr commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

📌 Commit f3b6502 has been tentatively approved by lcnr

It will be put into the queue for this repository once PR CI succeeds.

@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 Sep 28, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 28, 2026
Force the correct type variable to never for method resolution on an adjusted never type

Fixes the problem described in https://rust-lang.zulipchat.com/#narrow/channel/618216-t-types.2Fcall-for-participation/topic/method.20call.20on.20diverging.20infer.20doesn.27t.20constrain.20to.20never/near/627440568

The reason that the old code didn't work, as far as I understand, is that the subtype constraint `root_ty <: ty` is only evaluated after `ty` is unioned with `&_`, causing a `mismatched type` error when `&_` is then given the subtype constraint.

This is fixed by demanding `ty`, rather than `root_ty` to be equal to never.

I asked lcnr whether they think there's a way to reproduce this on the old trait solver, they were unsure and I also am.
I think to be safe we should backport this to 1.100, since the never type stabilization is in 1.100 and there might be a way to break this code then.

r? @lcnr
cc @WaffleLapkin
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 28, 2026
Force the correct type variable to never for method resolution on an adjusted never type

Fixes the problem described in https://rust-lang.zulipchat.com/#narrow/channel/618216-t-types.2Fcall-for-participation/topic/method.20call.20on.20diverging.20infer.20doesn.27t.20constrain.20to.20never/near/627440568

The reason that the old code didn't work, as far as I understand, is that the subtype constraint `root_ty <: ty` is only evaluated after `ty` is unioned with `&_`, causing a `mismatched type` error when `&_` is then given the subtype constraint.

This is fixed by demanding `ty`, rather than `root_ty` to be equal to never.

I asked lcnr whether they think there's a way to reproduce this on the old trait solver, they were unsure and I also am.
I think to be safe we should backport this to 1.100, since the never type stabilization is in 1.100 and there might be a way to break this code then.

r? @lcnr
cc @WaffleLapkin
rust-bors Bot pushed a commit that referenced this pull request Sep 28, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #158936 (Add `std::fs::{Home|Media}Dirs`)
 - #129036 (Additional NonZero conversions)
 - #158997 (Avoid recording unnameable `extern crate` aliases in diagnostic metadata)
 - #161015 (Stabilize `funnel_shifts` (including `const`))
 - #161712 (Stabilize `Result::into_{ok,err}`)
 - #162493 (Add support for -Zsanitizer-cfi-minimal-runtime)
 - #162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - #162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - #163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - #163331 (Move `Arc` and `Rc` into `rcs` mod)
 - #163427 (implement #![feature(gca_adts)])
 - #163428 (do not complain about unstable target features on nightly)
 - #163444 (Add `stable_rustc` helper in `run-make-support`)
 - #163447 (Allow using different index types when reading and writing to tables)
 - #163450 (Force the correct type variable to never for method resolution on an adjusted never type)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 29, 2026
Force the correct type variable to never for method resolution on an adjusted never type

Fixes the problem described in https://rust-lang.zulipchat.com/#narrow/channel/618216-t-types.2Fcall-for-participation/topic/method.20call.20on.20diverging.20infer.20doesn.27t.20constrain.20to.20never/near/627440568

The reason that the old code didn't work, as far as I understand, is that the subtype constraint `root_ty <: ty` is only evaluated after `ty` is unioned with `&_`, causing a `mismatched type` error when `&_` is then given the subtype constraint.

This is fixed by demanding `ty`, rather than `root_ty` to be equal to never.

I asked lcnr whether they think there's a way to reproduce this on the old trait solver, they were unsure and I also am.
I think to be safe we should backport this to 1.100, since the never type stabilization is in 1.100 and there might be a way to break this code then.

r? @lcnr
cc @WaffleLapkin
rust-bors Bot pushed a commit that referenced this pull request Sep 29, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - #162832 (add `Div` and `Mul` for `Complex<{float}>`)
 - #162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - #163024 (Add `Dir` equivalents of `fs::metadata` & `fs::symlink_metadata`)
 - #163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - #163210 (std: split stack overflow module)
 - #163331 (Move `Arc` and `Rc` into `rcs` mod)
 - #163183 (Add .seek_read_buf_exact() to std::os::windows::fs::FileExt)
 - #163450 (Force the correct type variable to never for method resolution on an adjusted never type)
rust-bors Bot pushed a commit that referenced this pull request Sep 29, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #158997 (Avoid recording unnameable `extern crate` aliases in diagnostic metadata)
 - #162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - #162832 (add `Div` and `Mul` for `Complex<{float}>`)
 - #162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - #163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - #163210 (std: split stack overflow module)
 - #163331 (Move `Arc` and `Rc` into `rcs` mod)
 - #163183 (Add .seek_read_buf_exact() to std::os::windows::fs::FileExt)
 - #163450 (Force the correct type variable to never for method resolution on an adjusted never type)
@rust-bors
rust-bors Bot merged commit 38506f8 into rust-lang:main Sep 29, 2026
13 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Sep 29, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 29, 2026
Rollup merge of #163450 - JonathanBrouwer:fix-never, r=lcnr

Force the correct type variable to never for method resolution on an adjusted never type

Fixes the problem described in https://rust-lang.zulipchat.com/#narrow/channel/618216-t-types.2Fcall-for-participation/topic/method.20call.20on.20diverging.20infer.20doesn.27t.20constrain.20to.20never/near/627440568

The reason that the old code didn't work, as far as I understand, is that the subtype constraint `root_ty <: ty` is only evaluated after `ty` is unioned with `&_`, causing a `mismatched type` error when `&_` is then given the subtype constraint.

This is fixed by demanding `ty`, rather than `root_ty` to be equal to never.

I asked lcnr whether they think there's a way to reproduce this on the old trait solver, they were unsure and I also am.
I think to be safe we should backport this to 1.100, since the never type stabilization is in 1.100 and there might be a way to break this code then.

r? @lcnr
cc @WaffleLapkin
pull Bot pushed a commit to LeeeeeeM/miri that referenced this pull request Sep 30, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#158997 (Avoid recording unnameable `extern crate` aliases in diagnostic metadata)
 - rust-lang/rust#162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - rust-lang/rust#162832 (add `Div` and `Mul` for `Complex<{float}>`)
 - rust-lang/rust#162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - rust-lang/rust#163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - rust-lang/rust#163210 (std: split stack overflow module)
 - rust-lang/rust#163331 (Move `Arc` and `Rc` into `rcs` mod)
 - rust-lang/rust#163183 (Add .seek_read_buf_exact() to std::os::windows::fs::FileExt)
 - rust-lang/rust#163450 (Force the correct type variable to never for method resolution on an adjusted never type)
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request Sep 30, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#158997 (Avoid recording unnameable `extern crate` aliases in diagnostic metadata)
 - rust-lang/rust#162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - rust-lang/rust#162832 (add `Div` and `Mul` for `Complex<{float}>`)
 - rust-lang/rust#162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - rust-lang/rust#163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - rust-lang/rust#163210 (std: split stack overflow module)
 - rust-lang/rust#163331 (Move `Arc` and `Rc` into `rcs` mod)
 - rust-lang/rust#163183 (Add .seek_read_buf_exact() to std::os::windows::fs::FileExt)
 - rust-lang/rust#163450 (Force the correct type variable to never for method resolution on an adjusted never type)
@rustbot

rustbot commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

beta backport approved as per compiler team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle. Backport labels are handled by them.

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Oct 8, 2026
@cuviper cuviper mentioned this pull request Oct 13, 2026
@cuviper cuviper modified the milestones: 1.101.0, 1.100.0 Oct 13, 2026
@cuviper cuviper removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 13, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 13, 2026
[beta] backports

- Fix ICE for ambiguous candidates on method probing #162904
- Don't imply incorrect things about `Global` in the docs of `System` #163342
- make semicolon_in_expressions_from_non_local_macros not report-in-deps #163364
- Force the correct type variable to never for method resolution on an adjusted never type #163450
- Update LLVM submodule to latest release/23.x branch #163615
- Switch TLS implementation for wasi and bump SDK version to 34 #163809
- use the type name instead of `Self` in constructor paths again #163863
- Re-enable extension of bool return values on x86_64 #163917
- Add `synchronization` import lib to windows-gnullvm dist #163933
- fix(bootstrap/darwin): fix rpath for distributed LLD #163954

r? me
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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.

4 participants