Skip to content

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

Open
scottmcm wants to merge 1 commit intorust-lang:mainfrom
scottmcm:require-residual
Open

Require that a <_ as Try>::Residual implement the Residual trait#154451
scottmcm wants to merge 1 commit intorust-lang:mainfrom
scottmcm:require-residual

Conversation

@scottmcm
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

@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
/// "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>;
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.

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.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

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 marked this pull request as ready for review March 28, 2026 09:26
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 28, 2026

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@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
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 28, 2026

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

@petrochenkov
Copy link
Copy Markdown
Contributor

r? library

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 7, 2026

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.

@petrochenkov
Copy link
Copy Markdown
Contributor

r? libs

@rustbot rustbot assigned jhpratt and unassigned petrochenkov Apr 7, 2026
@jhpratt
Copy link
Copy Markdown
Member

jhpratt commented Apr 9, 2026

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.

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

Labels

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. 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.

5 participants