GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Require that a `<_ as Try>::Residual` implement the `Residual` trait by scottmcm · Pull Request #154451 · rust-lang/rust

Conversation

@scottmcm

@scottmcm scottmcm commented Mar 27, 2026

Copy link
Copy Markdown
Member

The Residual trait was even more experimental than Try, but now that rust-lang/rfcs#3721 is merged, I think it would make sense to require this. Technically it's not strictly required, but without it something working on <T: Try> might need an extra bound even to use a homogeneous try block with the same output type as T::Output. (Another where will of course be needed to return a different impl Try type still.)

cc #154391

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rustbot rustbot added 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 Mar 27, 2026
scottmcm
scottmcm commented Mar 27, 2026
View reviewed changes
Comment thread library/core/src/ops/try_trait.rs
/// "foo-ness" of the residual so other types need to opt-in to interconversion.
#[unstable(feature = "try_trait_v2", issue = "84277", old_name = "try_trait")]
type Residual;
type Residual: Residual<Self::Output>;

@scottmcm scottmcm Mar 27, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

There's a more nuanced conversation about whether this should go further and also require

Suggested change
type Residual: Residual<Self::Output>;
type Residual: Residual<Self::Output, TryType = Self>;

but that has a variety of implications, so I'd rather leave it for another time rather than this PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@joshtriplett joshtriplett Apr 14, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@scottmcm Where is that further step being discussed? And what are those implications?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nxsaken nxsaken Apr 14, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

IIUC, this would force Residuals to be truly colored. It's not enforced now, so, e.g., Poll currently shares a Residual with Result (Result<Infallible, E>). Someone can ? a Poll in a function returning Result without a specific FromResidual<R> impl:

fn foo() -> Result<u8, bool> {
    core::task::Poll::<Result<u16, bool>>::Ready(Ok(0))?;
    Ok(1)
}

I guess that's not desirable because it's unexpected. If Poll had its own Residual, it would take a deliberate impl FromResidual<Poll<Result<Infallible, E>>> for Result<T, E> for the above to work.

I'm also curious to see the discussions.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@scottmcm scottmcm Apr 16, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I made #155368 as a place to have the discussion.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rust-log-analyzer

This comment has been minimized.

Sign in to view
@scottmcm
scottmcm force-pushed the require-residual branch from d1b48a0 to 0dcf324 Compare March 28, 2026 02:59
@rust-log-analyzer

This comment has been minimized.

Sign in to view
@scottmcm
scottmcm force-pushed the require-residual branch from 0dcf324 to 898972a Compare March 28, 2026 04:58
@scottmcm
scottmcm marked this pull request as ready for review March 28, 2026 09:26
@rustbot

rustbot commented Mar 28, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 28, 2026
@rustbot rustbot assigned petrochenkov Mar 28, 2026
@rustbot

rustbot commented Mar 28, 2026

Copy link
Copy Markdown
Collaborator

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 12 candidates
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@petrochenkov

petrochenkov commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

r? library

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rustbot

rustbot commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

Failed to set assignee to library: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@petrochenkov

petrochenkov commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

r? libs

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rustbot rustbot assigned jhpratt and unassigned petrochenkov Apr 7, 2026
@jhpratt

jhpratt commented Apr 9, 2026

Copy link
Copy Markdown
Member

cc @rust-lang/libs-api

r=me on implementation, but it's a design decision for you. imo it's more than reasonable to add this bound.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nxsaken
nxsaken reviewed Apr 11, 2026
View reviewed changes
Comment thread library/core/src/ops/try_trait.rs
/// "foo-ness" of the residual so other types need to opt-in to interconversion.
#[unstable(feature = "try_trait_v2", issue = "84277", old_name = "try_trait")]
type Residual;
type Residual: Residual<Self::Output>;

@nxsaken nxsaken Apr 11, 2026 •
edited by rustbot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

View changes since the review

Suggested change
type Residual: Residual<Self::Output>;
type Residual: [const] Residual<Self::Output>;

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@scottmcm scottmcm Apr 16, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This needs more changes than just this so I'll leave it for a follow-up.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@scottmcm scottmcm added T-libs-api [DEPRECATED; DO NOT USE] I-libs-api-nominated [DEPRECATED; DO NOT USE] labels Apr 12, 2026
@nia-e

