Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {

// `::std::ops::Try::from_output($tail_expr)`
block.expr = Some(this.wrap_in_try_constructor(
hir::LangItem::TryTraitFromOutput,
hir::LangItem::TryFromOutput,
try_span,
tail_expr,
ok_wrapped_span,
Expand Down Expand Up @@ -1972,7 +1972,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
/// ControlFlow::Break(residual) =>
/// #[allow(unreachable_code)]
/// // If there is an enclosing `try {...}`:
/// break 'catch_target Residual::into_try_type(residual),
/// break 'catch_target Residual::into_try(residual),
Copy link
Copy Markdown
Member

@scottmcm scottmcm Apr 18, 2026

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 Residual any more.

View changes since the review

/// // Otherwise:
/// return Try::from_residual(residual),
/// }
Expand All @@ -1997,7 +1997,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {

self.expr_call_lang_item_fn(
unstable_span,
hir::LangItem::TryTraitBranch,
hir::LangItem::TryBranch,
arena_vec![self; sub_expr],
)
};
Expand All @@ -2024,13 +2024,13 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {

let (constructor_item, target_id) = match self.try_block_scope {
TryBlockScope::Function => {
(hir::LangItem::TryTraitFromResidual, Err(hir::LoopIdError::OutsideLoopScope))
(hir::LangItem::TryFromResidual, Err(hir::LoopIdError::OutsideLoopScope))
}
TryBlockScope::Homogeneous(block_id) => {
(hir::LangItem::ResidualIntoTryType, Ok(block_id))
(hir::LangItem::ResidualIntoTry, Ok(block_id))
}
TryBlockScope::Heterogeneous(block_id) => {
(hir::LangItem::TryTraitFromResidual, Ok(block_id))
(hir::LangItem::TryFromResidual, Ok(block_id))
}
};
let from_residual_expr = self.wrap_in_try_constructor(
Expand Down Expand Up @@ -2088,7 +2088,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
);

let from_yeet_expr = self.wrap_in_try_constructor(
hir::LangItem::TryTraitFromYeet,
hir::LangItem::TryFromYeet,
unstable_span,
yeeted_expr,
yeeted_span,
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_hir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Member

@scottmcm scottmcm Apr 18, 2026

Choose a reason for hiding this comment

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

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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);

Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,13 +576,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
Some(ObligationCauseCode::ForLoopIterator)
}
LangItem::TryTraitFromOutput
if expr.span.is_desugaring(DesugaringKind::TryBlock) =>
{
LangItem::TryFromOutput if expr.span.is_desugaring(DesugaringKind::TryBlock) => {
// FIXME it's a try block, not a question mark
Some(ObligationCauseCode::QuestionMark)
}
LangItem::TryTraitBranch | LangItem::TryTraitFromResidual
LangItem::TryBranch | LangItem::TryFromResidual
if expr.span.is_desugaring(DesugaringKind::QuestionMark) =>
{
Some(ObligationCauseCode::QuestionMark)
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,10 @@ impl<'tcx, T> ops::Try for InterpResult<'tcx, T> {
}

impl<'tcx, T> ops::Residual<T> for InterpResult<'tcx, convert::Infallible> {
#[cfg(bootstrap)]
type TryType = InterpResult<'tcx, T>;
#[cfg(not(bootstrap))]
type Try = InterpResult<'tcx, T>;
}

impl<'tcx, T> ops::FromResidual for InterpResult<'tcx, T> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ symbols! {
into_async_iter_into_iter,
into_future,
into_iter,
into_try_type,
into_try,
intra_doc_pointers,
intrinsics,
irrefutable_let_patterns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ pub fn call_kind<'tcx>(
{
Some((CallDesugaringKind::ForLoopNext, method_args.type_at(0)))
} else if fn_call_span.desugaring_kind() == Some(DesugaringKind::QuestionMark) {
if tcx.is_lang_item(method_did, LangItem::TryTraitBranch) {
if tcx.is_lang_item(method_did, LangItem::TryBranch) {
Some((CallDesugaringKind::QuestionBranch, method_args.type_at(0)))
} else if tcx.is_lang_item(method_did, LangItem::TryTraitFromResidual) {
} else if tcx.is_lang_item(method_did, LangItem::TryFromResidual) {
Some((CallDesugaringKind::QuestionFromResidual, method_args.type_at(0)))
} else {
None
}
} else if tcx.is_lang_item(method_did, LangItem::TryTraitFromOutput)
} else if tcx.is_lang_item(method_did, LangItem::TryFromOutput)
&& fn_call_span.desugaring_kind() == Some(DesugaringKind::TryBlock)
{
Some((CallDesugaringKind::TryBlockFromOutput, method_args.type_at(0)))
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Member

@scottmcm scottmcm Apr 18, 2026

Choose a reason for hiding this comment

The 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
) -> <R::Residual as Residual<Box<R::Output>>>::Try
) -> ChangeOutputType<R, Box<R::Output>>

View changes since the review

where
R: Try,
R::Residual: Residual<Box<R::Output>>,
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ impl<T> Rc<T> {
pub fn try_map<R>(
this: Self,
f: impl FnOnce(&T) -> R,
) -> <R::Residual as Residual<Rc<R::Output>>>::TryType
) -> <R::Residual as Residual<Rc<R::Output>>>::Try
where
R: Try,
R::Residual: Residual<Rc<R::Output>>,
Expand Down Expand Up @@ -4265,7 +4265,7 @@ impl<T> UniqueRc<T> {
pub fn try_map<R>(
this: Self,
f: impl FnOnce(T) -> R,
) -> <R::Residual as Residual<UniqueRc<R::Output>>>::TryType
) -> <R::Residual as Residual<UniqueRc<R::Output>>>::Try
where
R: Try,
R::Residual: Residual<UniqueRc<R::Output>>,
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ impl<T> Arc<T> {
pub fn try_map<R>(
this: Self,
f: impl FnOnce(&T) -> R,
) -> <R::Residual as Residual<Arc<R::Output>>>::TryType
) -> <R::Residual as Residual<Arc<R::Output>>>::Try
where
R: Try,
R::Residual: Residual<Arc<R::Output>>,
Expand Down Expand Up @@ -4691,7 +4691,7 @@ impl<T> UniqueArc<T, Global> {
pub fn try_map<R>(
this: Self,
f: impl FnOnce(T) -> R,
) -> <R::Residual as Residual<UniqueArc<R::Output>>>::TryType
) -> <R::Residual as Residual<UniqueArc<R::Output>>>::Try
where
R: Try,
R::Residual: Residual<UniqueArc<R::Output>>,
Expand Down
4 changes: 1 addition & 3 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3058,9 +3058,7 @@ pub const trait Iterator {
R: Try<Output = bool, Residual: Residual<Option<Self::Item>>>,
{
#[inline]
fn check<I, V, R>(
mut f: impl FnMut(&I) -> V,
) -> impl FnMut((), I) -> ControlFlow<R::TryType>
fn check<I, V, R>(mut f: impl FnMut(&I) -> V) -> impl FnMut((), I) -> ControlFlow<R::Try>
where
V: Try<Output = bool, Residual = R>,
R: Residual<Option<I>>,
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ops/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl<B, C> const ops::FromResidual<ControlFlow<B, convert::Infallible>> for Cont
#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
#[rustc_const_unstable(feature = "const_try_residual", issue = "91285")]
impl<B, C> const ops::Residual<C> for ControlFlow<B, convert::Infallible> {
type TryType = ControlFlow<B, C>;
type Try = ControlFlow<B, C>;
}

impl<B, C> ControlFlow<B, C> {
Expand Down
14 changes: 6 additions & 8 deletions library/core/src/ops/try_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Copy link
Copy Markdown
Member

@scottmcm scottmcm Apr 18, 2026

Choose a reason for hiding this comment

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

View changes since the review

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.
///
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1860,7 +1860,7 @@ impl<T> Option<T> {
pub fn get_or_try_insert_with<'a, R, F>(
&'a mut self,
f: F,
) -> <R::Residual as Residual<&'a mut T>>::TryType
) -> <R::Residual as Residual<&'a mut T>>::Try
where
F: FnOnce() -> R,
R: Try<Output = T, Residual: Residual<&'a mut T>>,
Expand Down Expand Up @@ -2808,7 +2808,7 @@ impl<T> const ops::FromResidual<ops::Yeet<()>> for Option<T> {
#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
#[rustc_const_unstable(feature = "const_try", issue = "74935")]
impl<T> const ops::Residual<T> for Option<convert::Infallible> {
type TryType = Option<T>;
type Try = Option<T>;
}

impl<T> Option<Option<T>> {
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2203,5 +2203,5 @@ impl<T, E, F: [const] From<E>> const ops::FromResidual<ops::Yeet<E>> for Result<
#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
#[rustc_const_unstable(feature = "const_try", issue = "74935")]
impl<T, E> const ops::Residual<T> for Result<convert::Infallible, E> {
type TryType = Result<T, E>;
type Try = Result<T, E>;
}
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/matches/try_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, scrutine
// };
if let ExprKind::Call(match_fun, [try_arg]) = scrutinee.kind
&& let ExprKind::Path(match_fun_path) = match_fun.kind
&& cx.tcx.qpath_is_lang_item(match_fun_path, LangItem::TryTraitBranch)
&& cx.tcx.qpath_is_lang_item(match_fun_path, LangItem::TryBranch)
&& let ExprKind::Call(err_fun, [err_arg]) = try_arg.kind
&& err_fun.res(cx).ctor_parent(cx).is_lang_item(cx, ResultErr)
&& let Some(return_ty) = find_return_type(cx, &expr.kind)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/methods/clone_on_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>)
ExprKind::Call(hir_callee, [_]) => matches!(
hir_callee.kind,
ExprKind::Path(qpath)
if cx.tcx.qpath_is_lang_item(qpath, rustc_hir::LangItem::TryTraitBranch)
if cx.tcx.qpath_is_lang_item(qpath, rustc_hir::LangItem::TryBranch)
),
ExprKind::MethodCall(_, self_arg, ..) if expr.hir_id == self_arg.hir_id => true,
ExprKind::Match(_, _, MatchSource::TryDesugar(_) | MatchSource::AwaitDesugar)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/methods/str_splitn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ fn parse_iter_usage<'tcx>(
..
},
[_],
) if cx.tcx.qpath_is_lang_item(qpath, LangItem::TryTraitBranch) => {
) if cx.tcx.qpath_is_lang_item(qpath, LangItem::TryBranch) => {
let parent_span = e.span.parent_callsite().unwrap();
if parent_span.ctxt() == ctxt {
(Some(UnwrapKind::QuestionMark), parent_span)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
&& let ExprKind::Match(inner_expr_with_q, _, MatchSource::TryDesugar(_)) = &arg.kind
&& let ExprKind::Call(called, [inner_expr]) = &inner_expr_with_q.kind
&& let ExprKind::Path(qpath) = called.kind
&& cx.tcx.qpath_is_lang_item(qpath, LangItem::TryTraitBranch)
&& cx.tcx.qpath_is_lang_item(qpath, LangItem::TryBranch)
&& expr.span.eq_ctxt(inner_expr.span)
&& let expr_ty = cx.typeck_results().expr_ty(expr)
&& let inner_ty = cx.typeck_results().expr_ty(inner_expr)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/question_mark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ fn is_try_block(cx: &LateContext<'_>, bl: &Block<'_>) -> bool {
if let Some(expr) = bl.expr
&& let ExprKind::Call(callee, [_]) = expr.kind
&& let ExprKind::Path(qpath) = callee.kind
&& cx.tcx.qpath_is_lang_item(qpath, LangItem::TryTraitFromOutput)
&& cx.tcx.qpath_is_lang_item(qpath, LangItem::TryFromOutput)
{
true
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn check_final_expr<'tcx>(
// if desugar of `do yeet`, don't lint
if let ExprKind::Call(path_expr, [_]) = inner_expr.kind
&& let ExprKind::Path(qpath) = path_expr.kind
&& cx.tcx.qpath_is_lang_item(qpath, LangItem::TryTraitFromYeet)
&& cx.tcx.qpath_is_lang_item(qpath, LangItem::TryFromYeet)
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/unused_io_amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ fn unpack_call_chain<'a>(mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
fn unpack_try<'a>(cx: &LateContext<'_>, mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
while let ExprKind::Call(func, [arg_0]) = expr.kind
&& let ExprKind::Path(qpath) = func.kind
&& cx.tcx.qpath_is_lang_item(qpath, hir::LangItem::TryTraitBranch)
&& cx.tcx.qpath_is_lang_item(qpath, hir::LangItem::TryBranch)
{
expr = arg_0;
}
Expand Down
10 changes: 5 additions & 5 deletions src/tools/rust-analyzer/crates/hir-def/src/expr_store/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ impl<'db> ExprCollector<'db> {
/// `try { <stmts>; }` into `'<new_label>: { <stmts>; ::std::ops::Try::from_output(()) }`
/// and save the `<new_label>` to use it as a break target for desugaring of the `?` operator.
fn desugar_try_block(&mut self, e: BlockExpr, result_type: Option<ast::Type>) -> ExprId {
let try_from_output = self.lang_path(self.lang_items().TryTraitFromOutput);
let try_from_output = self.lang_path(self.lang_items().TryFromOutput);
let label = self.generate_new_name();
let label = self.alloc_label_desugared(Label { name: label }, AstPtr::new(&e).wrap_right());
let try_block_info = match result_type {
Expand Down Expand Up @@ -1960,7 +1960,7 @@ impl<'db> ExprCollector<'db> {
/// ControlFlow::Continue(val) => val,
/// ControlFlow::Break(residual) =>
/// // If there is an enclosing `try {...}`:
/// break 'catch_target Residual::into_try_type(residual),
/// break 'catch_target Residual::into_try(residual),
/// // If there is an enclosing `try bikeshed Ty {...}`:
/// break 'catch_target Try::from_residual(residual),
/// // Otherwise:
Expand All @@ -1969,7 +1969,7 @@ impl<'db> ExprCollector<'db> {
/// ```
fn collect_try_operator(&mut self, syntax_ptr: AstPtr<ast::Expr>, e: ast::TryExpr) -> ExprId {
let lang_items = self.lang_items();
let try_branch = self.lang_path(lang_items.TryTraitBranch);
let try_branch = self.lang_path(lang_items.TryBranch);
let cf_continue = self.lang_path(lang_items.ControlFlowContinue);
let cf_break = self.lang_path(lang_items.ControlFlowBreak);
let operand = self.collect_expr_opt(e.expr());
Expand Down Expand Up @@ -2010,10 +2010,10 @@ impl<'db> ExprCollector<'db> {
let it = self.alloc_expr(Expr::Path(Path::from(break_name)), syntax_ptr);
let convert_fn = match self.current_try_block {
Some(TryBlock::Homogeneous { .. }) => {
self.lang_path(lang_items.ResidualIntoTryType)
self.lang_path(lang_items.ResidualIntoTry.or(lang_items.ResidualIntoTryOld))
}
Some(TryBlock::Heterogeneous { .. }) | None => {
self.lang_path(lang_items.TryTraitFromResidual)
self.lang_path(lang_items.TryFromResidual)
}
};
let callee =
Expand Down
13 changes: 8 additions & 5 deletions src/tools/rust-analyzer/crates/hir-def/src/lang_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,14 @@ language_item_table! { LangItems =>
SliceLen, sym::slice_len_fn, FunctionId;

// Language items from AST lowering
TryTraitFromResidual, sym::from_residual, FunctionId;
TryTraitFromOutput, sym::from_output, FunctionId;
TryTraitBranch, sym::branch, FunctionId;
TryTraitFromYeet, sym::from_yeet, FunctionId;
ResidualIntoTryType, sym::into_try_type, FunctionId;
TryFromResidual, sym::from_residual, FunctionId;
TryFromOutput, sym::from_output, FunctionId;
TryBranch, sym::branch, FunctionId;
TryFromYeet, sym::from_yeet, FunctionId;
ResidualIntoTry, sym::into_try, FunctionId;
// TODO: remove when dropping support for the last stable toolchain using `into_try_type`,
// see https://github.com/rust-lang/rust/pull/155229
ResidualIntoTryOld, sym::into_try_type, FunctionId;

PointerLike, sym::pointer_like, TraitId;

Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ impl<'db> SourceAnalyzer<'db> {
) -> Option<Function> {
let ty = self.ty_of_expr(try_expr.expr()?)?;

let op_fn = self.lang_items(db).TryTraitBranch?;
let op_fn = self.lang_items(db).TryBranch?;
// HACK: subst for `branch()` coincides with that for `Try` because `branch()` itself
// doesn't have any generic parameters, so we skip building another subst for `branch()`.
let substs = GenericArgs::new_from_slice(&[ty.into()]);
Expand Down
Loading
Loading