Skip to content

Commit 5f19fac

Browse files
authored
Rollup merge of rust-lang#117175 - oli-obk:gen_fn_split, r=compiler-errors
Rename AsyncCoroutineKind to CoroutineSource pulled out of rust-lang#116447 Also refactors the printing infra of `CoroutineSource` to be ready for easily extending it with a `Gen` variant for `gen` blocks
2 parents ffc7419 + c337899 commit 5f19fac

5 files changed

+10
-10
lines changed

clippy_lints/src/async_yields_async.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_hir_and_then;
22
use clippy_utils::source::snippet;
33
use clippy_utils::ty::implements_trait;
44
use rustc_errors::Applicability;
5-
use rustc_hir::{AsyncCoroutineKind, Body, BodyId, CoroutineKind, ExprKind, QPath};
5+
use rustc_hir::{CoroutineSource, Body, BodyId, CoroutineKind, ExprKind, QPath};
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_session::{declare_lint_pass, declare_tool_lint};
88

@@ -45,7 +45,7 @@ declare_lint_pass!(AsyncYieldsAsync => [ASYNC_YIELDS_ASYNC]);
4545

4646
impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync {
4747
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
48-
use AsyncCoroutineKind::{Block, Closure};
48+
use CoroutineSource::{Block, Closure};
4949
// For functions, with explicitly defined types, don't warn.
5050
// XXXkhuey maybe we should?
5151
if let Some(CoroutineKind::Async(Block | Closure)) = body.coroutine_kind {

clippy_lints/src/await_holding_invalid.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::{match_def_path, paths};
33
use rustc_data_structures::fx::FxHashMap;
44
use rustc_hir::def_id::DefId;
5-
use rustc_hir::{AsyncCoroutineKind, Body, CoroutineKind};
5+
use rustc_hir::{CoroutineSource, Body, CoroutineKind};
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_middle::mir::CoroutineLayout;
88
use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -195,7 +195,7 @@ impl LateLintPass<'_> for AwaitHolding {
195195
}
196196

197197
fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) {
198-
use AsyncCoroutineKind::{Block, Closure, Fn};
198+
use CoroutineSource::{Block, Closure, Fn};
199199
if let Some(CoroutineKind::Async(Block | Closure | Fn)) = body.coroutine_kind {
200200
let def_id = cx.tcx.hir().body_owner_def_id(body.id());
201201
if let Some(coroutine_layout) = cx.tcx.mir_coroutine_witnesses(def_id) {

clippy_lints/src/manual_async_fn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use if_chain::if_chain;
44
use rustc_errors::Applicability;
55
use rustc_hir::intravisit::FnKind;
66
use rustc_hir::{
7-
AsyncCoroutineKind, Block, Body, Closure, CoroutineKind, Expr, ExprKind, FnDecl, FnRetTy, GenericArg, GenericBound,
7+
CoroutineSource, Block, Body, Closure, CoroutineKind, Expr, ExprKind, FnDecl, FnRetTy, GenericArg, GenericBound,
88
ImplItem, Item, ItemKind, LifetimeName, Node, Term, TraitRef, Ty, TyKind, TypeBindingKind,
99
};
1010
use rustc_lint::{LateContext, LateLintPass};
@@ -188,7 +188,7 @@ fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>)
188188
..
189189
} = block_expr;
190190
let closure_body = cx.tcx.hir().body(body);
191-
if closure_body.coroutine_kind == Some(CoroutineKind::Async(AsyncCoroutineKind::Block));
191+
if closure_body.coroutine_kind == Some(CoroutineKind::Async(CoroutineSource::Block));
192192
then {
193193
return Some(closure_body);
194194
}

clippy_lints/src/needless_question_mark.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::source::snippet;
44
use if_chain::if_chain;
55
use rustc_errors::Applicability;
66
use rustc_hir::def::{DefKind, Res};
7-
use rustc_hir::{AsyncCoroutineKind, Block, Body, CoroutineKind, Expr, ExprKind, LangItem, MatchSource, QPath};
7+
use rustc_hir::{CoroutineSource, Block, Body, CoroutineKind, Expr, ExprKind, LangItem, MatchSource, QPath};
88
use rustc_lint::{LateContext, LateLintPass};
99
use rustc_session::{declare_lint_pass, declare_tool_lint};
1010

@@ -87,7 +87,7 @@ impl LateLintPass<'_> for NeedlessQuestionMark {
8787
}
8888

8989
fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) {
90-
if let Some(CoroutineKind::Async(AsyncCoroutineKind::Fn)) = body.coroutine_kind {
90+
if let Some(CoroutineKind::Async(CoroutineSource::Fn)) = body.coroutine_kind {
9191
if let ExprKind::Block(
9292
Block {
9393
expr:

clippy_lints/src/redundant_async_block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clippy_utils::peel_blocks;
55
use clippy_utils::source::{snippet, walk_span_to_context};
66
use clippy_utils::visitors::for_each_expr;
77
use rustc_errors::Applicability;
8-
use rustc_hir::{AsyncCoroutineKind, Closure, CoroutineKind, Expr, ExprKind, MatchSource};
8+
use rustc_hir::{CoroutineSource, Closure, CoroutineKind, Expr, ExprKind, MatchSource};
99
use rustc_lint::{LateContext, LateLintPass};
1010
use rustc_middle::lint::in_external_macro;
1111
use rustc_middle::ty::UpvarCapture;
@@ -71,7 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantAsyncBlock {
7171
fn desugar_async_block<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<&'tcx Expr<'tcx>> {
7272
if let ExprKind::Closure(Closure { body, def_id, .. }) = expr.kind &&
7373
let body = cx.tcx.hir().body(*body) &&
74-
matches!(body.coroutine_kind, Some(CoroutineKind::Async(AsyncCoroutineKind::Block)))
74+
matches!(body.coroutine_kind, Some(CoroutineKind::Async(CoroutineSource::Block)))
7575
{
7676
cx
7777
.typeck_results()

0 commit comments

Comments
 (0)