Remove redundant suffixes from Try (TryType, TryTrait)#155229
Remove redundant suffixes from Try (TryType, TryTrait)#155229nxsaken wants to merge 3 commits intorust-lang:mainfrom
Try (TryType, TryTrait)#155229Conversation
|
Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
This comment has been minimized.
This comment has been minimized.
|
Let me check my intuition. I need to add the renamed lang item symbol ( ResidualIntoTry, sym::into_try, FunctionId;
ResidualIntoTryOld, sym::into_try_type, FunctionId;and then, this: Some(TryBlock::Homogeneous { .. }) => {
self.lang_path(lang_items.ResidualIntoTry)
}seems to be the only mention of If this is correct, I should only do it in rust-analyzer, not in the compiler? And how can someone tell when it's safe to remove? |
|
The main concern is that rust-analyzer should work with both old and new versions of the standard library. The compiler only needs to support the matching one.
Yes.
Add a comment like "// TODO: change [stuff, maybe point to your commit] when dropping support for 1.95" (or whatever is the last stable toolchain that uses the old names). |
3908d69 to
69f2576
Compare
| 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 { |
There was a problem hiding this comment.
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.
| /// #[allow(unreachable_code)] | ||
| /// // If there is an enclosing `try {...}`: | ||
| /// break 'catch_target Residual::into_try_type(residual), | ||
| /// break 'catch_target Residual::into_try(residual), |
There was a problem hiding this comment.
If you're going to update, might as well make it actually correct, since it's not part of Residual any more.
| this: Self, | ||
| f: impl FnOnce(T) -> R, | ||
| ) -> <R::Residual as Residual<Box<R::Output>>>::TryType | ||
| ) -> <R::Residual as Residual<Box<R::Output>>>::Try |
There was a problem hiding this comment.
In core we do this using a type alias which is why that didn't need changing; should alloc switch to using that too?
| ) -> <R::Residual as Residual<Box<R::Output>>>::Try | |
| ) -> ChangeOutputType<R, Box<R::Output>> |
| 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; |
There was a problem hiding this comment.
fix: this file uses vertical alignment for the columns, so please fix that.
There was a problem hiding this comment.
The rest of the items have been misaligned all along. Do you want me to realign everything?
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
Feature:
try_trait_v2_residual(#91285)The main part is renaming
Residual::TryTypeintoTry(+residual_into_try_typeintoresidual_into_try) to reflect the symmetry betweenTry::Residual: ResidualandResidual::Try: Try. I went ahead and changed all similar references except fortry_trait*(there it makes sense because it distinguishes the trait feature from the block feature and prevents clashing with the keyword).r? @scottmcm