1
Fork 0

Rollup merge of #118199 - compiler-errors:qpath, r=lcnr

Remove `HirId` from `QPath::LangItem`

Remove `HirId` from `QPath::LangItem`, since there was only *one* use-case (`ObligationCauseCode::AwaitableExpr`), which we can instead recover by walking the HIR tree.
This commit is contained in:
Guillaume Gomez 2023-11-25 19:51:55 +01:00 committed by GitHub
commit 8fb68fc3b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 45 additions and 75 deletions

View file

@ -560,7 +560,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
expr: &'hir hir::Expr<'hir>, expr: &'hir hir::Expr<'hir>,
overall_span: Span, overall_span: Span,
) -> &'hir hir::Expr<'hir> { ) -> &'hir hir::Expr<'hir> {
let constructor = self.arena.alloc(self.expr_lang_item_path(method_span, lang_item, None)); let constructor = self.arena.alloc(self.expr_lang_item_path(method_span, lang_item));
self.expr_call(overall_span, constructor, std::slice::from_ref(expr)) self.expr_call(overall_span, constructor, std::slice::from_ref(expr))
} }
@ -614,7 +614,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// Resume argument type: `ResumeTy` // Resume argument type: `ResumeTy`
let unstable_span = let unstable_span =
self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone()); self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone());
let resume_ty = hir::QPath::LangItem(hir::LangItem::ResumeTy, unstable_span, None); let resume_ty = hir::QPath::LangItem(hir::LangItem::ResumeTy, unstable_span);
let input_ty = hir::Ty { let input_ty = hir::Ty {
hir_id: self.next_id(), hir_id: self.next_id(),
kind: hir::TyKind::Path(resume_ty), kind: hir::TyKind::Path(resume_ty),
@ -818,19 +818,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
span, span,
hir::LangItem::PinNewUnchecked, hir::LangItem::PinNewUnchecked,
arena_vec![self; ref_mut_awaitee], arena_vec![self; ref_mut_awaitee],
Some(expr_hir_id),
); );
let get_context = self.expr_call_lang_item_fn_mut( let get_context = self.expr_call_lang_item_fn_mut(
gen_future_span, gen_future_span,
hir::LangItem::GetContext, hir::LangItem::GetContext,
arena_vec![self; task_context], arena_vec![self; task_context],
Some(expr_hir_id),
); );
let call = self.expr_call_lang_item_fn( let call = self.expr_call_lang_item_fn(
span, span,
hir::LangItem::FuturePoll, hir::LangItem::FuturePoll,
arena_vec![self; new_unchecked, get_context], arena_vec![self; new_unchecked, get_context],
Some(expr_hir_id),
); );
self.arena.alloc(self.expr_unsafe(call)) self.arena.alloc(self.expr_unsafe(call))
}; };
@ -843,12 +840,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let (x_pat, x_pat_hid) = self.pat_ident(gen_future_span, x_ident); let (x_pat, x_pat_hid) = self.pat_ident(gen_future_span, x_ident);
let x_expr = self.expr_ident(gen_future_span, x_ident, x_pat_hid); let x_expr = self.expr_ident(gen_future_span, x_ident, x_pat_hid);
let ready_field = self.single_pat_field(gen_future_span, x_pat); let ready_field = self.single_pat_field(gen_future_span, x_pat);
let ready_pat = self.pat_lang_item_variant( let ready_pat = self.pat_lang_item_variant(span, hir::LangItem::PollReady, ready_field);
span,
hir::LangItem::PollReady,
ready_field,
Some(expr_hir_id),
);
let break_x = self.with_loop_scope(loop_node_id, move |this| { let break_x = self.with_loop_scope(loop_node_id, move |this| {
let expr_break = let expr_break =
hir::ExprKind::Break(this.lower_loop_destination(None), Some(x_expr)); hir::ExprKind::Break(this.lower_loop_destination(None), Some(x_expr));
@ -859,12 +851,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// `::std::task::Poll::Pending => {}` // `::std::task::Poll::Pending => {}`
let pending_arm = { let pending_arm = {
let pending_pat = self.pat_lang_item_variant( let pending_pat = self.pat_lang_item_variant(span, hir::LangItem::PollPending, &[]);
span,
hir::LangItem::PollPending,
&[],
Some(expr_hir_id),
);
let empty_block = self.expr_block_empty(span); let empty_block = self.expr_block_empty(span);
self.arm(pending_pat, empty_block) self.arm(pending_pat, empty_block)
}; };
@ -922,7 +909,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
span, span,
hir::LangItem::IntoFutureIntoFuture, hir::LangItem::IntoFutureIntoFuture,
arena_vec![self; expr], arena_vec![self; expr],
Some(expr_hir_id),
); );
// match <into_future_expr> { // match <into_future_expr> {
@ -1379,8 +1365,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn lower_expr_range_closed(&mut self, span: Span, e1: &Expr, e2: &Expr) -> hir::ExprKind<'hir> { fn lower_expr_range_closed(&mut self, span: Span, e1: &Expr, e2: &Expr) -> hir::ExprKind<'hir> {
let e1 = self.lower_expr_mut(e1); let e1 = self.lower_expr_mut(e1);
let e2 = self.lower_expr_mut(e2); let e2 = self.lower_expr_mut(e2);
let fn_path = let fn_path = hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, self.lower_span(span));
hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, self.lower_span(span), None);
let fn_expr = self.arena.alloc(self.expr(span, hir::ExprKind::Path(fn_path))); let fn_expr = self.arena.alloc(self.expr(span, hir::ExprKind::Path(fn_path)));
hir::ExprKind::Call(fn_expr, arena_vec![self; e1, e2]) hir::ExprKind::Call(fn_expr, arena_vec![self; e1, e2])
} }
@ -1421,7 +1406,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
); );
hir::ExprKind::Struct( hir::ExprKind::Struct(
self.arena.alloc(hir::QPath::LangItem(lang_item, self.lower_span(span), None)), self.arena.alloc(hir::QPath::LangItem(lang_item, self.lower_span(span))),
fields, fields,
None, None,
) )
@ -1590,7 +1575,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
head_span, head_span,
hir::LangItem::IteratorNext, hir::LangItem::IteratorNext,
arena_vec![self; ref_mut_iter], arena_vec![self; ref_mut_iter],
None,
); );
let arms = arena_vec![self; none_arm, some_arm]; let arms = arena_vec![self; none_arm, some_arm];
@ -1619,7 +1603,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
head_span, head_span,
hir::LangItem::IntoIterIntoIter, hir::LangItem::IntoIterIntoIter,
arena_vec![self; head], arena_vec![self; head],
None,
) )
}; };
@ -1675,7 +1658,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
unstable_span, unstable_span,
hir::LangItem::TryTraitBranch, hir::LangItem::TryTraitBranch,
arena_vec![self; sub_expr], arena_vec![self; sub_expr],
None,
) )
}; };
@ -1880,9 +1862,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
span: Span, span: Span,
lang_item: hir::LangItem, lang_item: hir::LangItem,
args: &'hir [hir::Expr<'hir>], args: &'hir [hir::Expr<'hir>],
hir_id: Option<hir::HirId>,
) -> hir::Expr<'hir> { ) -> hir::Expr<'hir> {
let path = self.arena.alloc(self.expr_lang_item_path(span, lang_item, hir_id)); let path = self.arena.alloc(self.expr_lang_item_path(span, lang_item));
self.expr_call_mut(span, path, args) self.expr_call_mut(span, path, args)
} }
@ -1891,21 +1872,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
span: Span, span: Span,
lang_item: hir::LangItem, lang_item: hir::LangItem,
args: &'hir [hir::Expr<'hir>], args: &'hir [hir::Expr<'hir>],
hir_id: Option<hir::HirId>,
) -> &'hir hir::Expr<'hir> { ) -> &'hir hir::Expr<'hir> {
self.arena.alloc(self.expr_call_lang_item_fn_mut(span, lang_item, args, hir_id)) self.arena.alloc(self.expr_call_lang_item_fn_mut(span, lang_item, args))
} }
fn expr_lang_item_path( fn expr_lang_item_path(&mut self, span: Span, lang_item: hir::LangItem) -> hir::Expr<'hir> {
&mut self, self.expr(span, hir::ExprKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span))))
span: Span,
lang_item: hir::LangItem,
hir_id: Option<hir::HirId>,
) -> hir::Expr<'hir> {
self.expr(
span,
hir::ExprKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span), hir_id)),
)
} }
/// `<LangItem>::name` /// `<LangItem>::name`
@ -1918,7 +1890,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let path = hir::ExprKind::Path(hir::QPath::TypeRelative( let path = hir::ExprKind::Path(hir::QPath::TypeRelative(
self.arena.alloc(self.ty( self.arena.alloc(self.ty(
span, span,
hir::TyKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span), None)), hir::TyKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span))),
)), )),
self.arena.alloc(hir::PathSegment::new( self.arena.alloc(hir::PathSegment::new(
Ident::new(name, span), Ident::new(name, span),

View file

@ -2304,21 +2304,21 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
fn pat_cf_continue(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> { fn pat_cf_continue(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
let field = self.single_pat_field(span, pat); let field = self.single_pat_field(span, pat);
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowContinue, field, None) self.pat_lang_item_variant(span, hir::LangItem::ControlFlowContinue, field)
} }
fn pat_cf_break(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> { fn pat_cf_break(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
let field = self.single_pat_field(span, pat); let field = self.single_pat_field(span, pat);
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowBreak, field, None) self.pat_lang_item_variant(span, hir::LangItem::ControlFlowBreak, field)
} }
fn pat_some(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> { fn pat_some(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
let field = self.single_pat_field(span, pat); let field = self.single_pat_field(span, pat);
self.pat_lang_item_variant(span, hir::LangItem::OptionSome, field, None) self.pat_lang_item_variant(span, hir::LangItem::OptionSome, field)
} }
fn pat_none(&mut self, span: Span) -> &'hir hir::Pat<'hir> { fn pat_none(&mut self, span: Span) -> &'hir hir::Pat<'hir> {
self.pat_lang_item_variant(span, hir::LangItem::OptionNone, &[], None) self.pat_lang_item_variant(span, hir::LangItem::OptionNone, &[])
} }
fn single_pat_field( fn single_pat_field(
@ -2341,9 +2341,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
span: Span, span: Span,
lang_item: hir::LangItem, lang_item: hir::LangItem,
fields: &'hir [hir::PatField<'hir>], fields: &'hir [hir::PatField<'hir>],
hir_id: Option<hir::HirId>,
) -> &'hir hir::Pat<'hir> { ) -> &'hir hir::Pat<'hir> {
let qpath = hir::QPath::LangItem(lang_item, self.lower_span(span), hir_id); let qpath = hir::QPath::LangItem(lang_item, self.lower_span(span));
self.pat(span, hir::PatKind::Struct(qpath, fields, false)) self.pat(span, hir::PatKind::Struct(qpath, fields, false))
} }

View file

@ -445,7 +445,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
&& let hir::ExprKind::Path(hir::QPath::LangItem( && let hir::ExprKind::Path(hir::QPath::LangItem(
LangItem::IntoIterIntoIter, LangItem::IntoIterIntoIter,
_, _,
_,
)) = call_expr.kind )) = call_expr.kind
{ {
// Do not suggest `.clone()` in a `for` loop, we already suggest borrowing. // Do not suggest `.clone()` in a `for` loop, we already suggest borrowing.
@ -1346,11 +1345,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
// }; // };
// corresponding to the desugaring of a for loop `for <pat> in <head> { <body> }`. // corresponding to the desugaring of a for loop `for <pat> in <head> { <body> }`.
if let hir::ExprKind::Call(path, [arg]) = ex.kind if let hir::ExprKind::Call(path, [arg]) = ex.kind
&& let hir::ExprKind::Path(hir::QPath::LangItem( && let hir::ExprKind::Path(hir::QPath::LangItem(LangItem::IntoIterIntoIter, _)) =
LangItem::IntoIterIntoIter, path.kind
_,
_,
)) = path.kind
&& arg.span.contains(self.issue_span) && arg.span.contains(self.issue_span)
{ {
// Find `IntoIterator::into_iter(<head>)` // Find `IntoIterator::into_iter(<head>)`
@ -1368,10 +1364,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
.. ..
}) = stmt.kind }) = stmt.kind
&& let hir::ExprKind::Call(path, _args) = call.kind && let hir::ExprKind::Call(path, _args) = call.kind
&& let hir::ExprKind::Path(hir::QPath::LangItem(LangItem::IteratorNext, _, _)) = && let hir::ExprKind::Path(hir::QPath::LangItem(LangItem::IteratorNext, _)) =
path.kind path.kind
&& let hir::PatKind::Struct(path, [field, ..], _) = bind.pat.kind && let hir::PatKind::Struct(path, [field, ..], _) = bind.pat.kind
&& let hir::QPath::LangItem(LangItem::OptionSome, pat_span, _) = path && let hir::QPath::LangItem(LangItem::OptionSome, pat_span) = path
&& call.span.contains(self.issue_span) && call.span.contains(self.issue_span)
{ {
// Find `<pat>` and the span for the whole `for` loop. // Find `<pat>` and the span for the whole `for` loop.

View file

@ -2058,8 +2058,8 @@ pub enum QPath<'hir> {
/// the `X` and `Y` nodes each being a `TyKind::Path(QPath::TypeRelative(..))`. /// the `X` and `Y` nodes each being a `TyKind::Path(QPath::TypeRelative(..))`.
TypeRelative(&'hir Ty<'hir>, &'hir PathSegment<'hir>), TypeRelative(&'hir Ty<'hir>, &'hir PathSegment<'hir>),
/// Reference to a `#[lang = "foo"]` item. `HirId` of the inner expr. /// Reference to a `#[lang = "foo"]` item.
LangItem(LangItem, Span, Option<HirId>), LangItem(LangItem, Span),
} }
impl<'hir> QPath<'hir> { impl<'hir> QPath<'hir> {
@ -2068,7 +2068,7 @@ impl<'hir> QPath<'hir> {
match *self { match *self {
QPath::Resolved(_, path) => path.span, QPath::Resolved(_, path) => path.span,
QPath::TypeRelative(qself, ps) => qself.span.to(ps.ident.span), QPath::TypeRelative(qself, ps) => qself.span.to(ps.ident.span),
QPath::LangItem(_, span, _) => span, QPath::LangItem(_, span) => span,
} }
} }
@ -2078,7 +2078,7 @@ impl<'hir> QPath<'hir> {
match *self { match *self {
QPath::Resolved(_, path) => path.span, QPath::Resolved(_, path) => path.span,
QPath::TypeRelative(qself, _) => qself.span, QPath::TypeRelative(qself, _) => qself.span,
QPath::LangItem(_, span, _) => span, QPath::LangItem(_, span) => span,
} }
} }
} }

View file

@ -2546,7 +2546,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.map(|(ty, _, _)| ty) .map(|(ty, _, _)| ty)
.unwrap_or_else(|guar| Ty::new_error(tcx, guar)) .unwrap_or_else(|guar| Ty::new_error(tcx, guar))
} }
&hir::TyKind::Path(hir::QPath::LangItem(lang_item, span, _)) => { &hir::TyKind::Path(hir::QPath::LangItem(lang_item, span)) => {
let def_id = tcx.require_lang_item(lang_item, Some(span)); let def_id = tcx.require_lang_item(lang_item, Some(span));
let (args, _) = self.create_args_for_ast_path( let (args, _) = self.create_args_for_ast_path(
span, span,

View file

@ -1623,7 +1623,7 @@ impl<'a> State<'a> {
self.print_ident(item_segment.ident); self.print_ident(item_segment.ident);
self.print_generic_args(item_segment.args(), colons_before_params) self.print_generic_args(item_segment.args(), colons_before_params)
} }
hir::QPath::LangItem(lang_item, span, _) => { hir::QPath::LangItem(lang_item, span) => {
self.word("#[lang = \""); self.word("#[lang = \"");
self.print_ident(Ident::new(lang_item.name(), span)); self.print_ident(Ident::new(lang_item.name(), span));
self.word("\"]"); self.word("\"]");

View file

@ -289,8 +289,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ExprKind::AddrOf(kind, mutbl, oprnd) => { ExprKind::AddrOf(kind, mutbl, oprnd) => {
self.check_expr_addr_of(kind, mutbl, oprnd, expected, expr) self.check_expr_addr_of(kind, mutbl, oprnd, expected, expr)
} }
ExprKind::Path(QPath::LangItem(lang_item, _, hir_id)) => { ExprKind::Path(QPath::LangItem(lang_item, _)) => {
self.check_lang_item_path(lang_item, expr, hir_id) self.check_lang_item_path(lang_item, expr)
} }
ExprKind::Path(ref qpath) => self.check_expr_path(qpath, expr, &[]), ExprKind::Path(ref qpath) => self.check_expr_path(qpath, expr, &[]),
ExprKind::InlineAsm(asm) => { ExprKind::InlineAsm(asm) => {
@ -497,9 +497,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
lang_item: hir::LangItem, lang_item: hir::LangItem,
expr: &'tcx hir::Expr<'tcx>, expr: &'tcx hir::Expr<'tcx>,
hir_id: Option<hir::HirId>,
) -> Ty<'tcx> { ) -> Ty<'tcx> {
self.resolve_lang_item_path(lang_item, expr.span, expr.hir_id, hir_id).1 self.resolve_lang_item_path(lang_item, expr.span, expr.hir_id).1
} }
pub(crate) fn check_expr_path( pub(crate) fn check_expr_path(

View file

@ -753,7 +753,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
lang_item: hir::LangItem, lang_item: hir::LangItem,
span: Span, span: Span,
hir_id: hir::HirId, hir_id: hir::HirId,
expr_hir_id: Option<hir::HirId>,
) -> (Res, Ty<'tcx>) { ) -> (Res, Ty<'tcx>) {
let def_id = self.tcx.require_lang_item(lang_item, Some(span)); let def_id = self.tcx.require_lang_item(lang_item, Some(span));
let def_kind = self.tcx.def_kind(def_id); let def_kind = self.tcx.def_kind(def_id);
@ -770,7 +769,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let code = match lang_item { let code = match lang_item {
hir::LangItem::IntoFutureIntoFuture => { hir::LangItem::IntoFutureIntoFuture => {
Some(ObligationCauseCode::AwaitableExpr(expr_hir_id)) if let hir::Node::Expr(into_future_call) = self.tcx.hir().get_parent(hir_id)
&& let hir::ExprKind::Call(_, [arg0]) = &into_future_call.kind
{
Some(ObligationCauseCode::AwaitableExpr(arg0.hir_id))
} else {
None
}
} }
hir::LangItem::IteratorNext | hir::LangItem::IntoIterIntoIter => { hir::LangItem::IteratorNext | hir::LangItem::IntoIterIntoIter => {
Some(ObligationCauseCode::ForLoopIterator) Some(ObligationCauseCode::ForLoopIterator)

View file

@ -1842,8 +1842,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
(result.map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id)), ty) (result.map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id)), ty)
} }
QPath::LangItem(lang_item, span, id) => { QPath::LangItem(lang_item, span) => {
let (res, ty) = self.resolve_lang_item_path(lang_item, span, hir_id, id); let (res, ty) = self.resolve_lang_item_path(lang_item, span, hir_id);
(res, self.handle_raw_ty(path_span, ty)) (res, self.handle_raw_ty(path_span, ty))
} }
} }

View file

@ -1087,7 +1087,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
Box::new(segment.into_iter()) Box::new(segment.into_iter())
} }
hir::QPath::LangItem(_, _, _) => Box::new(iter::empty()), hir::QPath::LangItem(_, _) => Box::new(iter::empty()),
} }
} }
} }

