-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Remove redundant suffixes from Try (TryType, TryTrait)
#155229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -356,11 +356,11 @@ language_item_table! { | |
| SliceLen, sym::slice_len_fn, slice_len_fn, Target::Method(MethodKind::Inherent), GenericRequirement::None; | ||
|
|
||
| // Language items from AST lowering | ||
| TryTraitFromResidual, sym::from_residual, from_residual_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None; | ||
| TryTraitFromOutput, sym::from_output, from_output_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None; | ||
| TryTraitBranch, sym::branch, branch_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None; | ||
| TryTraitFromYeet, sym::from_yeet, from_yeet_fn, Target::Fn, GenericRequirement::None; | ||
| ResidualIntoTryType, sym::into_try_type, into_try_type_fn, Target::Fn, GenericRequirement::None; | ||
| TryFromResidual, sym::from_residual, from_residual_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None; | ||
| TryFromOutput, sym::from_output, from_output_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None; | ||
| TryBranch, sym::branch, branch_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None; | ||
| TryFromYeet, sym::from_yeet, from_yeet_fn, Target::Fn, GenericRequirement::None; | ||
| ResidualIntoTry, sym::into_try, into_try_fn, Target::Fn, GenericRequirement::None; | ||
|
Comment on lines
-359
to
+363
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix: this file uses vertical alignment for the columns, so please fix that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rest of the items have been misaligned all along. Do you want me to realign everything? |
||
|
|
||
| CoercePointeeValidated, sym::coerce_pointee_validated, coerce_pointee_validated_trait, Target::Trait, GenericRequirement::Exact(0); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -476,7 +476,7 @@ impl<T> Box<T> { | |||||
| pub fn try_map<R>( | ||||||
| this: Self, | ||||||
| f: impl FnOnce(T) -> R, | ||||||
| ) -> <R::Residual as Residual<Box<R::Output>>>::TryType | ||||||
| ) -> <R::Residual as Residual<Box<R::Output>>>::Try | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In core we do this using a type alias which is why that didn't need changing; should alloc switch to using that too?
Suggested change
|
||||||
| where | ||||||
| R: Try, | ||||||
| R::Residual: Residual<Box<R::Output>>, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -358,14 +358,14 @@ where | |
| /// For example, | ||
| /// `Result<T, E>: Try<Output = T, Residual = Result<Infallible, E>>`, | ||
| /// and in the other direction, | ||
| /// `<Result<Infallible, E> as Residual<T>>::TryType = Result<T, E>`. | ||
| /// `<Result<Infallible, E> as Residual<T>>::Try = Result<T, E>`. | ||
| #[unstable(feature = "try_trait_v2_residual", issue = "91285")] | ||
| #[rustc_const_unstable(feature = "const_try_residual", issue = "91285")] | ||
| pub const trait Residual<O>: Sized { | ||
| /// The "return" type of this meta-function. | ||
| #[unstable(feature = "try_trait_v2_residual", issue = "91285")] | ||
| // FIXME: ought to be implied | ||
| type TryType: [const] Try<Output = O, Residual = Self>; | ||
| type Try: [const] Try<Output = O, Residual = Self>; | ||
| } | ||
|
|
||
| /// Used in `try {}` blocks so the type produced in the `?` desugaring | ||
|
|
@@ -377,17 +377,15 @@ pub const trait Residual<O>: Sized { | |
| // needs to be `pub` to avoid `private type` errors | ||
| #[expect(unreachable_pub)] | ||
| #[inline] // FIXME: force would be nice, but fails -- see #148915 | ||
| #[lang = "into_try_type"] | ||
| pub const fn residual_into_try_type<R: [const] Residual<O>, O>( | ||
| r: R, | ||
| ) -> <R as Residual<O>>::TryType { | ||
| #[lang = "into_try"] | ||
| pub const fn residual_into_try<R: [const] Residual<O>, O>(r: R) -> <R as Residual<O>>::Try { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest just leaving this function alone. It's perma-unstable, only here for implementing the desugaring. To especially if it affects R-A, can leave it as the same lang item. |
||
| FromResidual::from_residual(r) | ||
| } | ||
|
|
||
| #[unstable(feature = "pub_crate_should_not_need_unstable_attr", issue = "none")] | ||
| #[allow(type_alias_bounds)] | ||
| pub(crate) type ChangeOutputType<T: Try<Residual: Residual<V>>, V> = | ||
| <T::Residual as Residual<V>>::TryType; | ||
| <T::Residual as Residual<V>>::Try; | ||
|
|
||
| /// An adapter for implementing non-try methods via the `Try` implementation. | ||
| /// | ||
|
|
@@ -463,7 +461,7 @@ impl<T> const FromResidual for NeverShortCircuit<T> { | |
| } | ||
| #[rustc_const_unstable(feature = "const_never_short_circuit", issue = "none")] | ||
| impl<T: [const] Destruct> const Residual<T> for NeverShortCircuitResidual { | ||
| type TryType = NeverShortCircuit<T>; | ||
| type Try = NeverShortCircuit<T>; | ||
| } | ||
|
|
||
| /// Implement `FromResidual<Yeet<T>>` on your type to enable | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
If you're going to update, might as well make it actually correct, since it's not part of
Residualany more.View changes since the review