s/generator/coroutine/
This commit is contained in:
parent
868e513935
commit
d9259fdedd
@ -48,7 +48,7 @@ fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
|
||||
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,
|
||||
|
@ -196,25 +196,25 @@ fn check_crate(&mut self, cx: &LateContext<'_>) {
|
||||
|
||||
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)
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -87,7 +87,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'_ Expr<'_>) {
|
||||
}
|
||||
|
||||
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:
|
||||
|
@ -71,7 +71,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
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()
|
||||
|
@ -144,7 +144,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
|
||||
// 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,
|
||||
@ -156,7 +156,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
|
||||
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);
|
||||
|
@ -86,7 +86,7 @@ fn nested_visit_map(&mut self) -> Self::Map {
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -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,
|
||||
|
@ -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 _ = || {
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(generators)]
|
||||
#![feature(coroutines)]
|
||||
#![warn(clippy::large_futures)]
|
||||
#![allow(clippy::never_loop)]
|
||||
#![allow(clippy::future_not_send)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(generators)]
|
||||
#![feature(coroutines)]
|
||||
#![warn(clippy::large_futures)]
|
||||
#![allow(clippy::never_loop)]
|
||||
#![allow(clippy::future_not_send)]
|
||||
|
Loading…
Reference in New Issue
Block a user