Skip to content

Commit 930dfc8

Browse files
committed
Remove QPath::LangItem from async
1 parent ae9d202 commit 930dfc8

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

clippy_lints/src/large_futures.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::source::snippet;
44
use clippy_utils::ty::implements_trait;
55
use rustc_abi::Size;
66
use rustc_errors::Applicability;
7-
use rustc_hir::{Expr, ExprKind, LangItem, MatchSource, QPath};
7+
use rustc_hir::{Expr, ExprKind, LangItem, MatchSource};
88
use rustc_lint::{LateContext, LateLintPass};
99
use rustc_session::impl_lint_pass;
1010

@@ -58,7 +58,8 @@ impl<'tcx> LateLintPass<'tcx> for LargeFuture {
5858
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
5959
if let ExprKind::Match(scrutinee, _, MatchSource::AwaitDesugar) = expr.kind
6060
&& let ExprKind::Call(func, [arg]) = scrutinee.kind
61-
&& let ExprKind::Path(QPath::LangItem(LangItem::IntoFutureIntoFuture, ..)) = func.kind
61+
&& let ExprKind::Path(qpath) = func.kind
62+
&& cx.tcx.qpath_is_lang_item(qpath, LangItem::IntoFutureIntoFuture)
6263
&& !expr.span.from_expansion()
6364
&& let ty = cx.typeck_results().expr_ty(arg)
6465
&& let Some(future_trait_def_id) = cx.tcx.lang_items().future_trait()

clippy_lints/src/unused_io_amount.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ fn should_lint<'a>(cx: &LateContext<'a>, mut inner: &'a hir::Expr<'a>) -> Option
194194
inner = unpack_match(inner);
195195
inner = unpack_try(inner);
196196
inner = unpack_call_chain(inner);
197-
inner = unpack_await(inner);
197+
inner = unpack_await(cx, inner);
198198
// we type-check it to get whether it's a read/write or their vectorized forms
199199
// and keep only the ones that are produce io amount
200200
check_io_mode(cx, inner)
@@ -277,13 +277,11 @@ fn unpack_match<'a>(mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
277277

278278
/// If `expr` is an (e).await, return the inner expression "e" that's being
279279
/// waited on. Otherwise return None.
280-
fn unpack_await<'a>(expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
280+
fn unpack_await<'a>(cx: &LateContext<'_>, expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
281281
if let ExprKind::Match(expr, _, hir::MatchSource::AwaitDesugar) = expr.kind
282282
&& let ExprKind::Call(func, [arg_0]) = expr.kind
283-
&& matches!(
284-
func.kind,
285-
ExprKind::Path(hir::QPath::LangItem(hir::LangItem::IntoFutureIntoFuture, ..))
286-
)
283+
&& let ExprKind::Path(qpath) = func.kind
284+
&& cx.tcx.qpath_is_lang_item(qpath, hir::LangItem::IntoFutureIntoFuture)
287285
{
288286
return arg_0;
289287
}

0 commit comments

Comments
 (0)