nia-e commented Apr 15, 2026

Copy link
Copy Markdown
Member

Per the discussion in the last @rust-lang/libs-api meeting, we're happy to defer to @scottmcm on the details here and the idea seems sound. Thanks ^^

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nia-e nia-e removed the I-libs-api-nominated [DEPRECATED; DO NOT USE] label Apr 15, 2026
@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Apr 16, 2026
@rust-log-analyzer

This comment has been minimized.

Sign in to view
@scottmcm
Require that a <_ as Try>::Residual implement Residual
3efcdbc
The `Residual` trait was even more experimental than `Try`, but now that RFC3721 is merged, I think it would make sense to require this.
@scottmcm
scottmcm force-pushed the require-residual branch from c3021c3 to 3efcdbc Compare April 16, 2026 01:10
@rustbot

rustbot commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@scottmcm

scottmcm commented Apr 16, 2026

Copy link
Copy Markdown
Member Author

@bors r=jhpratt

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rust-bors

rust-bors Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 3efcdbc has been approved by jhpratt

It is now in the queue for this repository.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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 Apr 16, 2026
@jhpratt jhpratt mentioned this pull request Apr 16, 2026
Rollup of 18 pull requests #155380
Merged
rust-bors Bot pushed a commit that referenced this pull request Apr 16, 2026
@bors
Auto merge of #155380 - jhpratt:rollup-j1e7DVL, r=jhpratt
7af3402
Rollup of 18 pull requests

Successful merges:

 - #154451 (Require that a `<_ as Try>::Residual` implement the `Residual` trait)
 - #154595 (Emit fatal on invalid const args with nested defs)
 - #154599 (report the `varargs_without_pattern` lint in deps)
 - #154699 (`core::unicode`: Replace `Cased` table with `Lt`)
 - #155353 (resolve: Remove `inaccessible_ctor_reexport` resolver field)
 - #155357 (Add `--remap-path-scope` as unstable in rustdoc)
 - #150649 (clippy fix: non_canonical_clone_impl)
 - #154604 (abort in core)
 - #154616 (Add `--quiet` flag to x.py and bootstrap to suppress output)
 - #155215 (Clean up `AttributeLintKind` and refactor diagnostic attribute linting)
 - #155228 (Check diagnostic output in incremental `cpass` and `rpass` revisions)
 - #155266 (Adjust release notes for post-merge feedback)
 - #155326 (Disallow ZST allocations with `TypedArena`.)
 - #155334 (docs: Use `0b1` instead of `NonZero::MIN` in `NonZero::bit_width` doctests)
 - #155340 (Handle nonnull pattern types in size skeleton)
 - #155347 (Add push_mut and new Layout methods to release notes)
 - #155356 (remove calls to AliasTyKind::def_id)
 - #155364 (Reduce diagnostic type visibilities.)
@rust-bors
rust-bors Bot merged commit 89cca04 into rust-lang:main Apr 16, 2026
11 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@rustbot rustbot added this to the 1.97.0 milestone Apr 16, 2026
rust-timer added a commit that referenced this pull request Apr 16, 2026
@rust-timer
Unrolled build for #154451
4c1b466
Rollup merge of #154451 - scottmcm:require-residual, r=jhpratt

Require that a `<_ as Try>::Residual` implement the `Residual` trait

The `Residual` trait was even more experimental than `Try`, but now that rust-lang/rfcs#3721 is merged, I think it would make sense to require this.  Technically it's not strictly required, but without it something working on `<T: Try>` might need an extra bound even to use a homogeneous try block with the same output type as `T::Output`.  (Another `where` will of course be needed to return a *different* `impl Try` type still.)

cc #154391
zihan0822 pushed a commit to zihan0822/rust-clippy that referenced this pull request Apr 30, 2026
@bors
Auto merge of #155380 - jhpratt:rollup-j1e7DVL, r=jhpratt
8bc1aa3
Rollup of 18 pull requests

