Skip to content

Commit

Permalink
s/generator/coroutine/
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Oct 20, 2023
1 parent 868e513 commit d9259fd
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/async_yields_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync {
use AsyncCoroutineKind::{Block, Closure};
// For functions, with explicitly defined types, don't warn.
// XXXkhuey maybe we should?
if let Some(CoroutineKind::Async(Block | Closure)) = body.generator_kind {
if let Some(CoroutineKind::Async(Block | Closure)) = body.coroutine_kind {
if let Some(future_trait_def_id) = cx.tcx.lang_items().future_trait() {
let body_id = BodyId {
hir_id: body.value.hir_id,
Expand Down
14 changes: 7 additions & 7 deletions clippy_lints/src/await_holding_invalid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,25 +196,25 @@ impl LateLintPass<'_> for AwaitHolding {

fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) {
use AsyncCoroutineKind::{Block, Closure, Fn};
if let Some(CoroutineKind::Async(Block | Closure | Fn)) = body.generator_kind {
if let Some(CoroutineKind::Async(Block | Closure | Fn)) = body.coroutine_kind {
let def_id = cx.tcx.hir().body_owner_def_id(body.id());
if let Some(generator_layout) = cx.tcx.mir_generator_witnesses(def_id) {
self.check_interior_types(cx, generator_layout);
if let Some(coroutine_layout) = cx.tcx.mir_coroutine_witnesses(def_id) {
self.check_interior_types(cx, coroutine_layout);
}
}
}
}

impl AwaitHolding {
fn check_interior_types(&self, cx: &LateContext<'_>, generator: &CoroutineLayout<'_>) {
for (ty_index, ty_cause) in generator.field_tys.iter_enumerated() {
fn check_interior_types(&self, cx: &LateContext<'_>, coroutine: &CoroutineLayout<'_>) {
for (ty_index, ty_cause) in coroutine.field_tys.iter_enumerated() {
if let rustc_middle::ty::Adt(adt, _) = ty_cause.ty.kind() {
let await_points = || {
generator
coroutine
.variant_source_info
.iter_enumerated()
.filter_map(|(variant, source_info)| {
generator.variant_fields[variant]
coroutine.variant_fields[variant]
.raw
.contains(&ty_index)
.then_some(source_info.span)
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ fn lint_for_missing_headers(
let ret_ty = typeck.expr_ty(body.value);
if implements_trait(cx, ret_ty, future, &[]);
if let ty::Coroutine(_, subs, _) = ret_ty.kind();
if is_type_diagnostic_item(cx, subs.as_generator().return_ty(), sym::Result);
if is_type_diagnostic_item(cx, subs.as_coroutine().return_ty(), sym::Result);
then {
span_lint(
cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/manual_async_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>)
..
} = block_expr;
let closure_body = cx.tcx.hir().body(body);
if closure_body.generator_kind == Some(CoroutineKind::Async(AsyncCoroutineKind::Block));
if closure_body.coroutine_kind == Some(CoroutineKind::Async(AsyncCoroutineKind::Block));
then {
return Some(closure_body);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/iter_kv_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(super) fn check<'tcx>(
if_chain! {
if !expr.span.from_expansion();
if let ExprKind::Closure(c) = m_arg.kind;
if let Body {params: [p], value: body_expr, generator_kind: _ } = cx.tcx.hir().body(c.body);
if let Body {params: [p], value: body_expr, coroutine_kind: _ } = cx.tcx.hir().body(c.body);
if let PatKind::Tuple([key_pat, val_pat], _) = p.pat.kind;

let (replacement_kind, annotation, bound_ident) = match (&key_pat.kind, &val_pat.kind) {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_question_mark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl LateLintPass<'_> for NeedlessQuestionMark {
}

fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) {
if let Some(CoroutineKind::Async(AsyncCoroutineKind::Fn)) = body.generator_kind {
if let Some(CoroutineKind::Async(AsyncCoroutineKind::Fn)) = body.coroutine_kind {
if let ExprKind::Block(
Block {
expr:
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/redundant_async_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantAsyncBlock {
fn desugar_async_block<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<&'tcx Expr<'tcx>> {
if let ExprKind::Closure(Closure { body, def_id, .. }) = expr.kind &&
let body = cx.tcx.hir().body(*body) &&
matches!(body.generator_kind, Some(CoroutineKind::Async(AsyncCoroutineKind::Block)))
matches!(body.coroutine_kind, Some(CoroutineKind::Async(AsyncCoroutineKind::Block)))
{
cx
.typeck_results()
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/redundant_closure_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall {
// without this check, we'd end up linting twice.
&& !matches!(recv.kind, hir::ExprKind::Call(..))
&& let (full_expr, call_depth) = get_parent_call_exprs(cx, expr)
&& let Some((body, fn_decl, generator_kind)) = find_innermost_closure(cx, recv, call_depth)
&& let Some((body, fn_decl, coroutine_kind)) = find_innermost_closure(cx, recv, call_depth)
{
span_lint_and_then(
cx,
Expand All @@ -156,7 +156,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall {
let mut applicability = Applicability::MachineApplicable;
let mut hint = Sugg::hir_with_context(cx, body, full_expr.span.ctxt(), "..", &mut applicability);

if generator_kind.is_async()
if coroutine_kind.is_async()
&& let hir::ExprKind::Closure(closure) = body.kind
{
let async_closure_body = cx.tcx.hir().body(closure.body);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/unused_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<'a, 'tcx> Visitor<'tcx> for AsyncFnVisitor<'a, 'tcx> {
}

fn visit_body(&mut self, b: &'tcx Body<'tcx>) {
let is_async_block = matches!(b.generator_kind, Some(rustc_hir::CoroutineKind::Async(_)));
let is_async_block = matches!(b.coroutine_kind, Some(rustc_hir::CoroutineKind::Async(_)));

if is_async_block {
self.async_depth += 1;
Expand Down
2 changes: 1 addition & 1 deletion clippy_utils/src/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ fn check_terminator<'tcx>(
},
TerminatorKind::SwitchInt { discr, targets: _ } => check_operand(tcx, discr, span, body),
TerminatorKind::CoroutineDrop | TerminatorKind::Yield { .. } => {
Err((span, "const fn generators are unstable".into()))
Err((span, "const fn coroutines are unstable".into()))
},
TerminatorKind::Call {
func,
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/crashes/ice-5238.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Regression test for #5238 / https://github.com/rust-lang/rust/pull/69562

#![feature(generators, generator_trait)]
#![feature(coroutines, coroutine_trait)]

fn main() {
let _ = || {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/large_futures.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(generators)]
#![feature(coroutines)]
#![warn(clippy::large_futures)]
#![allow(clippy::never_loop)]
#![allow(clippy::future_not_send)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/large_futures.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(generators)]
#![feature(coroutines)]
#![warn(clippy::large_futures)]
#![allow(clippy::never_loop)]
#![allow(clippy::future_not_send)]
Expand Down

0 comments on commit d9259fd

Please sign in to comment.