View file

@ -422,7 +422,7 @@ pub enum ObligationCauseCode<'tcx> {
/// If `X` is the concrete type of an opaque type `impl Y`, then `X` must implement `Y` /// If `X` is the concrete type of an opaque type `impl Y`, then `X` must implement `Y`
OpaqueType, OpaqueType,
AwaitableExpr(Option<hir::HirId>), AwaitableExpr(hir::HirId),
ForLoopIterator, ForLoopIterator,

View file

@ -1634,8 +1634,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
fn suggest_remove_await(&self, obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic) { fn suggest_remove_await(&self, obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic) {
let hir = self.tcx.hir(); let hir = self.tcx.hir();
if let ObligationCauseCode::AwaitableExpr(Some(hir_id)) = if let ObligationCauseCode::AwaitableExpr(hir_id) = obligation.cause.code().peel_derives()
obligation.cause.code().peel_derives()
&& let hir::Node::Expr(expr) = hir.get(*hir_id) && let hir::Node::Expr(expr) = hir.get(*hir_id)
{ {
// FIXME: use `obligation.predicate.kind()...trait_ref.self_ty()` to see if we have `()` // FIXME: use `obligation.predicate.kind()...trait_ref.self_ty()` to see if we have `()`

View file

@ -61,7 +61,7 @@ pub(super) fn check(
// ? is a Call, makes sure not to rec *x?, but rather (*x)? // ? is a Call, makes sure not to rec *x?, but rather (*x)?
ExprKind::Call(hir_callee, _) => matches!( ExprKind::Call(hir_callee, _) => matches!(
hir_callee.kind, hir_callee.kind,
ExprKind::Path(QPath::LangItem(rustc_hir::LangItem::TryTraitBranch, _, _)) ExprKind::Path(QPath::LangItem(rustc_hir::LangItem::TryTraitBranch, ..))
), ),
ExprKind::MethodCall(_, self_arg, ..) if expr.hir_id == self_arg.hir_id => true, ExprKind::MethodCall(_, self_arg, ..) if expr.hir_id == self_arg.hir_id => true,
ExprKind::Match(_, _, MatchSource::TryDesugar(_) | MatchSource::AwaitDesugar) ExprKind::Match(_, _, MatchSource::TryDesugar(_) | MatchSource::AwaitDesugar)

View file

@ -309,7 +309,7 @@ fn check_final_expr<'tcx>(
let replacement = if let Some(inner_expr) = inner { let replacement = if let Some(inner_expr) = inner {
// if desugar of `do yeet`, don't lint // if desugar of `do yeet`, don't lint
if let ExprKind::Call(path_expr, _) = inner_expr.kind if let ExprKind::Call(path_expr, _) = inner_expr.kind
&& let ExprKind::Path(QPath::LangItem(LangItem::TryTraitFromYeet, _, _)) = path_expr.kind && let ExprKind::Path(QPath::LangItem(LangItem::TryTraitFromYeet, ..)) = path_expr.kind
{ {
return; return;
} }

View file

@ -59,7 +59,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMapOnConstructor {
} }
}, },
hir::QPath::TypeRelative(_, path) => path.ident.name, hir::QPath::TypeRelative(_, path) => path.ident.name,
hir::QPath::LangItem(_, _, _) => return, hir::QPath::LangItem(..) => return,
}; };
match constructor_symbol { match constructor_symbol {
sym::Some | sym::Ok if path.ident.name == rustc_span::sym::map => (), sym::Some | sym::Ok if path.ident.name == rustc_span::sym::map => (),

View file

@ -170,7 +170,7 @@ fn qpath_certainty(cx: &LateContext<'_>, qpath: &QPath<'_>, resolves_to_type: bo
path_segment_certainty(cx, type_certainty(cx, ty), path_segment, resolves_to_type) path_segment_certainty(cx, type_certainty(cx, ty), path_segment, resolves_to_type)
}, },
QPath::LangItem(lang_item, _, _) => { QPath::LangItem(lang_item, ..) => {
cx.tcx cx.tcx
.lang_items() .lang_items()
.get(*lang_item) .get(*lang_item)