Skip to content

Proof of Concept: enforced homogeneity for Try (& Poll) - #163637

Draft
MusicalNinjaDad wants to merge 9 commits into
rust-lang:mainfrom
MusicalNinjaDad:try_poll
Draft

MusicalNinjaDad wants to merge 9 commits into
rust-lang:mainfrom
MusicalNinjaDad:try_poll

Conversation

@MusicalNinjaDad

@MusicalNinjaDad MusicalNinjaDad commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

This is a draft PR targeted at a crater run to validate the viability of enforcing homogeneity for Try. See #155368, #84277 & rust-lang/goals#654.

If successful, this will feed into a near-future design meeting on the key open points for stabilising Try. I will organise a design meeting once the crater results are available.

Requesting a crater run to validate the following points

homogeneous Poll

This is not expected to produce any regressions in stable code.

? desugaring has been gated to use non-homogeneous Poll unless feature(try_trait_v2) is enabled. See zulip: #t-lang/try > impl Try for std::task::Poll for more details & discussion.

Iterator::try_fold

Potential source of regression, low risk.

try_fold is currently stable and names the unstable trait Try in its signature, this means that gated ? desugaring cannot be leveraged. There is a potential for crater regressions in the case that try_fold is used on an iterator of Poll<Result<_,_> or Poll<Option<Result<_,_>>; I cannot conceive a viable use-case for doing this as it would require silently ignoring & throwing away any Pending/Ready(None) cases during folding.

enforced homogeneity

This is not expected to produce any regressions in stable code.

Only stdlib can name Try etc in stable code. x test passes locally, any regressions should be caught by the full CI test run & bors build before crater.

TODOs - this is a draft PR for the following reasons

  • decision (design meeting TBC): if taking this approach stabilisation of Try is fixed to an edition boundary. All unstable try_... features should not stabilise before try_trait_v2
  • decision (design meeting TBC): is enforced homogeneity desirable?
  • decision (design meeting TBC): Is Poll homogeneity desirable (feedback from tokio is "yes, but only on an edition boundary")?
  • fix compiler output for legacy desugaring. This is temporarily adjusted to the (unsuitable) output produced by this change to allow for validation of the underlying approach.
  • fix try_trait_v2 flagged as unused if only needed for desugaring
  • consistent naming (old vs legacy vs not-intending-to-open-for-bikeshedding)
  • update rust-analyzer (symbols)

LLM statement

Confirmed no LLM usage.

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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. labels Oct 2, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@MusicalNinjaDad
MusicalNinjaDad force-pushed the try_poll branch 2 times, most recently from e8af9c3 to 4a64637 Compare October 3, 2026 10:20
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

traits with associated lang items
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added A-CI Area: Our Github Actions CI T-clippy Relevant to the Clippy team. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Oct 5, 2026
@rust-log-analyzer

This comment has been minimized.

@tmandry

tmandry commented Oct 5, 2026

Copy link
Copy Markdown
Member

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 5, 2026
@rust-bors

rust-bors Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 35f304e (35f304e0e45f840db2524fae65670886a86bf6ba)
Base parent: ea13733 (ea137335b78829b4514bf1b4c16302f74fab8581)

FIXME this needs to be reverted and done properly if the overall approach is sound
try_fold is stable but relies on unstable trait Try.
add a dedicated qmark! macro which performs future
desugaring in a stable context.

This is sound because only stdlib can name and use
Try in a stable context. All third-party
implementations of try_fold must be unstable and make
use of feature(try_trait_v2) in order to name Try.

This does not introduce any new risks, any adjustments
to unstable `Try` already need to consider the impact
on try_fold. All other try_xxx methods in stdlib are
unstable.
to explicitly use modern desugaring
to use qmark!

get_or_try_insert_with is currently unstable and
is the only such method which relies on `?`. All
other unstable `try_xxx` methods manually implement
a match on Try::branch.
@MusicalNinjaDad MusicalNinjaDad changed the title Try poll Proof of Concept: enforced homogeneity for Try (& Poll) Oct 6, 2026
@MusicalNinjaDad

Copy link
Copy Markdown
Contributor Author

r? @tmandry can you please set up a crater run for this.

Thanks!

@tmandry

tmandry commented Oct 6, 2026

Copy link
Copy Markdown
Member

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 6, 2026
Proof of Concept: enforced homogeneity for Try (& Poll)
@rust-bors

rust-bors Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 8773d2c (8773d2c75a8e90130dcce745a7ec4e66bb9963db)
Base parent: 8d1a764 (8d1a76430406c877b35d0b627e7f796dcf0dfeca)

@tmandry

tmandry commented Oct 7, 2026

Copy link
Copy Markdown
Member

@craterbot run mode=check-only start=8d1a76430406c877b35d0b627e7f796dcf0dfeca+rustflags=-Aunfulfilled-lint-expectations end=8773d2c75a8e90130dcce745a7ec4e66bb9963db+rustflags=-Aunfulfilled-lint-expectations

-Aunfulfilled-lint-expectations requested by the author to filter out lint related noise due to the current state of the PR.

@craterbot

Copy link
Copy Markdown
Collaborator

👌 Experiment pr-163637 created and queued.
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 7, 2026
@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #164005) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

This branch has not been deployed

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

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-CI Area: Our Github Actions CI S-waiting-on-crater Status: Waiting on a crater run to be completed. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure 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.

Crater run for homogenous Poll

5 participants