Successful merges:

 - rust-lang/rust#154451 (Require that a `<_ as Try>::Residual` implement the `Residual` trait)
 - rust-lang/rust#154595 (Emit fatal on invalid const args with nested defs)
 - rust-lang/rust#154599 (report the `varargs_without_pattern` lint in deps)
 - rust-lang/rust#154699 (`core::unicode`: Replace `Cased` table with `Lt`)
 - rust-lang/rust#155353 (resolve: Remove `inaccessible_ctor_reexport` resolver field)
 - rust-lang/rust#155357 (Add `--remap-path-scope` as unstable in rustdoc)
 - rust-lang/rust#150649 (clippy fix: non_canonical_clone_impl)
 - rust-lang/rust#154604 (abort in core)
 - rust-lang/rust#154616 (Add `--quiet` flag to x.py and bootstrap to suppress output)
 - rust-lang/rust#155215 (Clean up `AttributeLintKind` and refactor diagnostic attribute linting)
 - rust-lang/rust#155228 (Check diagnostic output in incremental `cpass` and `rpass` revisions)
 - rust-lang/rust#155266 (Adjust release notes for post-merge feedback)
 - rust-lang/rust#155326 (Disallow ZST allocations with `TypedArena`.)
 - rust-lang/rust#155334 (docs: Use `0b1` instead of `NonZero::MIN` in `NonZero::bit_width` doctests)
 - rust-lang/rust#155340 (Handle nonnull pattern types in size skeleton)
 - rust-lang/rust#155347 (Add push_mut and new Layout methods to release notes)
 - rust-lang/rust#155356 (remove calls to AliasTyKind::def_id)
 - rust-lang/rust#155364 (Reduce diagnostic type visibilities.)
@ThierryBerger ThierryBerger mentioned this pull request May 23, 2026
impl Residual<()> for OperatorCancelled jbuehler23/jackdaw#278
Merged
@fmease fmease mentioned this pull request Jun 4, 2026
1.97 beta rustdoc regression: "the trait bound ... is not satisfied" #157415
Closed
@RalfJung RalfJung mentioned this pull request Jun 24, 2026
Update to latest changes in the handling of the try features minirust/specr#18
Merged
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Aug 17, 2026
@bors
Auto merge of #155380 - jhpratt:rollup-j1e7DVL, r=jhpratt
a502b0f
Rollup of 18 pull requests

Successful merges:

 - rust-lang/rust#154451 (Require that a `<_ as Try>::Residual` implement the `Residual` trait)
 - rust-lang/rust#154595 (Emit fatal on invalid const args with nested defs)
 - rust-lang/rust#154599 (report the `varargs_without_pattern` lint in deps)
 - rust-lang/rust#154699 (`core::unicode`: Replace `Cased` table with `Lt`)
 - rust-lang/rust#155353 (resolve: Remove `inaccessible_ctor_reexport` resolver field)
 - rust-lang/rust#155357 (Add `--remap-path-scope` as unstable in rustdoc)
 - rust-lang/rust#150649 (clippy fix: non_canonical_clone_impl)
 - rust-lang/rust#154604 (abort in core)
 - rust-lang/rust#154616 (Add `--quiet` flag to x.py and bootstrap to suppress output)
 - rust-lang/rust#155215 (Clean up `AttributeLintKind` and refactor diagnostic attribute linting)
 - rust-lang/rust#155228 (Check diagnostic output in incremental `cpass` and `rpass` revisions)
 - rust-lang/rust#155266 (Adjust release notes for post-merge feedback)
 - rust-lang/rust#155326 (Disallow ZST allocations with `TypedArena`.)
 - rust-lang/rust#155334 (docs: Use `0b1` instead of `NonZero::MIN` in `NonZero::bit_width` doctests)
 - rust-lang/rust#155340 (Handle nonnull pattern types in size skeleton)
 - rust-lang/rust#155347 (Add push_mut and new Layout methods to release notes)
 - rust-lang/rust#155356 (remove calls to AliasTyKind::def_id)
 - rust-lang/rust#155364 (Reduce diagnostic type visibilities.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@joshtriplett joshtriplett joshtriplett left review comments
@nxsaken nxsaken nxsaken left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@jhpratt jhpratt

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. 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. T-libs-api [DEPRECATED; DO NOT USE]

Projects

None yet

Milestone

1.97.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@scottmcm @rust-log-analyzer @rustbot @petrochenkov @jhpratt @nia-e @joshtriplett @nxsaken
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.