mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-13 23:42:56 +00:00
s/Generator/Coroutine/
This commit is contained in:
parent
214b4d91bd
commit
868e513935
@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_hir_and_then;
|
||||
use clippy_utils::source::snippet;
|
||||
use clippy_utils::ty::implements_trait;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{AsyncGeneratorKind, Body, BodyId, ExprKind, GeneratorKind, QPath};
|
||||
use rustc_hir::{AsyncCoroutineKind, Body, BodyId, ExprKind, CoroutineKind, QPath};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
|
||||
@ -45,10 +45,10 @@ declare_lint_pass!(AsyncYieldsAsync => [ASYNC_YIELDS_ASYNC]);
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync {
|
||||
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
|
||||
use AsyncGeneratorKind::{Block, Closure};
|
||||
use AsyncCoroutineKind::{Block, Closure};
|
||||
// For functions, with explicitly defined types, don't warn.
|
||||
// XXXkhuey maybe we should?
|
||||
if let Some(GeneratorKind::Async(Block | Closure)) = body.generator_kind {
|
||||
if let Some(CoroutineKind::Async(Block | Closure)) = body.generator_kind {
|
||||
if let Some(future_trait_def_id) = cx.tcx.lang_items().future_trait() {
|
||||
let body_id = BodyId {
|
||||
hir_id: body.value.hir_id,
|
||||
|
@ -2,9 +2,9 @@ use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::{match_def_path, paths};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{AsyncGeneratorKind, Body, GeneratorKind};
|
||||
use rustc_hir::{AsyncCoroutineKind, Body, CoroutineKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::mir::GeneratorLayout;
|
||||
use rustc_middle::mir::CoroutineLayout;
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::{sym, Span};
|
||||
|
||||
@ -195,8 +195,8 @@ impl LateLintPass<'_> for AwaitHolding {
|
||||
}
|
||||
|
||||
fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) {
|
||||
use AsyncGeneratorKind::{Block, Closure, Fn};
|
||||
if let Some(GeneratorKind::Async(Block | Closure | Fn)) = body.generator_kind {
|
||||
use AsyncCoroutineKind::{Block, Closure, Fn};
|
||||
if let Some(CoroutineKind::Async(Block | Closure | Fn)) = body.generator_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);
|
||||
@ -206,7 +206,7 @@ impl LateLintPass<'_> for AwaitHolding {
|
||||
}
|
||||
|
||||
impl AwaitHolding {
|
||||
fn check_interior_types(&self, cx: &LateContext<'_>, generator: &GeneratorLayout<'_>) {
|
||||
fn check_interior_types(&self, cx: &LateContext<'_>, generator: &CoroutineLayout<'_>) {
|
||||
for (ty_index, ty_cause) in generator.field_tys.iter_enumerated() {
|
||||
if let rustc_middle::ty::Adt(adt, _) = ty_cause.ty.kind() {
|
||||
let await_points = || {
|
||||
|
@ -842,8 +842,8 @@ impl TyCoercionStability {
|
||||
| ty::Adt(..)
|
||||
| ty::Foreign(_)
|
||||
| ty::FnDef(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(..)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
|
@ -436,7 +436,7 @@ fn lint_for_missing_headers(
|
||||
let body = cx.tcx.hir().body(body_id);
|
||||
let ret_ty = typeck.expr_ty(body.value);
|
||||
if implements_trait(cx, ret_ty, future, &[]);
|
||||
if let ty::Generator(_, subs, _) = ret_ty.kind();
|
||||
if let ty::Coroutine(_, subs, _) = ret_ty.kind();
|
||||
if is_type_diagnostic_item(cx, subs.as_generator().return_ty(), sym::Result);
|
||||
then {
|
||||
span_lint(
|
||||
|
@ -12,7 +12,7 @@ declare_clippy_lint! {
|
||||
/// It checks for the size of a `Future` created by `async fn` or `async {}`.
|
||||
///
|
||||
/// ### Why is this bad?
|
||||
/// Due to the current [unideal implementation](https://github.com/rust-lang/rust/issues/69826) of `Generator`,
|
||||
/// Due to the current [unideal implementation](https://github.com/rust-lang/rust/issues/69826) of `Coroutine`,
|
||||
/// large size of a `Future` may cause stack overflows.
|
||||
///
|
||||
/// ### Example
|
||||
|
@ -4,7 +4,7 @@ use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
use rustc_hir::{
|
||||
AsyncGeneratorKind, Block, Body, Closure, Expr, ExprKind, FnDecl, FnRetTy, GeneratorKind, GenericArg, GenericBound,
|
||||
AsyncCoroutineKind, Block, Body, Closure, Expr, ExprKind, FnDecl, FnRetTy, CoroutineKind, GenericArg, GenericBound,
|
||||
ImplItem, Item, ItemKind, LifetimeName, Node, Term, TraitRef, Ty, TyKind, TypeBindingKind,
|
||||
};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
@ -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(GeneratorKind::Async(AsyncGeneratorKind::Block));
|
||||
if closure_body.generator_kind == Some(CoroutineKind::Async(AsyncCoroutineKind::Block));
|
||||
then {
|
||||
return Some(closure_body);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use clippy_utils::source::snippet;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::{AsyncGeneratorKind, Block, Body, Expr, ExprKind, GeneratorKind, LangItem, MatchSource, QPath};
|
||||
use rustc_hir::{AsyncCoroutineKind, Block, Body, Expr, ExprKind, CoroutineKind, LangItem, MatchSource, QPath};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
|
||||
@ -87,7 +87,7 @@ impl LateLintPass<'_> for NeedlessQuestionMark {
|
||||
}
|
||||
|
||||
fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) {
|
||||
if let Some(GeneratorKind::Async(AsyncGeneratorKind::Fn)) = body.generator_kind {
|
||||
if let Some(CoroutineKind::Async(AsyncCoroutineKind::Fn)) = body.generator_kind {
|
||||
if let ExprKind::Block(
|
||||
Block {
|
||||
expr:
|
||||
|
@ -5,7 +5,7 @@ use clippy_utils::peel_blocks;
|
||||
use clippy_utils::source::{snippet, walk_span_to_context};
|
||||
use clippy_utils::visitors::for_each_expr;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{AsyncGeneratorKind, Closure, Expr, ExprKind, GeneratorKind, MatchSource};
|
||||
use rustc_hir::{AsyncCoroutineKind, Closure, Expr, ExprKind, CoroutineKind, MatchSource};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_middle::ty::UpvarCapture;
|
||||
@ -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(GeneratorKind::Async(AsyncGeneratorKind::Block)))
|
||||
matches!(body.generator_kind, Some(CoroutineKind::Async(AsyncCoroutineKind::Block)))
|
||||
{
|
||||
cx
|
||||
.typeck_results()
|
||||
|
@ -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::GeneratorKind::Async(_)));
|
||||
let is_async_block = matches!(b.generator_kind, Some(rustc_hir::CoroutineKind::Async(_)));
|
||||
|
||||
if is_async_block {
|
||||
self.async_depth += 1;
|
||||
|
@ -305,7 +305,7 @@ fn check_terminator<'tcx>(
|
||||
Ok(())
|
||||
},
|
||||
TerminatorKind::SwitchInt { discr, targets: _ } => check_operand(tcx, discr, span, body),
|
||||
TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => {
|
||||
TerminatorKind::CoroutineDrop | TerminatorKind::Yield { .. } => {
|
||||
Err((span, "const fn generators are unstable".into()))
|
||||
},
|
||||
TerminatorKind::Call {
|
||||
|
Loading…
Reference in New Issue
Block a user