diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index d1dac1c7145df..ce7d12606127d 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -12,7 +12,7 @@ use rustc_data_structures::fx::FxIndexSet; use rustc_errors::codes::*; use rustc_errors::{Applicability, Diag, MultiSpan, struct_span_code_err}; use rustc_hir as hir; -use rustc_hir::def::{DefKind, Res}; +use rustc_hir::def::{CoroutineDefKind, DefKind, Res}; use rustc_hir::intravisit::{Visitor, walk_block, walk_expr}; use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, LangItem, PatField}; use rustc_middle::bug; @@ -2983,15 +2983,19 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { .map(|name| format!("function `{name}`")) .unwrap_or_else(|| { match &self.infcx.tcx.def_kind(self.mir_def_id()) { - DefKind::Closure - if self - .infcx - .tcx - .is_coroutine(self.mir_def_id().to_def_id()) => - { - "enclosing coroutine" - } - DefKind::Closure => "enclosing closure", + DefKind::Closure { coroutine_kind } => match coroutine_kind { + None => "enclosing closure", + Some(CoroutineDefKind::Desugared( + hir::CoroutineDesugaring::Async, + )) => "enclosing async closure", + Some(CoroutineDefKind::Desugared( + hir::CoroutineDesugaring::Gen, + )) => "enclosing gen closure", + Some(CoroutineDefKind::Desugared( + hir::CoroutineDesugaring::AsyncGen, + )) => "enclosing async gen closure", + Some(CoroutineDefKind::Coroutine) => "enclosing coroutine", + }, kind => bug!("expected closure or coroutine, found {:?}", kind), } .to_string() diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index e37b5a33af82c..07aa60b23138b 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -2515,7 +2515,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { // We don't want to dispatch on 3 different kind of closures here, so take // advantage of the fact that the `parent_args` is the same length as the // `typeck_root_args`. - DefKind::Closure => { + DefKind::Closure { .. } => { // FIXME(async_closures): It may be useful to add a debug assert here // to actually call `type_of` and check the `parent_args` are the same // length as the `typeck_root_args`. diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index 18279a4d05fe0..d79568965237f 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -605,7 +605,7 @@ fn push_unqualified_item_name( DefPathData::CrateRoot => { output.push_str(tcx.crate_name(def_id.krate).as_str()); } - DefPathData::Closure => { + DefPathData::Closure { .. } => { let label = coroutine_kind_label(tcx.coroutine_kind(def_id)); push_disambiguated_special_name( @@ -619,7 +619,7 @@ fn push_unqualified_item_name( DefPathDataName::Named(name) => { output.push_str(name.as_str()); } - DefPathDataName::Anon { namespace } => { + DefPathDataName::Anon { namespace, kind: _ } => { push_disambiguated_special_name( namespace.as_str(), disambiguated_data.disambiguator, diff --git a/compiler/rustc_const_eval/src/interpret/stack.rs b/compiler/rustc_const_eval/src/interpret/stack.rs index 3361a586b8eef..83615a624b1cc 100644 --- a/compiler/rustc_const_eval/src/interpret/stack.rs +++ b/compiler/rustc_const_eval/src/interpret/stack.rs @@ -217,7 +217,10 @@ pub struct FrameInfo<'tcx> { impl<'tcx> fmt::Display for FrameInfo<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ty::tls::with(|tcx| { - if tcx.def_key(self.instance.def_id()).disambiguated_data.data == DefPathData::Closure { + if matches!( + tcx.def_key(self.instance.def_id()).disambiguated_data.data, + DefPathData::Closure { .. } + ) { write!(f, "inside closure") } else { // Note: this triggers a `must_produce_diag` state, which means that if we ever @@ -232,7 +235,10 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> { impl<'tcx> FrameInfo<'tcx> { pub fn as_note(&self, tcx: TyCtxt<'tcx>) -> errors::FrameNote { let span = self.span; - if tcx.def_key(self.instance.def_id()).disambiguated_data.data == DefPathData::Closure { + if matches!( + tcx.def_key(self.instance.def_id()).disambiguated_data.data, + DefPathData::Closure { .. } + ) { errors::FrameNote { where_: "closure", span, diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 459fe5935e06e..c8543eacfc7ee 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -6,9 +6,9 @@ use rustc_ast::NodeId; use rustc_data_structures::stable_hasher::ToStableHashKey; use rustc_data_structures::unord::UnordMap; use rustc_macros::{Decodable, Encodable, HashStable_Generic}; -use rustc_span::Symbol; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::hygiene::MacroKind; +use rustc_span::{Symbol, kw, sym}; use crate::definitions::DefPathData; use crate::hir; @@ -45,6 +45,14 @@ pub enum NonMacroAttrKind { DeriveHelperCompat, } +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)] +pub enum CoroutineDefKind { + /// A desugared coroutine from `async` or similar + Desugared(hir::CoroutineDesugaring), + /// An explicit `#[coroutine]` + Coroutine, +} + /// What kind of definition something is; e.g., `mod` vs `struct`. /// `enum DefPathData` may need to be updated if a new variant is added here. #[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)] @@ -140,7 +148,9 @@ pub enum DefKind { /// which makes it difficult to distinguish these during def collection. Therefore, /// we treat them all the same, and code which needs to distinguish them can match /// or `hir::ClosureKind` or `type_of`. - Closure, + Closure { + coroutine_kind: Option, + }, /// The definition of a synthetic coroutine body created by the lowering of a /// coroutine-closure, such as an async closure. SyntheticCoroutineBody, @@ -185,7 +195,17 @@ impl DefKind { DefKind::InlineConst => "inline constant", DefKind::Field => "field", DefKind::Impl { .. } => "implementation", - DefKind::Closure => "closure", + DefKind::Closure { coroutine_kind } => match coroutine_kind { + None => "closure", + Some(CoroutineDefKind::Desugared(hir::CoroutineDesugaring::Async)) => { + "async closure" + } + Some(CoroutineDefKind::Desugared(hir::CoroutineDesugaring::Gen)) => "gen closure", + Some(CoroutineDefKind::Desugared(hir::CoroutineDesugaring::AsyncGen)) => { + "async gen closure" + } + Some(CoroutineDefKind::Coroutine) => "coroutine", + }, DefKind::ExternCrate => "extern crate", DefKind::GlobalAsm => "global assembly block", DefKind::SyntheticCoroutineBody => "synthetic mir body", @@ -209,6 +229,15 @@ impl DefKind { | DefKind::InlineConst | DefKind::ExternCrate => "an", DefKind::Macro(macro_kind) => macro_kind.article(), + + DefKind::Closure { coroutine_kind } => match coroutine_kind { + None => "a", + Some(CoroutineDefKind::Desugared(hir::CoroutineDesugaring::Async)) => "an", + Some(CoroutineDefKind::Desugared(hir::CoroutineDesugaring::Gen)) => "a", + Some(CoroutineDefKind::Desugared(hir::CoroutineDesugaring::AsyncGen)) => "an", + Some(CoroutineDefKind::Coroutine) => "a", + }, + _ => "a", } } @@ -243,7 +272,7 @@ impl DefKind { | DefKind::Field | DefKind::LifetimeParam | DefKind::ExternCrate - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::Use | DefKind::ForeignMod | DefKind::GlobalAsm @@ -290,7 +319,21 @@ impl DefKind { DefKind::OpaqueTy => DefPathData::OpaqueTy, DefKind::GlobalAsm => DefPathData::GlobalAsm, DefKind::Impl { .. } => DefPathData::Impl, - DefKind::Closure => DefPathData::Closure, + DefKind::Closure { coroutine_kind } => match coroutine_kind { + None => DefPathData::Closure { coroutine_kind: None }, + Some(CoroutineDefKind::Desugared(hir::CoroutineDesugaring::Async)) => { + DefPathData::Closure { coroutine_kind: Some(kw::Async) } + } + Some(CoroutineDefKind::Desugared(hir::CoroutineDesugaring::Gen)) => { + DefPathData::Closure { coroutine_kind: Some(kw::Gen) } + } + Some(CoroutineDefKind::Desugared(hir::CoroutineDesugaring::AsyncGen)) => { + DefPathData::Closure { coroutine_kind: Some(sym::async_gen) } + } + Some(CoroutineDefKind::Coroutine) => { + DefPathData::Closure { coroutine_kind: Some(sym::coroutine) } + } + }, DefKind::SyntheticCoroutineBody => DefPathData::SyntheticCoroutineBody, } } @@ -299,7 +342,10 @@ impl DefKind { pub fn is_fn_like(self) -> bool { matches!( self, - DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::SyntheticCoroutineBody + DefKind::Fn + | DefKind::AssocFn + | DefKind::Closure { .. } + | DefKind::SyntheticCoroutineBody ) } @@ -309,7 +355,7 @@ impl DefKind { DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(..) - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::Static { .. } | DefKind::SyntheticCoroutineBody => true, DefKind::Mod diff --git a/compiler/rustc_hir/src/definitions.rs b/compiler/rustc_hir/src/definitions.rs index f93b9e5af5345..50d19111e20e2 100644 --- a/compiler/rustc_hir/src/definitions.rs +++ b/compiler/rustc_hir/src/definitions.rs @@ -190,13 +190,20 @@ impl DisambiguatedDefPathData { writer.write_str(name.as_str()) } } - DefPathDataName::Anon { namespace } => { - if let DefPathData::AnonAssocTy(method) = self.data { + DefPathDataName::Anon { namespace, kind } => match (self.data, kind) { + (DefPathData::AnonAssocTy(method), None) => { write!(writer, "{}::{{{}#{}}}", method, namespace, self.disambiguator) - } else { + } + (DefPathData::AnonAssocTy(method), Some(kind)) => { + write!(writer, "{}::{{{}:{}#{}}}", method, namespace, kind, self.disambiguator) + } + (_, None) => { write!(writer, "{{{}#{}}}", namespace, self.disambiguator) } - } + (_, Some(kind)) => { + write!(writer, "{{{}:{}#{}}}", namespace, kind, self.disambiguator) + } + }, } } } @@ -299,7 +306,7 @@ pub enum DefPathData { /// Something in the lifetime namespace. LifetimeNs(Symbol), /// A closure expression. - Closure, + Closure { coroutine_kind: Option }, // Subportions of items: /// Implicit constructor for a unit or tuple-like struct or enum variant. @@ -440,7 +447,7 @@ impl Definitions { #[derive(Copy, Clone, PartialEq, Debug)] pub enum DefPathDataName { Named(Symbol), - Anon { namespace: Symbol }, + Anon { namespace: Symbol, kind: Option }, } impl DefPathData { @@ -450,12 +457,13 @@ impl DefPathData { TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) | OpaqueLifetime(name) => Some(name), + Closure { coroutine_kind } => coroutine_kind, + Impl | ForeignMod | CrateRoot | Use | GlobalAsm - | Closure | Ctor | AnonConst | OpaqueTy @@ -471,12 +479,13 @@ impl DefPathData { TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) | AnonAssocTy(name) | OpaqueLifetime(name) => Some(name), + Closure { coroutine_kind } => coroutine_kind, + Impl | ForeignMod | CrateRoot | Use | GlobalAsm - | Closure | Ctor | AnonConst | OpaqueTy @@ -491,18 +500,22 @@ impl DefPathData { TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) | OpaqueLifetime(name) => DefPathDataName::Named(name), // Note that this does not show up in user print-outs. - CrateRoot => DefPathDataName::Anon { namespace: kw::Crate }, - Impl => DefPathDataName::Anon { namespace: kw::Impl }, - ForeignMod => DefPathDataName::Anon { namespace: kw::Extern }, - Use => DefPathDataName::Anon { namespace: kw::Use }, - GlobalAsm => DefPathDataName::Anon { namespace: sym::global_asm }, - Closure => DefPathDataName::Anon { namespace: sym::closure }, - Ctor => DefPathDataName::Anon { namespace: sym::constructor }, - AnonConst => DefPathDataName::Anon { namespace: sym::constant }, - OpaqueTy => DefPathDataName::Anon { namespace: sym::opaque }, - AnonAssocTy(..) => DefPathDataName::Anon { namespace: sym::anon_assoc }, - SyntheticCoroutineBody => DefPathDataName::Anon { namespace: sym::synthetic }, - NestedStatic => DefPathDataName::Anon { namespace: sym::nested }, + CrateRoot => DefPathDataName::Anon { namespace: kw::Crate, kind: None }, + Impl => DefPathDataName::Anon { namespace: kw::Impl, kind: None }, + ForeignMod => DefPathDataName::Anon { namespace: kw::Extern, kind: None }, + Use => DefPathDataName::Anon { namespace: kw::Use, kind: None }, + GlobalAsm => DefPathDataName::Anon { namespace: sym::global_asm, kind: None }, + Closure { coroutine_kind } => { + DefPathDataName::Anon { namespace: sym::closure, kind: coroutine_kind } + } + Ctor => DefPathDataName::Anon { namespace: sym::constructor, kind: None }, + AnonConst => DefPathDataName::Anon { namespace: sym::constant, kind: None }, + OpaqueTy => DefPathDataName::Anon { namespace: sym::opaque, kind: None }, + AnonAssocTy(..) => DefPathDataName::Anon { namespace: sym::anon_assoc, kind: None }, + SyntheticCoroutineBody => { + DefPathDataName::Anon { namespace: sym::synthetic, kind: None } + } + NestedStatic => DefPathDataName::Anon { namespace: sym::nested, kind: None }, } } } @@ -512,7 +525,10 @@ impl fmt::Display for DefPathData { match self.name() { DefPathDataName::Named(name) => f.write_str(name.as_str()), // FIXME(#70334): this will generate legacy {{closure}}, {{impl}}, etc - DefPathDataName::Anon { namespace } => write!(f, "{{{{{namespace}}}}}"), + DefPathDataName::Anon { namespace, kind: None } => write!(f, "{{{{{namespace}}}}}"), + DefPathDataName::Anon { namespace, kind: Some(n) } => { + write!(f, "{{{{{namespace}:{n}}}}}") + } } } } diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index a361679e8ad6a..d223ae78defad 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -889,7 +889,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) { } } } - DefKind::Closure => { + DefKind::Closure { .. } => { // This is guaranteed to be called by metadata encoding, // we still call it in wfcheck eagerly to ensure errors in codegen // attrs prevent lints from spamming the output. diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index b9124ea0e5ee6..732f5e5572974 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -2407,7 +2407,7 @@ fn lint_redundant_lifetimes<'tcx>( | DefKind::Field | DefKind::LifetimeParam | DefKind::GlobalAsm - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody => return, } diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 74739355e1fcb..8363d90244d35 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -2289,7 +2289,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { | DefKind::InlineConst | DefKind::Field | DefKind::Impl { .. } - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::ExternCrate | DefKind::GlobalAsm | DefKind::SyntheticCoroutineBody, diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index d74918235b6c3..010cec6a9ca4f 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -907,7 +907,7 @@ fn should_encode_span(def_kind: DefKind) -> bool { | DefKind::OpaqueTy | DefKind::Field | DefKind::Impl { .. } - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody => true, DefKind::ForeignMod | DefKind::GlobalAsm => false, } @@ -937,7 +937,7 @@ fn should_encode_attrs(def_kind: DefKind) -> bool { // closures from upstream crates, too. This is used by // https://github.com/model-checking/kani and is not a performance // or maintenance issue for us. - DefKind::Closure => true, + DefKind::Closure { .. } => true, DefKind::SyntheticCoroutineBody => false, DefKind::TyParam | DefKind::ConstParam @@ -985,7 +985,7 @@ fn should_encode_expn_that_defined(def_kind: DefKind) -> bool { | DefKind::Field | DefKind::LifetimeParam | DefKind::GlobalAsm - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody => false, } } @@ -1021,7 +1021,7 @@ fn should_encode_visibility(def_kind: DefKind) -> bool { | DefKind::OpaqueTy | DefKind::GlobalAsm | DefKind::Impl { .. } - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::ExternCrate | DefKind::SyntheticCoroutineBody => false, } @@ -1057,7 +1057,7 @@ fn should_encode_stability(def_kind: DefKind) -> bool { | DefKind::AnonConst | DefKind::InlineConst | DefKind::GlobalAsm - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::ExternCrate | DefKind::SyntheticCoroutineBody => false, } @@ -1100,10 +1100,10 @@ fn should_encode_mir( (true, false) } // Coroutines require optimized MIR to compute layout. - DefKind::Closure if tcx.is_coroutine(def_id.to_def_id()) => (false, true), + DefKind::Closure { coroutine_kind: Some(_) } => (false, true), DefKind::SyntheticCoroutineBody => (false, true), // Full-fledged functions + closures - DefKind::AssocFn | DefKind::Fn | DefKind::Closure => { + DefKind::AssocFn | DefKind::Fn | DefKind::Closure { .. } => { let generics = tcx.generics_of(def_id); let opt = tcx.sess.opts.unstable_opts.always_encode_mir || (tcx.sess.opts.output_types.should_codegen() @@ -1152,7 +1152,7 @@ fn should_encode_variances<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, def_kind: Def | DefKind::AnonConst | DefKind::InlineConst | DefKind::GlobalAsm - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::ExternCrate | DefKind::SyntheticCoroutineBody => false, DefKind::TyAlias => tcx.type_alias_is_lazy(def_id), @@ -1182,7 +1182,7 @@ fn should_encode_generics(def_kind: DefKind) -> bool { | DefKind::Impl { .. } | DefKind::Field | DefKind::TyParam - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody => true, DefKind::Mod | DefKind::ForeignMod @@ -1211,7 +1211,7 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) -> | DefKind::Impl { .. } | DefKind::AssocFn | DefKind::AssocConst - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::ConstParam | DefKind::AnonConst | DefKind::InlineConst @@ -1273,7 +1273,7 @@ fn should_encode_fn_sig(def_kind: DefKind) -> bool { | DefKind::ForeignTy | DefKind::Impl { .. } | DefKind::AssocConst - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::ConstParam | DefKind::AnonConst | DefKind::InlineConst @@ -1294,7 +1294,10 @@ fn should_encode_fn_sig(def_kind: DefKind) -> bool { fn should_encode_constness(def_kind: DefKind) -> bool { match def_kind { - DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Ctor(_, CtorKind::Fn) => true, + DefKind::Fn + | DefKind::AssocFn + | DefKind::Closure { .. } + | DefKind::Ctor(_, CtorKind::Fn) => true, DefKind::Struct | DefKind::Union @@ -1344,7 +1347,7 @@ fn should_encode_const(def_kind: DefKind) -> bool { | DefKind::ForeignTy | DefKind::Impl { .. } | DefKind::AssocFn - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::ConstParam | DefKind::AssocTy | DefKind::TyParam @@ -1537,12 +1540,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { self.encode_info_for_assoc_item(def_id); } } - if let DefKind::Closure | DefKind::SyntheticCoroutineBody = def_kind + if let DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody = def_kind && let Some(coroutine_kind) = self.tcx.coroutine_kind(def_id) { self.tables.coroutine_kind.set(def_id.index, Some(coroutine_kind)) } - if def_kind == DefKind::Closure + if matches!(def_kind, DefKind::Closure { .. }) && tcx.type_of(def_id).skip_binder().is_coroutine_closure() { let coroutine_for_closure = self.tcx.coroutine_for_closure(def_id); diff --git a/compiler/rustc_metadata/src/rmeta/table.rs b/compiler/rustc_metadata/src/rmeta/table.rs index 28f406fbc9629..3aecb069adf8d 100644 --- a/compiler/rustc_metadata/src/rmeta/table.rs +++ b/compiler/rustc_metadata/src/rmeta/table.rs @@ -1,4 +1,4 @@ -use rustc_hir::def::CtorOf; +use rustc_hir::def::{CoroutineDefKind, CtorOf}; use rustc_index::Idx; use crate::rmeta::*; @@ -154,7 +154,11 @@ fixed_size_enum! { ( GlobalAsm ) ( Impl { of_trait: false } ) ( Impl { of_trait: true } ) - ( Closure ) + ( Closure { coroutine_kind: None } ) + ( Closure { coroutine_kind: Some(CoroutineDefKind::Desugared(hir::CoroutineDesugaring::Async)) } ) + ( Closure { coroutine_kind: Some(CoroutineDefKind::Desugared(hir::CoroutineDesugaring::Gen)) } ) + ( Closure { coroutine_kind: Some(CoroutineDefKind::Desugared(hir::CoroutineDesugaring::AsyncGen)) } ) + ( Closure { coroutine_kind: Some(CoroutineDefKind::Coroutine) } ) ( Static { safety: hir::Safety::Unsafe, mutability: ast::Mutability::Not, nested: false } ) ( Static { safety: hir::Safety::Safe, mutability: ast::Mutability::Not, nested: false } ) ( Static { safety: hir::Safety::Unsafe, mutability: ast::Mutability::Mut, nested: false } ) diff --git a/compiler/rustc_middle/src/hir/map.rs b/compiler/rustc_middle/src/hir/map.rs index 291707878a342..fd5c0cafe32c1 100644 --- a/compiler/rustc_middle/src/hir/map.rs +++ b/compiler/rustc_middle/src/hir/map.rs @@ -294,7 +294,7 @@ impl<'tcx> TyCtxt<'tcx> { } DefKind::InlineConst => BodyOwnerKind::Const { inline: true }, DefKind::Ctor(..) | DefKind::Fn | DefKind::AssocFn => BodyOwnerKind::Fn, - DefKind::Closure | DefKind::SyntheticCoroutineBody => BodyOwnerKind::Closure, + DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody => BodyOwnerKind::Closure, DefKind::Static { safety: _, mutability, nested: false } => { BodyOwnerKind::Static(mutability) } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 457a4f4d5027a..e6d6e715b2ae2 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2059,7 +2059,7 @@ impl<'tcx> TyCtxt<'tcx> { // They have visibilities inherited from the module they are defined in. // Visibilities for opaque types are meaningless, but still provided // so that all items have visibilities. - if matches!(def_kind, DefKind::Closure | DefKind::OpaqueTy) { + if matches!(def_kind, DefKind::Closure { .. } | DefKind::OpaqueTy) { let parent_mod = self.parent_module_from_def_id(def_id).to_def_id(); feed.visibility(ty::Visibility::Restricted(parent_mod)); } diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index 68adfb3cdb388..2a4c2644c83d8 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -314,7 +314,7 @@ impl<'tcx> InstanceKind<'tcx> { }; matches!( tcx.def_key(def_id).disambiguated_data.data, - DefPathData::Ctor | DefPathData::Closure + DefPathData::Ctor | DefPathData::Closure { .. } ) } @@ -568,7 +568,7 @@ impl<'tcx> Instance<'tcx> { | DefKind::InlineConst | DefKind::Static { .. } | DefKind::Ctor(_, CtorKind::Fn) - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody, "`Instance::try_resolve` should only be used to resolve instances of \ functions, statics, and consts; to resolve associated types, use \ diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 84b21fee92fe4..28dd4bbff841a 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -2087,7 +2087,10 @@ impl<'tcx> TyCtxt<'tcx> { pub fn is_const_fn(self, def_id: DefId) -> bool { matches!( self.def_kind(def_id), - DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(_, CtorKind::Fn) | DefKind::Closure + DefKind::Fn + | DefKind::AssocFn + | DefKind::Ctor(_, CtorKind::Fn) + | DefKind::Closure { .. } ) && self.constness(def_id) == hir::Constness::Const } @@ -2137,7 +2140,7 @@ impl<'tcx> TyCtxt<'tcx> { // FIXME(const_trait_impl): ATPITs could be conditionally const? hir::OpaqueTyOrigin::TyAlias { .. } => false, }, - DefKind::Closure => { + DefKind::Closure { .. } => { // Closures and RPITs will eventually have const conditions // for `[const]` bounds. false diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index 9172c5d3ab752..f56b7153949bb 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -138,7 +138,7 @@ pub trait Printer<'tcx>: Sized { parent_args = &args[..generics.parent_count.min(args.len())]; match key.disambiguated_data.data { - DefPathData::Closure => { + DefPathData::Closure { .. } => { // We need to additionally print the `kind` field of a coroutine if // it is desugared from a coroutine-closure. if let Some(hir::CoroutineKind::Desugared( diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 1392d1d08fcb5..68f539437f7b4 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2193,7 +2193,7 @@ fn guess_def_namespace(tcx: TyCtxt<'_>, def_id: DefId) -> Namespace { DefPathData::ValueNs(..) | DefPathData::AnonConst - | DefPathData::Closure + | DefPathData::Closure { .. } | DefPathData::Ctor => Namespace::ValueNS, DefPathData::MacroNs(..) => Namespace::MacroNS, diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 3971ac13bbe05..947152a308259 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -656,7 +656,7 @@ impl<'tcx> Ty<'tcx> { | DefKind::LifetimeParam | DefKind::GlobalAsm | DefKind::Impl { .. } - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody => { bug!("not an adt: {def:?} ({:?})", tcx.def_kind(def.did())) } diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 69b8be3d9cbc3..7b794daa7c8d9 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -603,7 +603,7 @@ impl<'tcx> TyCtxt<'tcx> { // a corresponding `NodeId`, since those are not yet phased out). The parent of // the closure's `DefId` will also be the context where it appears. pub fn is_closure_like(self, def_id: DefId) -> bool { - matches!(self.def_kind(def_id), DefKind::Closure) + matches!(self.def_kind(def_id), DefKind::Closure { .. }) } /// Returns `true` if `def_id` refers to a definition that does not have its own @@ -611,7 +611,7 @@ impl<'tcx> TyCtxt<'tcx> { pub fn is_typeck_child(self, def_id: DefId) -> bool { matches!( self.def_kind(def_id), - DefKind::Closure | DefKind::InlineConst | DefKind::SyntheticCoroutineBody + DefKind::Closure { .. } | DefKind::InlineConst | DefKind::SyntheticCoroutineBody ) } @@ -769,7 +769,7 @@ impl<'tcx> TyCtxt<'tcx> { match def_kind { DefKind::AssocFn if self.associated_item(def_id).is_method() => "method", DefKind::AssocTy if self.opt_rpitit_info(def_id).is_some() => "opaque type", - DefKind::Closure if let Some(coroutine_kind) = self.coroutine_kind(def_id) => { + DefKind::Closure { .. } if let Some(coroutine_kind) = self.coroutine_kind(def_id) => { match coroutine_kind { hir::CoroutineKind::Desugared( hir::CoroutineDesugaring::Async, @@ -823,7 +823,7 @@ impl<'tcx> TyCtxt<'tcx> { pub fn def_kind_descr_article(self, def_kind: DefKind, def_id: DefId) -> &'static str { match def_kind { DefKind::AssocFn if self.associated_item(def_id).is_method() => "a", - DefKind::Closure if let Some(coroutine_kind) = self.coroutine_kind(def_id) => { + DefKind::Closure { .. } if let Some(coroutine_kind) = self.coroutine_kind(def_id) => { match coroutine_kind { hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Async, ..) => "an", hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::AsyncGen, ..) => "an", diff --git a/compiler/rustc_middle/src/values.rs b/compiler/rustc_middle/src/values.rs index 4d70a70873267..10fc8edad30f2 100644 --- a/compiler/rustc_middle/src/values.rs +++ b/compiler/rustc_middle/src/values.rs @@ -193,7 +193,7 @@ impl<'tcx, T> Value> for Result> && let Some(def_id) = cycle[0].query.def_id_for_ty_in_cycle && let Some(def_id) = def_id.as_local() && let def_kind = tcx.def_kind(def_id) - && matches!(def_kind, DefKind::Closure) + && matches!(def_kind, DefKind::Closure { .. }) && let Some(coroutine_kind) = tcx.coroutine_kind(def_id) { // FIXME: `def_span` for an fn-like coroutine will point to the fn's body diff --git a/compiler/rustc_mir_build/src/builder/mod.rs b/compiler/rustc_mir_build/src/builder/mod.rs index 3d5f6f4cf451e..be4fb98455488 100644 --- a/compiler/rustc_mir_build/src/builder/mod.rs +++ b/compiler/rustc_mir_build/src/builder/mod.rs @@ -460,7 +460,7 @@ fn construct_fn<'tcx>( .span(); let mut abi = fn_sig.abi; - if let DefKind::Closure = tcx.def_kind(fn_def) { + if let DefKind::Closure { .. } = tcx.def_kind(fn_def) { // HACK(eddyb) Avoid having RustCall on closures, // as it adds unnecessary (and wrong) auto-tupling. abi = ExternAbi::Rust; @@ -616,7 +616,7 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) - ); (sig.inputs().to_vec(), sig.output(), None) } - DefKind::Closure => { + DefKind::Closure { .. } => { let closure_ty = tcx.type_of(def_id).instantiate_identity(); match closure_ty.kind() { ty::Closure(_, args) => { diff --git a/compiler/rustc_mir_build/src/check_tail_calls.rs b/compiler/rustc_mir_build/src/check_tail_calls.rs index 18db8c1debb14..31a3bb6ed74ae 100644 --- a/compiler/rustc_mir_build/src/check_tail_calls.rs +++ b/compiler/rustc_mir_build/src/check_tail_calls.rs @@ -19,7 +19,7 @@ pub(crate) fn check_tail_calls(tcx: TyCtxt<'_>, def: LocalDefId) -> Result<(), E return Ok(()); } - let is_closure = matches!(tcx.def_kind(def), DefKind::Closure); + let is_closure = matches!(tcx.def_kind(def), DefKind::Closure { .. }); let caller_ty = tcx.type_of(def).skip_binder(); let mut visitor = TailCallCkVisitor { diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index 24d4136c64237..a1bf29b64d93d 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -124,7 +124,7 @@ impl<'tcx> ThirBuildCx<'tcx> { } fn closure_env_param(&self, owner_def: LocalDefId, expr_id: HirId) -> Option> { - if self.tcx.def_kind(owner_def) != DefKind::Closure { + if !matches!(self.tcx.def_kind(owner_def), DefKind::Closure { .. }) { return None; } diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 41fbabc253930..eabe14d98b745 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -53,7 +53,7 @@ pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), Err let origin = match tcx.def_kind(def_id) { DefKind::AssocFn | DefKind::Fn => "function argument", - DefKind::Closure => "closure argument", + DefKind::Closure { .. } => "closure argument", // other types of MIR don't have function parameters, and we don't need to // categorize those for the irrefutable check. _ if thir.params.is_empty() => "", diff --git a/compiler/rustc_mir_transform/src/cross_crate_inline.rs b/compiler/rustc_mir_transform/src/cross_crate_inline.rs index 6d7b7e10ef697..a2013ff185fc7 100644 --- a/compiler/rustc_mir_transform/src/cross_crate_inline.rs +++ b/compiler/rustc_mir_transform/src/cross_crate_inline.rs @@ -24,7 +24,9 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { // This just reproduces the logic from Instance::requires_inline. match tcx.def_kind(def_id) { - DefKind::Ctor(..) | DefKind::Closure | DefKind::SyntheticCoroutineBody => return true, + DefKind::Ctor(..) | DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody => { + return true; + } DefKind::Fn | DefKind::AssocFn => {} _ => return false, } diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 08f25276cecc1..9cc1c8e8edcc8 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -319,7 +319,7 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet { // Coroutine-closures (e.g. async closures) have an additional by-move MIR // body that isn't in the HIR. for body_owner in tcx.hir_body_owners() { - if let DefKind::Closure = tcx.def_kind(body_owner) + if let DefKind::Closure { .. } = tcx.def_kind(body_owner) && tcx.needs_coroutine_by_move_body_def_id(body_owner.to_def_id()) { set.insert(tcx.coroutine_by_move_body_def_id(body_owner).expect_local()); @@ -406,7 +406,7 @@ fn mir_promoted( // Also this means promotion can rely on all const checks having been done. let const_qualifs = match tcx.def_kind(def) { - DefKind::Fn | DefKind::AssocFn | DefKind::Closure + DefKind::Fn | DefKind::AssocFn | DefKind::Closure { .. } if tcx.constness(def) == hir::Constness::Const || tcx.is_const_default_method(def.to_def_id()) => { diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 798f4da9b3bbf..82c95901fe5bc 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -1522,7 +1522,7 @@ impl<'v> RootCollector<'_, 'v> { fn process_nested_body(&mut self, def_id: LocalDefId) { match self.tcx.def_kind(def_id) { - DefKind::Closure => { + DefKind::Closure { .. } => { if self.strategy == MonoItemCollectionStrategy::Eager && !self .tcx diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 963f4c77d809d..4a61296576580 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -636,7 +636,7 @@ impl<'tcx> EmbargoVisitor<'tcx> { | DefKind::Field | DefKind::GlobalAsm | DefKind::Impl { .. } - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody => (), } } diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 650a827ba5644..f21fb2503f613 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -261,7 +261,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | DefKind::Field | DefKind::LifetimeParam | DefKind::GlobalAsm - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody | DefKind::Impl { .. }, _, diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index 1e345b11c1466..3a1729c914c46 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -5,7 +5,7 @@ use rustc_ast::*; use rustc_attr_parsing::{AttributeParser, Early, OmitDoc}; use rustc_expand::expand::AstFragment; use rustc_hir as hir; -use rustc_hir::def::{CtorKind, CtorOf, DefKind}; +use rustc_hir::def::{CoroutineDefKind, CtorKind, CtorOf, DefKind}; use rustc_hir::def_id::LocalDefId; use rustc_middle::span_bug; use rustc_span::hygiene::LocalExpnId; @@ -222,8 +222,11 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { // then the closure_def will never be used, and we should avoid generating a // def-id for it. if let Some(body) = body { + let def_kind = DefKind::Closure { + coroutine_kind: Some(coroutine_def_kind(&coroutine_kind)), + }; let closure_def = - self.create_def(coroutine_kind.closure_id(), None, DefKind::Closure, span); + self.create_def(coroutine_kind.closure_id(), None, def_kind, span); self.with_parent(closure_def, |this| this.visit_block(body)); } } @@ -233,8 +236,12 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { // Async closures desugar to closures inside of closures, so // we must create two defs. + // This is the inner coroutine-ish closure, so we should include + // the coroutine info. + let def_kind = + DefKind::Closure { coroutine_kind: Some(coroutine_def_kind(coroutine_kind)) }; let coroutine_def = - self.create_def(coroutine_kind.closure_id(), None, DefKind::Closure, span); + self.create_def(coroutine_kind.closure_id(), None, def_kind, span); self.with_parent(coroutine_def, |this| this.visit_expr(body)); } _ => visit::walk_fn(self, fn_kind), @@ -361,8 +368,30 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { fn visit_expr(&mut self, expr: &'a Expr) { let parent_def = match expr.kind { ExprKind::MacCall(..) => return self.visit_macro_invoc(expr.id), - ExprKind::Closure(..) | ExprKind::Gen(..) => { - self.create_def(expr.id, None, DefKind::Closure, expr.span) + ExprKind::Closure(ref closure) => { + let coroutine_kind = match closure.coroutine_kind { + // A closure may actually be a coroutine if it has the `#[coroutine]` attr. + // This is more like an `async {}` or `gen {}` block in that it's actually the + // coroutine (instead of async/gen closures, where the desugared inner closure + // is the real coroutine). So we should include the coroutine kind here. + None if has_coroutine_attr(&expr.attrs) => Some(CoroutineDefKind::Coroutine), + // For async/gen closures (`async || ...` / `gen || ...`), the desugared inner + // closure will have `coroutine_kind = Some(_)`. This is the outer closure, so + // we should not include it. + _ => None, + }; + + self.create_def(expr.id, None, DefKind::Closure { coroutine_kind }, expr.span) + } + ExprKind::Gen(_, _, ref gen_kind, _) => { + let desugaring = match gen_kind { + GenBlockKind::Async => hir::CoroutineDesugaring::Async, + GenBlockKind::Gen => hir::CoroutineDesugaring::Gen, + GenBlockKind::AsyncGen => hir::CoroutineDesugaring::AsyncGen, + }; + let coroutine_kind = Some(CoroutineDefKind::Desugared(desugaring)); + + self.create_def(expr.id, None, DefKind::Closure { coroutine_kind }, expr.span) } ExprKind::ConstBlock(ref constant) => { for attr in &expr.attrs { @@ -509,3 +538,17 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { } } } + +fn coroutine_def_kind(coroutine_kind: &CoroutineKind) -> CoroutineDefKind { + let desugaring = match coroutine_kind { + CoroutineKind::Async { .. } => hir::CoroutineDesugaring::Async, + CoroutineKind::Gen { .. } => hir::CoroutineDesugaring::Gen, + CoroutineKind::AsyncGen { .. } => hir::CoroutineDesugaring::AsyncGen, + }; + + CoroutineDefKind::Desugared(desugaring) +} + +fn has_coroutine_attr(attrs: &[Attribute]) -> bool { + attrs.iter().any(|attr| attr.has_name(sym::coroutine)) +} diff --git a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs index 9d1d3412f8d23..57332e58c9f27 100644 --- a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs +++ b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs @@ -712,7 +712,7 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String { hir::definitions::DefPathData::ForeignMod => "F", // Not specified in v0's hir::definitions::DefPathData::TypeNs(..) => "t", hir::definitions::DefPathData::ValueNs(..) => "v", - hir::definitions::DefPathData::Closure => "C", + hir::definitions::DefPathData::Closure { .. } => "C", hir::definitions::DefPathData::Ctor => "c", hir::definitions::DefPathData::AnonConst => "k", hir::definitions::DefPathData::OpaqueTy => "i", diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 64fe181c26d48..a18070e15cd04 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -146,9 +146,10 @@ pub(crate) fn new_item_kind(kind: DefKind) -> ItemKind { | DefKind::GlobalAsm => { unreachable!("Not a valid item kind: {kind:?}"); } - DefKind::Closure | DefKind::AssocFn | DefKind::Fn | DefKind::SyntheticCoroutineBody => { - ItemKind::Fn - } + DefKind::Closure { .. } + | DefKind::AssocFn + | DefKind::Fn + | DefKind::SyntheticCoroutineBody => ItemKind::Fn, DefKind::Const | DefKind::InlineConst | DefKind::AssocConst | DefKind::AnonConst => { ItemKind::Const } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 4b8762d0dd1c2..f9e8246a4ddcd 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -510,6 +510,7 @@ symbols! { async_fn_track_caller, async_fn_traits, async_for_loop, + async_gen, async_iterator, async_iterator_poll_next, async_trait_bounds, diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index 12d1de463136a..3e93159e4a043 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -30,7 +30,7 @@ pub(super) fn mangle<'tcx>( match key.disambiguated_data.data { DefPathData::TypeNs(_) | DefPathData::ValueNs(_) - | DefPathData::Closure + | DefPathData::Closure { .. } | DefPathData::SyntheticCoroutineBody => { instance_ty = tcx.type_of(ty_def_id).instantiate_identity(); debug!(?instance_ty); diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs index a9bf5eae445e4..660ead3ebf20f 100644 --- a/compiler/rustc_symbol_mangling/src/lib.rs +++ b/compiler/rustc_symbol_mangling/src/lib.rs @@ -266,7 +266,7 @@ fn compute_symbol_name<'tcx>( tcx.def_kind(instance.def_id()), DefKind::Fn | DefKind::AssocFn - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody | DefKind::Ctor(..) ) && matches!( diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index 1db8ad72b321c..a913418e851da 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -872,7 +872,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> { // Uppercase categories are more stable than lowercase ones. DefPathData::TypeNs(_) => 't', DefPathData::ValueNs(_) => 'v', - DefPathData::Closure => 'C', + DefPathData::Closure { .. } => 'C', DefPathData::Ctor => 'c', DefPathData::AnonConst => 'k', DefPathData::OpaqueTy => 'i', diff --git a/compiler/rustc_ty_utils/src/implied_bounds.rs b/compiler/rustc_ty_utils/src/implied_bounds.rs index 6fa763f18ef19..5d0a403b1b880 100644 --- a/compiler/rustc_ty_utils/src/implied_bounds.rs +++ b/compiler/rustc_ty_utils/src/implied_bounds.rs @@ -146,7 +146,7 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<' | DefKind::Field | DefKind::LifetimeParam | DefKind::GlobalAsm - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody => { span_bug!( tcx.def_span(def_id), diff --git a/compiler/rustc_ty_utils/src/opaque_types.rs b/compiler/rustc_ty_utils/src/opaque_types.rs index 3b4482146d4f1..a76a2fa9725a2 100644 --- a/compiler/rustc_ty_utils/src/opaque_types.rs +++ b/compiler/rustc_ty_utils/src/opaque_types.rs @@ -324,7 +324,7 @@ fn opaque_types_defined_by<'tcx>( // Note that we also support `SyntheticCoroutineBody` since we create // a MIR body for the def kind, and some MIR passes (like promotion) // may require doing analysis using its typing env. - DefKind::Closure | DefKind::InlineConst | DefKind::SyntheticCoroutineBody => { + DefKind::Closure { .. } | DefKind::InlineConst | DefKind::SyntheticCoroutineBody => { collector.opaques.extend(tcx.opaque_types_defined_by(tcx.local_parent(item))); } DefKind::AssocTy | DefKind::TyAlias | DefKind::GlobalAsm => {} diff --git a/compiler/rustc_ty_utils/src/sig_types.rs b/compiler/rustc_ty_utils/src/sig_types.rs index dc6009116ac57..e871caf865d1f 100644 --- a/compiler/rustc_ty_utils/src/sig_types.rs +++ b/compiler/rustc_ty_utils/src/sig_types.rs @@ -84,7 +84,7 @@ pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>( // These are not part of a public API, they can only appear as hidden types, and there // the interesting parts are solely in the signature of the containing item's opaque type // or dyn type. - DefKind::InlineConst | DefKind::Closure | DefKind::SyntheticCoroutineBody => {} + DefKind::InlineConst | DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody => {} DefKind::Impl { of_trait } => { if of_trait { let span = tcx.hir_node_by_def_id(item).expect_item().expect_impl().of_trait.unwrap().path.span; diff --git a/src/librustdoc/formats/item_type.rs b/src/librustdoc/formats/item_type.rs index 3aba7a370adb2..1e9757c2577eb 100644 --- a/src/librustdoc/formats/item_type.rs +++ b/src/librustdoc/formats/item_type.rs @@ -157,7 +157,7 @@ impl ItemType { | DefKind::LifetimeParam | DefKind::GlobalAsm | DefKind::Impl { .. } - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::SyntheticCoroutineBody => Self::ForeignType, } } diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index ca6f67eb6dfd6..e74523ca48cca 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -2046,7 +2046,7 @@ fn resolution_failure( } Variant | Field - | Closure + | Closure { .. } | AssocTy | AssocConst | AssocFn diff --git a/src/tools/clippy/clippy_lints/src/manual_float_methods.rs b/src/tools/clippy/clippy_lints/src/manual_float_methods.rs index bd2785fea2709..efcf12f36c61f 100644 --- a/src/tools/clippy/clippy_lints/src/manual_float_methods.rs +++ b/src/tools/clippy/clippy_lints/src/manual_float_methods.rs @@ -126,7 +126,7 @@ fn is_not_const(tcx: TyCtxt<'_>, def_id: DefId) -> bool { | DefKind::Ctor(..) | DefKind::AssocConst => false, - DefKind::Fn | DefKind::AssocFn | DefKind::Closure => tcx.constness(def_id) == Constness::NotConst, + DefKind::Fn | DefKind::AssocFn | DefKind::Closure { .. } => tcx.constness(def_id) == Constness::NotConst, } } diff --git a/src/tools/clippy/clippy_lints/src/missing_doc.rs b/src/tools/clippy/clippy_lints/src/missing_doc.rs index 7772051eb5c61..cea612e1d8bf5 100644 --- a/src/tools/clippy/clippy_lints/src/missing_doc.rs +++ b/src/tools/clippy/clippy_lints/src/missing_doc.rs @@ -119,7 +119,7 @@ impl MissingDoc { && let DefKind::AnonConst | DefKind::AssocConst | DefKind::AssocFn - | DefKind::Closure + | DefKind::Closure { .. } | DefKind::Const | DefKind::Fn | DefKind::InlineConst diff --git a/tests/codegen-units/item-collection/closures.rs b/tests/codegen-units/item-collection/closures.rs index 9d537814baf64..01a9e6e453e63 100644 --- a/tests/codegen-units/item-collection/closures.rs +++ b/tests/codegen-units/item-collection/closures.rs @@ -2,7 +2,7 @@ //@ compile-flags: -Clink-dead-code --crate-type=lib //~ MONO_ITEM fn async_fn @@ -//~ MONO_ITEM fn async_fn::{closure#0} @@ +//~ MONO_ITEM fn async_fn::{closure:async#0} @@ pub async fn async_fn() {} //~ MONO_ITEM fn closure @@ diff --git a/tests/codegen/issues/issue-98678-closure-coroutine.rs b/tests/codegen/issues/issue-98678-closure-coroutine.rs index 8763bcb799ded..0062836317823 100644 --- a/tests/codegen/issues/issue-98678-closure-coroutine.rs +++ b/tests/codegen/issues/issue-98678-closure-coroutine.rs @@ -18,8 +18,8 @@ pub fn foo() { let closure = |x| x; closure(0); - // NONMSVC-DAG: !DICompositeType({{.*"[{]}}coroutine_env#1{{[}]".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 3]], - // MSVC-DAG: !DICompositeType({{.*".*foo::}}coroutine_env$1>{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 2]], + // NONMSVC-DAG: !DICompositeType({{.*"[{]}}coroutine_env#0{{[}]".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 3]], + // MSVC-DAG: !DICompositeType({{.*".*foo::}}coroutine_env$0>{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 2]], let _coroutine = #[coroutine] || yield 1; } diff --git a/tests/coverage/async.cov-map b/tests/coverage/async.cov-map index c528ad525b5f4..e861c7abcaa3b 100644 --- a/tests/coverage/async.cov-map +++ b/tests/coverage/async.cov-map @@ -7,7 +7,7 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 11, 1) to (start + 0, 24) Highest counter ID seen: c0 -Function name: async::c::{closure#0} +Function name: async::c::{closure:async#0} Raw bytes (31): 0x[01, 01, 01, 01, 05, 05, 01, 0b, 19, 00, 1a, 01, 01, 08, 00, 0e, 05, 01, 09, 00, 0a, 02, 02, 09, 00, 0a, 01, 02, 01, 00, 02] Number of files: 1 - file 0 => $DIR/async.rs @@ -31,7 +31,7 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 19, 1) to (start + 0, 19) Highest counter ID seen: c0 -Function name: async::d::{closure#0} +Function name: async::d::{closure:async#0} Raw bytes (19): 0x[01, 01, 00, 03, 01, 13, 14, 00, 15, 01, 00, 16, 00, 17, 01, 00, 18, 00, 19] Number of files: 1 - file 0 => $DIR/async.rs @@ -51,7 +51,7 @@ Number of file 0 mappings: 1 - Code(Zero) at (prev + 21, 1) to (start + 0, 19) Highest counter ID seen: (none) -Function name: async::e::{closure#0} (unused) +Function name: async::e::{closure:async#0} (unused) Raw bytes (19): 0x[01, 01, 00, 03, 00, 15, 14, 00, 15, 00, 00, 16, 00, 17, 00, 00, 18, 00, 19] Number of files: 1 - file 0 => $DIR/async.rs @@ -71,7 +71,7 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 23, 1) to (start + 0, 19) Highest counter ID seen: c0 -Function name: async::f::{closure#0} +Function name: async::f::{closure:async#0} Raw bytes (19): 0x[01, 01, 00, 03, 01, 17, 14, 00, 15, 01, 00, 16, 00, 17, 01, 00, 18, 00, 19] Number of files: 1 - file 0 => $DIR/async.rs @@ -91,7 +91,7 @@ Number of file 0 mappings: 1 - Code(Zero) at (prev + 25, 1) to (start + 0, 29) Highest counter ID seen: (none) -Function name: async::foo::{closure#0} (unused) +Function name: async::foo::{closure:async#0} (unused) Raw bytes (19): 0x[01, 01, 00, 03, 00, 19, 1e, 00, 1f, 00, 00, 20, 00, 2b, 00, 00, 2c, 00, 2d] Number of files: 1 - file 0 => $DIR/async.rs @@ -111,7 +111,7 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 27, 1) to (start + 0, 22) Highest counter ID seen: c0 -Function name: async::g::{closure#0} (unused) +Function name: async::g::{closure:async#0} (unused) Raw bytes (64): 0x[01, 01, 00, 0c, 00, 1b, 17, 00, 18, 00, 01, 0b, 00, 0c, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02] Number of files: 1 - file 0 => $DIR/async.rs @@ -140,7 +140,7 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 35, 1) to (start + 0, 21) Highest counter ID seen: c0 -Function name: async::h::{closure#0} (unused) +Function name: async::h::{closure:async#0} (unused) Raw bytes (44): 0x[01, 01, 00, 08, 00, 23, 16, 00, 17, 00, 03, 0b, 00, 0c, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 19, 00, 00, 1a, 00, 1b, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02] Number of files: 1 - file 0 => $DIR/async.rs @@ -165,7 +165,7 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 44, 1) to (start + 0, 18) Highest counter ID seen: c0 -Function name: async::i::{closure#0} +Function name: async::i::{closure:async#0} Raw bytes (75): 0x[01, 01, 03, 05, 09, 11, 15, 0d, 11, 0d, 01, 2c, 13, 00, 14, 01, 04, 0b, 00, 0c, 09, 01, 09, 00, 0a, 01, 00, 0e, 00, 0f, 01, 00, 0e, 00, 18, 05, 00, 1c, 00, 21, 09, 00, 27, 00, 30, 15, 01, 09, 00, 0a, 02, 00, 0e, 00, 17, 11, 00, 1b, 00, 20, 15, 00, 24, 00, 26, 06, 01, 0e, 00, 10, 0b, 02, 01, 00, 02] Number of files: 1 - file 0 => $DIR/async.rs @@ -293,7 +293,7 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 89, 1) to (start + 0, 24) Highest counter ID seen: c0 -Function name: async::m::{closure#0} (unused) +Function name: async::m::{closure:async#0} (unused) Raw bytes (19): 0x[01, 01, 00, 03, 00, 59, 19, 00, 1a, 00, 00, 1b, 00, 20, 00, 00, 21, 00, 22] Number of files: 1 - file 0 => $DIR/async.rs diff --git a/tests/coverage/async2.cov-map b/tests/coverage/async2.cov-map index cc62951709802..58063d88abd5d 100644 --- a/tests/coverage/async2.cov-map +++ b/tests/coverage/async2.cov-map @@ -7,7 +7,7 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 15, 1) to (start + 0, 22) Highest counter ID seen: c0 -Function name: async2::async_func::{closure#0} +Function name: async2::async_func::{closure:async#0} Raw bytes (49): 0x[01, 01, 00, 09, 01, 0f, 17, 00, 18, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 26, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 11, 01, 01, 08, 00, 09, 01, 00, 0a, 02, 06, 00, 02, 05, 00, 06, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/async2.rs @@ -33,7 +33,7 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 23, 1) to (start + 0, 35) Highest counter ID seen: c0 -Function name: async2::async_func_just_println::{closure#0} +Function name: async2::async_func_just_println::{closure:async#0} Raw bytes (24): 0x[01, 01, 00, 04, 01, 17, 24, 00, 25, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 33, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/async2.rs diff --git a/tests/coverage/async_block.cov-map b/tests/coverage/async_block.cov-map index 07d4c0eb3cd60..bdfc1d2907ee8 100644 --- a/tests/coverage/async_block.cov-map +++ b/tests/coverage/async_block.cov-map @@ -18,7 +18,7 @@ Number of file 0 mappings: 7 - Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2) Highest counter ID seen: c1 -Function name: async_block::main::{closure#0} +Function name: async_block::main::{closure:async#0} Raw bytes (31): 0x[01, 01, 01, 01, 05, 05, 01, 09, 1c, 00, 1d, 01, 01, 10, 00, 17, 05, 00, 18, 02, 0e, 02, 02, 14, 02, 0e, 01, 03, 09, 00, 0a] Number of files: 1 - file 0 => $DIR/async_block.rs diff --git a/tests/coverage/async_closure.cov-map b/tests/coverage/async_closure.cov-map index 9f8dc8d6cbbae..9f0549553d2f9 100644 --- a/tests/coverage/async_closure.cov-map +++ b/tests/coverage/async_closure.cov-map @@ -7,7 +7,7 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 6, 1) to (start + 0, 42) Highest counter ID seen: c0 -Function name: async_closure::call_once::::{closure#0} +Function name: async_closure::call_once::::{closure:async#0} Raw bytes (21): 0x[01, 01, 01, 05, 09, 03, 01, 06, 2b, 00, 2c, 01, 01, 05, 00, 0e, 02, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/async_closure.rs @@ -56,7 +56,7 @@ Number of file 0 mappings: 2 - Code(Counter(0)) at (prev + 0, 35) to (start + 0, 36) Highest counter ID seen: c0 -Function name: async_closure::main::{closure#0}::{closure#0}:: +Function name: async_closure::main::{closure#0}::{closure:async#0}:: Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 22, 00, 23, 01, 00, 23, 00, 24] Number of files: 1 - file 0 => $DIR/async_closure.rs diff --git a/tests/coverage/async_closure.coverage b/tests/coverage/async_closure.coverage index 14f043415eaca..c8cddd8a39d9a 100644 --- a/tests/coverage/async_closure.coverage +++ b/tests/coverage/async_closure.coverage @@ -17,7 +17,7 @@ | async_closure::main::{closure#0}: | LL| 1| let async_closure = async || {}; ------------------ - | async_closure::main::{closure#0}::{closure#0}::: + | async_closure::main::{closure#0}::{closure:async#0}::: | LL| 1| let async_closure = async || {}; ------------------ LL| 1| executor::block_on(async_closure()); diff --git a/tests/coverage/await_ready.cov-map b/tests/coverage/await_ready.cov-map index a7eb051ff0938..d38689f03b2f5 100644 --- a/tests/coverage/await_ready.cov-map +++ b/tests/coverage/await_ready.cov-map @@ -7,7 +7,7 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 14, 1) to (start + 0, 29) Highest counter ID seen: c0 -Function name: await_ready::await_ready::{closure#0} +Function name: await_ready::await_ready::{closure:async#0} Raw bytes (21): 0x[01, 01, 01, 05, 09, 03, 01, 0e, 1e, 00, 1f, 01, 02, 05, 01, 0f, 02, 02, 01, 00, 02] Number of files: 1 - file 0 => $DIR/await_ready.rs diff --git a/tests/coverage/closure_macro_async.cov-map b/tests/coverage/closure_macro_async.cov-map index b5f4cee0ec445..df80fdca77d34 100644 --- a/tests/coverage/closure_macro_async.cov-map +++ b/tests/coverage/closure_macro_async.cov-map @@ -18,7 +18,7 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 37, 1) to (start + 0, 42) Highest counter ID seen: c0 -Function name: closure_macro_async::test::{closure#0} +Function name: closure_macro_async::test::{closure:async#0} Raw bytes (66): 0x[01, 01, 01, 01, 05, 0c, 01, 25, 2b, 00, 2c, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 20, 02, 01, 09, 00, 0f, 01, 00, 12, 00, 1b, 01, 00, 1c, 00, 34, 05, 00, 54, 00, 55, 02, 02, 09, 00, 1f, 02, 00, 22, 00, 2e, 02, 01, 0d, 00, 2d, 02, 01, 05, 00, 0b, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/closure_macro_async.rs @@ -44,7 +44,7 @@ Number of file 0 mappings: 12 - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c1 -Function name: closure_macro_async::test::{closure#0}::{closure#0} +Function name: closure_macro_async::test::{closure:async#0}::{closure#0} Raw bytes (60): 0x[01, 01, 03, 01, 05, 01, 0b, 05, 09, 0a, 01, 14, 1c, 00, 1d, 01, 02, 11, 00, 18, 01, 00, 1b, 00, 22, 01, 01, 10, 00, 21, 05, 01, 11, 00, 19, 05, 00, 1a, 00, 1e, 05, 01, 11, 00, 27, 02, 02, 11, 00, 16, 06, 00, 17, 00, 1e, 01, 02, 09, 00, 0a] Number of files: 1 - file 0 => $DIR/closure_macro_async.rs diff --git a/tests/coverage/coroutine.cov-map b/tests/coverage/coroutine.cov-map index daa42915a4af5..86521755b3dbe 100644 --- a/tests/coverage/coroutine.cov-map +++ b/tests/coverage/coroutine.cov-map @@ -42,7 +42,7 @@ Number of file 0 mappings: 17 - Code(Counter(2)) at (prev + 2, 1) to (start + 0, 2) Highest counter ID seen: c3 -Function name: coroutine::main::{closure#0} +Function name: coroutine::main::{closure:coroutine#0} Raw bytes (24): 0x[01, 01, 00, 04, 01, 16, 08, 00, 09, 01, 01, 09, 00, 1f, 05, 01, 10, 00, 15, 05, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/coroutine.rs diff --git a/tests/coverage/holes.cov-map b/tests/coverage/holes.cov-map index c2158c4415068..4651eabf90546 100644 --- a/tests/coverage/holes.cov-map +++ b/tests/coverage/holes.cov-map @@ -68,7 +68,7 @@ Number of file 0 mappings: 4 - Code(Zero) at (prev + 1, 9) to (start + 0, 10) Highest counter ID seen: (none) -Function name: holes::main::{closure#1} (unused) +Function name: holes::main::{closure:async#0} (unused) Raw bytes (19): 0x[01, 01, 00, 03, 00, 4b, 09, 00, 0a, 00, 01, 0d, 00, 12, 00, 01, 09, 00, 0a] Number of files: 1 - file 0 => $DIR/holes.rs diff --git a/tests/coverage/yield.cov-map b/tests/coverage/yield.cov-map index 87d0a0472615f..e2378dfbf12bd 100644 --- a/tests/coverage/yield.cov-map +++ b/tests/coverage/yield.cov-map @@ -41,7 +41,7 @@ Number of file 0 mappings: 25 = (c4 - c5) Highest counter ID seen: c5 -Function name: yield::main::{closure#0} +Function name: yield::main::{closure:coroutine#0} Raw bytes (24): 0x[01, 01, 00, 04, 01, 09, 08, 00, 09, 01, 01, 09, 00, 10, 05, 01, 10, 00, 15, 05, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/yield.rs @@ -53,7 +53,7 @@ Number of file 0 mappings: 4 - Code(Counter(1)) at (prev + 1, 5) to (start + 0, 6) Highest counter ID seen: c1 -Function name: yield::main::{closure#1} +Function name: yield::main::{closure:coroutine#1} Raw bytes (34): 0x[01, 01, 00, 06, 01, 18, 08, 00, 09, 01, 01, 09, 00, 10, 05, 01, 09, 00, 10, 09, 01, 09, 00, 10, 0d, 01, 10, 00, 15, 0d, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/yield.rs diff --git a/tests/debuginfo/issue-57822.rs b/tests/debuginfo/issue-57822.rs index 7abac1c14d327..08f18b65b8dc3 100644 --- a/tests/debuginfo/issue-57822.rs +++ b/tests/debuginfo/issue-57822.rs @@ -12,7 +12,7 @@ // gdb-check:$1 = issue_57822::main::{closure_env#1} {f: issue_57822::main::{closure_env#0} {x: 1}} // gdb-command:print b -// gdb-check:$2 = issue_57822::main::{coroutine_env#3}::Unresumed{a: issue_57822::main::{coroutine_env#2}::Unresumed{y: 2}} +// gdb-check:$2 = issue_57822::main::{coroutine_env#1}::Unresumed{a: issue_57822::main::{coroutine_env#0}::Unresumed{y: 2}} // === LLDB TESTS ================================================================================== @@ -22,7 +22,7 @@ // lldb-check:(issue_57822::main::{closure_env#1}) g = { f = { x = 1 } } // lldb-command:v b -// lldb-check:(issue_57822::main::{coroutine_env#3}) b = { value = { a = { value = { y = 2 } $discr$ = '\x02' } } $discr$ = '\x02' } +// lldb-check:(issue_57822::main::{coroutine_env#1}) b = { value = { a = { value = { y = 2 } $discr$ = '\x02' } } $discr$ = '\x02' } #![feature(omit_gdb_pretty_printer_section, coroutines, coroutine_trait, stmt_expr_attributes)] #![omit_gdb_pretty_printer_section] diff --git a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure:async#0}.built.after.mir similarity index 87% rename from tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir rename to tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure:async#0}.built.after.mir index b43af549b232c..7af4a0d9f220c 100644 --- a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir +++ b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure:async#0}.built.after.mir @@ -1,6 +1,6 @@ -// MIR for `foo::{closure#0}::{closure#0}` after built +// MIR for `foo::{closure#0}::{closure:async#0}` after built -fn foo::{closure#0}::{closure#0}(_1: {async closure body@$DIR/async_closure_fake_read_for_by_move.rs:12:27: 15:6}, _2: ResumeTy) -> () +fn foo::{closure#0}::{closure:async#0}(_1: {async closure body@$DIR/async_closure_fake_read_for_by_move.rs:12:27: 15:6}, _2: ResumeTy) -> () yields () { debug _task_context => _2; diff --git a/tests/mir-opt/async_closure_fake_read_for_by_move.rs b/tests/mir-opt/async_closure_fake_read_for_by_move.rs index e78671f5e9d56..ecfb1a01b88cc 100644 --- a/tests/mir-opt/async_closure_fake_read_for_by_move.rs +++ b/tests/mir-opt/async_closure_fake_read_for_by_move.rs @@ -6,7 +6,7 @@ enum Foo { Baz, } -// EMIT_MIR async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir +// EMIT_MIR async_closure_fake_read_for_by_move.foo-{closure#0}-{closure:async#0}.built.after.mir // EMIT_MIR async_closure_fake_read_for_by_move.foo-{closure#0}-{synthetic#0}.built.after.mir fn foo(f: &Foo) { let x = async move || match f { diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.mir deleted file mode 100644 index a984845fd2c11..0000000000000 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.mir +++ /dev/null @@ -1,10 +0,0 @@ -// MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_move - -fn main::{closure#0}::{closure#0}(_1: {async closure@$DIR/async_closure_shims.rs:53:33: 53:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10} { - let mut _0: {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10}; - - bb0: { - _0 = {coroutine@$DIR/async_closure_shims.rs:53:53: 56:10 (#0)} { a: move _2, b: move (_1.0: i32) }; - return; - } -} diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_move.0.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_move.0.mir deleted file mode 100644 index aab9f7b03b9ab..0000000000000 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_move.0.mir +++ /dev/null @@ -1,10 +0,0 @@ -// MIR for `main::{closure#0}::{closure#1}` 0 coroutine_closure_by_move - -fn main::{closure#0}::{closure#1}(_1: {async closure@$DIR/async_closure_shims.rs:62:33: 62:47}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10} { - let mut _0: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}; - - bb0: { - _0 = {coroutine@$DIR/async_closure_shims.rs:62:48: 65:10 (#0)} { a: move _2, b: move (_1.0: &i32) }; - return; - } -} diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_ref.0.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_ref.0.mir deleted file mode 100644 index 3fdc81791deef..0000000000000 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_ref.0.mir +++ /dev/null @@ -1,10 +0,0 @@ -// MIR for `main::{closure#0}::{closure#1}` 0 coroutine_closure_by_ref - -fn main::{closure#0}::{closure#1}(_1: &{async closure@$DIR/async_closure_shims.rs:62:33: 62:47}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10} { - let mut _0: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}; - - bb0: { - _0 = {coroutine@$DIR/async_closure_shims.rs:62:48: 65:10 (#0)} { a: move _2, b: copy ((*_1).0: &i32) }; - return; - } -} diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.built.after.mir b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#0}-{closure:async#0}.built.after.mir similarity index 80% rename from tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.built.after.mir rename to tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#0}-{closure:async#0}.built.after.mir index 4d484b16b5072..0464c6a961814 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.built.after.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#0}-{closure:async#0}.built.after.mir @@ -1,6 +1,6 @@ -// MIR for `main::{closure#0}::{closure#0}::{closure#0}` after built +// MIR for `main::{closure:async#0}::{closure#0}::{closure:async#0}` after built -fn main::{closure#0}::{closure#0}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10}, _2: ResumeTy) -> () +fn main::{closure:async#0}::{closure#0}::{closure:async#0}(_1: {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10}, _2: ResumeTy) -> () yields () { debug _task_context => _2; diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{synthetic#0}.built.after.mir b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#0}-{synthetic#0}.built.after.mir similarity index 80% rename from tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{synthetic#0}.built.after.mir rename to tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#0}-{synthetic#0}.built.after.mir index ace780f773e89..74c37008fd9cf 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{synthetic#0}.built.after.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#0}-{synthetic#0}.built.after.mir @@ -1,6 +1,6 @@ -// MIR for `main::{closure#0}::{closure#0}::{synthetic#0}` after built +// MIR for `main::{closure:async#0}::{closure#0}::{synthetic#0}` after built -fn main::{closure#0}::{closure#0}::{synthetic#0}(_1: {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10}, _2: ResumeTy) -> () +fn main::{closure:async#0}::{closure#0}::{synthetic#0}(_1: {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10}, _2: ResumeTy) -> () yields () { debug _task_context => _2; diff --git a/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#0}.coroutine_closure_by_move.0.mir b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#0}.coroutine_closure_by_move.0.mir new file mode 100644 index 0000000000000..4d6fea118dc30 --- /dev/null +++ b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#0}.coroutine_closure_by_move.0.mir @@ -0,0 +1,10 @@ +// MIR for `main::{closure:async#0}::{closure#0}` 0 coroutine_closure_by_move + +fn main::{closure:async#0}::{closure#0}(_1: {async closure@$DIR/async_closure_shims.rs:53:33: 53:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10} { + let mut _0: {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10}; + + bb0: { + _0 = {coroutine@$DIR/async_closure_shims.rs:53:53: 56:10 (#0)} { a: move _2, b: move (_1.0: i32) }; + return; + } +} diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.built.after.mir b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#1}-{closure:async#0}.built.after.mir similarity index 80% rename from tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.built.after.mir rename to tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#1}-{closure:async#0}.built.after.mir index f50ad689f447e..6d4be497849ae 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.built.after.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#1}-{closure:async#0}.built.after.mir @@ -1,6 +1,6 @@ -// MIR for `main::{closure#0}::{closure#1}::{closure#0}` after built +// MIR for `main::{closure:async#0}::{closure#1}::{closure:async#0}` after built -fn main::{closure#0}::{closure#1}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}, _2: ResumeTy) -> () +fn main::{closure:async#0}::{closure#1}::{closure:async#0}(_1: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}, _2: ResumeTy) -> () yields () { debug _task_context => _2; diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{synthetic#0}.built.after.mir b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#1}-{synthetic#0}.built.after.mir similarity index 80% rename from tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{synthetic#0}.built.after.mir rename to tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#1}-{synthetic#0}.built.after.mir index 62d8adeedcb64..8fa156359aae6 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{synthetic#0}.built.after.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#1}-{synthetic#0}.built.after.mir @@ -1,6 +1,6 @@ -// MIR for `main::{closure#0}::{closure#1}::{synthetic#0}` after built +// MIR for `main::{closure:async#0}::{closure#1}::{synthetic#0}` after built -fn main::{closure#0}::{closure#1}::{synthetic#0}(_1: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}, _2: ResumeTy) -> () +fn main::{closure:async#0}::{closure#1}::{synthetic#0}(_1: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}, _2: ResumeTy) -> () yields () { debug _task_context => _2; diff --git a/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#1}.coroutine_closure_by_move.0.mir b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#1}.coroutine_closure_by_move.0.mir new file mode 100644 index 0000000000000..f4fcc006612fe --- /dev/null +++ b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#1}.coroutine_closure_by_move.0.mir @@ -0,0 +1,10 @@ +// MIR for `main::{closure:async#0}::{closure#1}` 0 coroutine_closure_by_move + +fn main::{closure:async#0}::{closure#1}(_1: {async closure@$DIR/async_closure_shims.rs:62:33: 62:47}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10} { + let mut _0: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}; + + bb0: { + _0 = {coroutine@$DIR/async_closure_shims.rs:62:48: 65:10 (#0)} { a: move _2, b: move (_1.0: &i32) }; + return; + } +} diff --git a/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#1}.coroutine_closure_by_ref.0.mir b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#1}.coroutine_closure_by_ref.0.mir new file mode 100644 index 0000000000000..29cb40436fb11 --- /dev/null +++ b/tests/mir-opt/async_closure_shims.main-{closure:async#0}-{closure#1}.coroutine_closure_by_ref.0.mir @@ -0,0 +1,10 @@ +// MIR for `main::{closure:async#0}::{closure#1}` 0 coroutine_closure_by_ref + +fn main::{closure:async#0}::{closure#1}(_1: &{async closure@$DIR/async_closure_shims.rs:62:33: 62:47}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10} { + let mut _0: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}; + + bb0: { + _0 = {coroutine@$DIR/async_closure_shims.rs:62:48: 65:10 (#0)} { a: move _2, b: copy ((*_1).0: &i32) }; + return; + } +} diff --git a/tests/mir-opt/async_closure_shims.rs b/tests/mir-opt/async_closure_shims.rs index 93cc7834a643f..004cf572db60e 100644 --- a/tests/mir-opt/async_closure_shims.rs +++ b/tests/mir-opt/async_closure_shims.rs @@ -40,13 +40,13 @@ async fn call_normal_mut>(f: &mut impl FnMut(i32) -> F) { f(1).await; } -// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.mir -// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.built.after.mir -// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#0}-{synthetic#0}.built.after.mir -// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_ref.0.mir -// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_move.0.mir -// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.built.after.mir -// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#1}-{synthetic#0}.built.after.mir +// EMIT_MIR async_closure_shims.main-{closure:async#0}-{closure#0}.coroutine_closure_by_move.0.mir +// EMIT_MIR async_closure_shims.main-{closure:async#0}-{closure#0}-{closure:async#0}.built.after.mir +// EMIT_MIR async_closure_shims.main-{closure:async#0}-{closure#0}-{synthetic#0}.built.after.mir +// EMIT_MIR async_closure_shims.main-{closure:async#0}-{closure#1}.coroutine_closure_by_ref.0.mir +// EMIT_MIR async_closure_shims.main-{closure:async#0}-{closure#1}.coroutine_closure_by_move.0.mir +// EMIT_MIR async_closure_shims.main-{closure:async#0}-{closure#1}-{closure:async#0}.built.after.mir +// EMIT_MIR async_closure_shims.main-{closure:async#0}-{closure#1}-{synthetic#0}.built.after.mir pub fn main() { block_on(async { let b = 2i32; diff --git a/tests/mir-opt/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-abort.mir b/tests/mir-opt/async_drop_live_dead.a-{closure:async#0}.coroutine_drop_async.0.panic-abort.mir similarity index 100% rename from tests/mir-opt/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-abort.mir rename to tests/mir-opt/async_drop_live_dead.a-{closure:async#0}.coroutine_drop_async.0.panic-abort.mir diff --git a/tests/mir-opt/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-unwind.mir b/tests/mir-opt/async_drop_live_dead.a-{closure:async#0}.coroutine_drop_async.0.panic-unwind.mir similarity index 94% rename from tests/mir-opt/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-unwind.mir rename to tests/mir-opt/async_drop_live_dead.a-{closure:async#0}.coroutine_drop_async.0.panic-unwind.mir index b1cf5373f9191..c7a14ccc28d92 100644 --- a/tests/mir-opt/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-unwind.mir +++ b/tests/mir-opt/async_drop_live_dead.a-{closure:async#0}.coroutine_drop_async.0.panic-unwind.mir @@ -1,6 +1,6 @@ -// MIR for `a::{closure#0}` 0 coroutine_drop_async +// MIR for `a::{closure:async#0}` 0 coroutine_drop_async -fn a::{closure#0}(_1: Pin<&mut {async fn body of a()}>, _2: &mut Context<'_>) -> Poll<()> { +fn a::{closure:async#0}(_1: Pin<&mut {async fn body of a()}>, _2: &mut Context<'_>) -> Poll<()> { debug _task_context => _19; debug x => ((*(_1.0: &mut {async fn body of a()})).0: T); let mut _0: std::task::Poll<()>; diff --git a/tests/mir-opt/async_drop_live_dead.rs b/tests/mir-opt/async_drop_live_dead.rs index 348866bbb8c75..ea326f4220c77 100644 --- a/tests/mir-opt/async_drop_live_dead.rs +++ b/tests/mir-opt/async_drop_live_dead.rs @@ -5,7 +5,7 @@ #![feature(async_drop)] #![allow(incomplete_features)] -// EMIT_MIR async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.mir +// EMIT_MIR async_drop_live_dead.a-{closure:async#0}.coroutine_drop_async.0.mir async fn a(x: T) {} fn main() {} diff --git a/tests/mir-opt/building/async_await.a-{closure#0}.coroutine_resume.0.mir b/tests/mir-opt/building/async_await.a-{closure:async#0}.coroutine_resume.0.mir similarity index 86% rename from tests/mir-opt/building/async_await.a-{closure#0}.coroutine_resume.0.mir rename to tests/mir-opt/building/async_await.a-{closure:async#0}.coroutine_resume.0.mir index 7480324b17791..5e2d7878685f9 100644 --- a/tests/mir-opt/building/async_await.a-{closure#0}.coroutine_resume.0.mir +++ b/tests/mir-opt/building/async_await.a-{closure:async#0}.coroutine_resume.0.mir @@ -1,4 +1,4 @@ -// MIR for `a::{closure#0}` 0 coroutine_resume +// MIR for `a::{closure:async#0}` 0 coroutine_resume /* coroutine_layout = CoroutineLayout { field_tys: {}, variant_fields: { @@ -9,7 +9,7 @@ storage_conflicts: BitMatrix(0x0) {}, } */ -fn a::{closure#0}(_1: Pin<&mut {async fn body of a()}>, _2: &mut Context<'_>) -> Poll<()> { +fn a::{closure:async#0}(_1: Pin<&mut {async fn body of a()}>, _2: &mut Context<'_>) -> Poll<()> { debug _task_context => _4; let mut _0: std::task::Poll<()>; let mut _3: (); diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure:async#0}.coroutine_resume.0.mir similarity index 96% rename from tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir rename to tests/mir-opt/building/async_await.b-{closure:async#0}.coroutine_resume.0.mir index 109a41d1ef907..73f226aef5a89 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure:async#0}.coroutine_resume.0.mir @@ -1,16 +1,16 @@ -// MIR for `b::{closure#0}` 0 coroutine_resume +// MIR for `b::{closure:async#0}` 0 coroutine_resume /* coroutine_layout = CoroutineLayout { field_tys: { _0: CoroutineSavedTy { ty: Coroutine( - DefId(0:5 ~ async_await[ccf8]::a::{closure#0}), + DefId(0:5 ~ async_await[ccf8]::a::{closure:async#0}), [ (), std::future::ResumeTy, (), (), CoroutineWitness( - DefId(0:5 ~ async_await[ccf8]::a::{closure#0}), + DefId(0:5 ~ async_await[ccf8]::a::{closure:async#0}), [], ), (), @@ -24,14 +24,14 @@ }, _1: CoroutineSavedTy { ty: Coroutine( - DefId(0:5 ~ async_await[ccf8]::a::{closure#0}), + DefId(0:5 ~ async_await[ccf8]::a::{closure:async#0}), [ (), std::future::ResumeTy, (), (), CoroutineWitness( - DefId(0:5 ~ async_await[ccf8]::a::{closure#0}), + DefId(0:5 ~ async_await[ccf8]::a::{closure:async#0}), [], ), (), @@ -57,7 +57,7 @@ }, } */ -fn b::{closure#0}(_1: Pin<&mut {async fn body of b()}>, _2: &mut Context<'_>) -> Poll<()> { +fn b::{closure:async#0}(_1: Pin<&mut {async fn body of b()}>, _2: &mut Context<'_>) -> Poll<()> { debug _task_context => _38; let mut _0: std::task::Poll<()>; let _3: (); diff --git a/tests/mir-opt/building/async_await.rs b/tests/mir-opt/building/async_await.rs index 6c44570d109c2..bed201a09d553 100644 --- a/tests/mir-opt/building/async_await.rs +++ b/tests/mir-opt/building/async_await.rs @@ -8,10 +8,10 @@ #![crate_type = "lib"] -// EMIT_MIR async_await.a-{closure#0}.coroutine_resume.0.mir +// EMIT_MIR async_await.a-{closure:async#0}.coroutine_resume.0.mir async fn a() {} -// EMIT_MIR async_await.b-{closure#0}.coroutine_resume.0.mir +// EMIT_MIR async_await.b-{closure:async#0}.coroutine_resume.0.mir pub async fn b() { a().await; a().await diff --git a/tests/mir-opt/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir b/tests/mir-opt/coroutine_drop_cleanup.main-{closure:coroutine#0}.coroutine_drop.0.panic-abort.mir similarity index 84% rename from tests/mir-opt/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir rename to tests/mir-opt/coroutine_drop_cleanup.main-{closure:coroutine#0}.coroutine_drop.0.panic-abort.mir index 7e033916fd348..ce889711ff2f8 100644 --- a/tests/mir-opt/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir +++ b/tests/mir-opt/coroutine_drop_cleanup.main-{closure:coroutine#0}.coroutine_drop.0.panic-abort.mir @@ -1,6 +1,6 @@ -// MIR for `main::{closure#0}` 0 coroutine_drop +// MIR for `main::{closure:coroutine#0}` 0 coroutine_drop -fn main::{closure#0}(_1: *mut {coroutine@$DIR/coroutine_drop_cleanup.rs:12:5: 12:7}) -> () { +fn main::{closure:coroutine#0}(_1: *mut {coroutine@$DIR/coroutine_drop_cleanup.rs:12:5: 12:7}) -> () { let mut _0: (); let mut _2: (); let _3: std::string::String; diff --git a/tests/mir-opt/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir b/tests/mir-opt/coroutine_drop_cleanup.main-{closure:coroutine#0}.coroutine_drop.0.panic-unwind.mir similarity index 86% rename from tests/mir-opt/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir rename to tests/mir-opt/coroutine_drop_cleanup.main-{closure:coroutine#0}.coroutine_drop.0.panic-unwind.mir index 613ef2909b5e4..b999e88a25cce 100644 --- a/tests/mir-opt/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir +++ b/tests/mir-opt/coroutine_drop_cleanup.main-{closure:coroutine#0}.coroutine_drop.0.panic-unwind.mir @@ -1,6 +1,6 @@ -// MIR for `main::{closure#0}` 0 coroutine_drop +// MIR for `main::{closure:coroutine#0}` 0 coroutine_drop -fn main::{closure#0}(_1: *mut {coroutine@$DIR/coroutine_drop_cleanup.rs:12:5: 12:7}) -> () { +fn main::{closure:coroutine#0}(_1: *mut {coroutine@$DIR/coroutine_drop_cleanup.rs:12:5: 12:7}) -> () { let mut _0: (); let mut _2: (); let _3: std::string::String; diff --git a/tests/mir-opt/coroutine_drop_cleanup.rs b/tests/mir-opt/coroutine_drop_cleanup.rs index 4ae97273cd90a..d9feb6c9dcd73 100644 --- a/tests/mir-opt/coroutine_drop_cleanup.rs +++ b/tests/mir-opt/coroutine_drop_cleanup.rs @@ -6,7 +6,7 @@ // Regression test for #58892, coroutine drop shims should not have blocks // spuriously marked as cleanup -// EMIT_MIR coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.mir +// EMIT_MIR coroutine_drop_cleanup.main-{closure:coroutine#0}.coroutine_drop.0.mir fn main() { let gen_ = #[coroutine] || { diff --git a/tests/mir-opt/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-abort.mir b/tests/mir-opt/coroutine_storage_dead_unwind.main-{closure:coroutine#0}.StateTransform.before.panic-abort.mir similarity index 89% rename from tests/mir-opt/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-abort.mir rename to tests/mir-opt/coroutine_storage_dead_unwind.main-{closure:coroutine#0}.StateTransform.before.panic-abort.mir index 4731aed335d9f..acbba05c03d08 100644 --- a/tests/mir-opt/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-abort.mir +++ b/tests/mir-opt/coroutine_storage_dead_unwind.main-{closure:coroutine#0}.StateTransform.before.panic-abort.mir @@ -1,6 +1,6 @@ -// MIR for `main::{closure#0}` before StateTransform +// MIR for `main::{closure:coroutine#0}` before StateTransform -fn main::{closure#0}(_1: {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}, _2: ()) -> () +fn main::{closure:coroutine#0}(_1: {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}, _2: ()) -> () yields () { let mut _0: (); diff --git a/tests/mir-opt/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir b/tests/mir-opt/coroutine_storage_dead_unwind.main-{closure:coroutine#0}.StateTransform.before.panic-unwind.mir similarity index 92% rename from tests/mir-opt/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir rename to tests/mir-opt/coroutine_storage_dead_unwind.main-{closure:coroutine#0}.StateTransform.before.panic-unwind.mir index 14e1782b86016..acc0a88dc2850 100644 --- a/tests/mir-opt/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir +++ b/tests/mir-opt/coroutine_storage_dead_unwind.main-{closure:coroutine#0}.StateTransform.before.panic-unwind.mir @@ -1,6 +1,6 @@ -// MIR for `main::{closure#0}` before StateTransform +// MIR for `main::{closure:coroutine#0}` before StateTransform -fn main::{closure#0}(_1: {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}, _2: ()) -> () +fn main::{closure:coroutine#0}(_1: {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}, _2: ()) -> () yields () { let mut _0: (); diff --git a/tests/mir-opt/coroutine_storage_dead_unwind.rs b/tests/mir-opt/coroutine_storage_dead_unwind.rs index ce9bad483af83..4e183a96c2e2e 100644 --- a/tests/mir-opt/coroutine_storage_dead_unwind.rs +++ b/tests/mir-opt/coroutine_storage_dead_unwind.rs @@ -18,7 +18,7 @@ struct Bar(i32); fn take(_x: T) {} -// EMIT_MIR coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir +// EMIT_MIR coroutine_storage_dead_unwind.main-{closure:coroutine#0}.StateTransform.before.mir fn main() { let _gen = #[coroutine] || { diff --git a/tests/mir-opt/coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir b/tests/mir-opt/coroutine_tiny.main-{closure:coroutine#0}.coroutine_resume.0.mir similarity index 91% rename from tests/mir-opt/coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir rename to tests/mir-opt/coroutine_tiny.main-{closure:coroutine#0}.coroutine_resume.0.mir index f8b3f68d21e63..5c7c839f7fc0c 100644 --- a/tests/mir-opt/coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir +++ b/tests/mir-opt/coroutine_tiny.main-{closure:coroutine#0}.coroutine_resume.0.mir @@ -1,4 +1,4 @@ -// MIR for `main::{closure#0}` 0 coroutine_resume +// MIR for `main::{closure:coroutine#0}` 0 coroutine_resume /* coroutine_layout = CoroutineLayout { field_tys: { _0: CoroutineSavedTy { @@ -21,7 +21,7 @@ }, } */ -fn main::{closure#0}(_1: Pin<&mut {coroutine@$DIR/coroutine_tiny.rs:21:5: 21:13}>, _2: u8) -> CoroutineState<(), ()> { +fn main::{closure:coroutine#0}(_1: Pin<&mut {coroutine@$DIR/coroutine_tiny.rs:21:5: 21:13}>, _2: u8) -> CoroutineState<(), ()> { debug _x => _10; let mut _0: std::ops::CoroutineState<(), ()>; let _3: HasDrop; diff --git a/tests/mir-opt/coroutine_tiny.rs b/tests/mir-opt/coroutine_tiny.rs index 81e9940541ba0..73581fd760429 100644 --- a/tests/mir-opt/coroutine_tiny.rs +++ b/tests/mir-opt/coroutine_tiny.rs @@ -15,7 +15,7 @@ impl Drop for HasDrop { fn callee() {} -// EMIT_MIR coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir +// EMIT_MIR coroutine_tiny.main-{closure:coroutine#0}.coroutine_resume.0.mir fn main() { let _gen = #[coroutine] |_x: u8| { diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff index 151580da19e09..4c9d6af4a8fe4 100644 --- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff @@ -18,7 +18,7 @@ + scope 4 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}>::new_unchecked) { + } + } -+ scope 5 (inlined g::{closure#0}) { ++ scope 5 (inlined g::{closure:coroutine#0}) { + debug a => _5; + let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; + let mut _7: u32; diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff index 6196fc0d0c6bf..5f76e9a10d05d 100644 --- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff @@ -18,7 +18,7 @@ + scope 4 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}>::new_unchecked) { + } + } -+ scope 5 (inlined g::{closure#0}) { ++ scope 5 (inlined g::{closure:coroutine#0}) { + debug a => _5; + let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; + let mut _7: u32; diff --git a/tests/mir-opt/inline/inline_coroutine.rs b/tests/mir-opt/inline/inline_coroutine.rs index 07f8fb20f7ea2..828158090ce2e 100644 --- a/tests/mir-opt/inline/inline_coroutine.rs +++ b/tests/mir-opt/inline/inline_coroutine.rs @@ -9,7 +9,7 @@ use std::pin::Pin; fn main() { // CHECK-LABEL: fn main( // CHECK: (inlined g) - // CHECK: (inlined g::{closure#0}) + // CHECK: (inlined g::{closure:coroutine#0}) let _r = Pin::new(&mut g()).resume(false); } diff --git a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff index 1e9a6dd4f5c8f..975a7a6989936 100644 --- a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff +++ b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff @@ -20,7 +20,7 @@ debug fut => _4; scope 3 { } -+ scope 6 (inlined ActionPermit::<'_, T>::perform::{closure#0}) { ++ scope 6 (inlined ActionPermit::<'_, T>::perform::{closure:async#0}) { + let _11: ActionPermit<'_, T>; + let mut _12: std::future::Ready<()>; + let mut _13: std::future::Ready<()>; diff --git a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff index 94b89a310baa8..f2e8b41c52c84 100644 --- a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff @@ -20,7 +20,7 @@ debug fut => _4; scope 3 { } -+ scope 6 (inlined ActionPermit::<'_, T>::perform::{closure#0}) { ++ scope 6 (inlined ActionPermit::<'_, T>::perform::{closure:async#0}) { + let _11: ActionPermit<'_, T>; + let mut _12: std::future::Ready<()>; + let mut _13: std::future::Ready<()>; diff --git a/tests/ui/async-await/async-closures/def-path.rs b/tests/ui/async-await/async-closures/def-path.rs index 838556966e865..8986e78656c86 100644 --- a/tests/ui/async-await/async-closures/def-path.rs +++ b/tests/ui/async-await/async-closures/def-path.rs @@ -6,7 +6,7 @@ fn main() { //~^ NOTE the expected `async` closure body let () = x(); //~^ ERROR mismatched types - //~| NOTE this expression has type `{static main::{closure#0}::{closure#0}< + //~| NOTE this expression has type `{static main::{closure#0}::{closure:async#0}< //~| NOTE expected `async` closure body, found `()` - //~| NOTE expected `async` closure body `{static main::{closure#0}::{closure#0}< + //~| NOTE expected `async` closure body `{static main::{closure#0}::{closure:async#0}< } diff --git a/tests/ui/async-await/async-closures/def-path.stderr b/tests/ui/async-await/async-closures/def-path.stderr index b50e353b6988e..825466d570edb 100644 --- a/tests/ui/async-await/async-closures/def-path.stderr +++ b/tests/ui/async-await/async-closures/def-path.stderr @@ -5,11 +5,11 @@ LL | let x = async || {}; | -- the expected `async` closure body LL | LL | let () = x(); - | ^^ --- this expression has type `{static main::{closure#0}::{closure#0} upvar_tys=?16t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?5t}` + | ^^ --- this expression has type `{static main::{closure#0}::{closure:async#0} upvar_tys=?16t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?5t}` | | | expected `async` closure body, found `()` | - = note: expected `async` closure body `{static main::{closure#0}::{closure#0} upvar_tys=?16t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?5t}` + = note: expected `async` closure body `{static main::{closure#0}::{closure:async#0} upvar_tys=?16t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?5t}` found unit type `()` error: aborting due to 1 previous error diff --git a/tests/ui/coroutine/def-path.rs b/tests/ui/coroutine/def-path.rs new file mode 100644 index 0000000000000..001ac9c2842e4 --- /dev/null +++ b/tests/ui/coroutine/def-path.rs @@ -0,0 +1,11 @@ +//@ compile-flags: -Zverbose-internals + +#![feature(coroutines, stmt_expr_attributes)] + +fn main() { + let x = #[coroutine] || {}; + //~^ NOTE `x` has type `{main::{closure:coroutine#0} upvar_tys=?3t resume_ty=() yield_ty=?4t return_ty=() witness=?5t}` + let () = x(); + //~^ ERROR expected function, found `{main::{closure:coroutine#0} upvar_tys=?3t resume_ty=() yield_ty=?4t return_ty=() witness=?5t}` + //~| NOTE call expression requires function +} diff --git a/tests/ui/coroutine/def-path.stderr b/tests/ui/coroutine/def-path.stderr new file mode 100644 index 0000000000000..3bfdf80386ed9 --- /dev/null +++ b/tests/ui/coroutine/def-path.stderr @@ -0,0 +1,14 @@ +error[E0618]: expected function, found `{main::{closure:coroutine#0} upvar_tys=?3t resume_ty=() yield_ty=?4t return_ty=() witness=?5t}` + --> $DIR/def-path.rs:8:14 + | +LL | let x = #[coroutine] || {}; + | - `x` has type `{main::{closure:coroutine#0} upvar_tys=?3t resume_ty=() yield_ty=?4t return_ty=() witness=?5t}` +LL | +LL | let () = x(); + | ^-- + | | + | call expression requires function + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0618`. diff --git a/tests/ui/coroutine/print/coroutine-print-verbose-2.stderr b/tests/ui/coroutine/print/coroutine-print-verbose-2.stderr index 8877d45dddad2..f52f36887e3b9 100644 --- a/tests/ui/coroutine/print/coroutine-print-verbose-2.stderr +++ b/tests/ui/coroutine/print/coroutine-print-verbose-2.stderr @@ -9,7 +9,7 @@ LL | | drop(a); LL | | }); | |______^ coroutine is not `Sync` | - = help: within `{main::{closure#0} upvar_tys=() resume_ty=() yield_ty=() return_ty=() witness={main::{closure#0}}}`, the trait `Sync` is not implemented for `NotSync` + = help: within `{main::{closure:coroutine#0} upvar_tys=() resume_ty=() yield_ty=() return_ty=() witness={main::{closure:coroutine#0}}}`, the trait `Sync` is not implemented for `NotSync` note: coroutine is not `Sync` as this value is used across a yield --> $DIR/coroutine-print-verbose-2.rs:20:9 | @@ -34,7 +34,7 @@ LL | | drop(a); LL | | }); | |______^ coroutine is not `Send` | - = help: within `{main::{closure#1} upvar_tys=() resume_ty=() yield_ty=() return_ty=() witness={main::{closure#1}}}`, the trait `Send` is not implemented for `NotSend` + = help: within `{main::{closure:coroutine#1} upvar_tys=() resume_ty=() yield_ty=() return_ty=() witness={main::{closure:coroutine#1}}}`, the trait `Send` is not implemented for `NotSend` note: coroutine is not `Send` as this value is used across a yield --> $DIR/coroutine-print-verbose-2.rs:27:9 | diff --git a/tests/ui/coroutine/print/coroutine-print-verbose-3.stderr b/tests/ui/coroutine/print/coroutine-print-verbose-3.stderr index 2f9f20cf1ffbf..fba8040582aa8 100644 --- a/tests/ui/coroutine/print/coroutine-print-verbose-3.stderr +++ b/tests/ui/coroutine/print/coroutine-print-verbose-3.stderr @@ -11,7 +11,7 @@ LL | | }; | |_____^ expected `()`, found coroutine | = note: expected unit type `()` - found coroutine `{main::{closure#0} upvar_tys=?4t resume_ty=() yield_ty=i32 return_ty=&'?1 str witness=?6t}` + found coroutine `{main::{closure:coroutine#0} upvar_tys=?4t resume_ty=() yield_ty=i32 return_ty=&'?1 str witness=?6t}` error: aborting due to 1 previous error diff --git a/tests/ui/force-inlining/deny-async.stderr b/tests/ui/force-inlining/deny-async.stderr index d6516ed875c21..89fa3fb1e852e 100644 --- a/tests/ui/force-inlining/deny-async.stderr +++ b/tests/ui/force-inlining/deny-async.stderr @@ -20,7 +20,7 @@ LL | pub fn callee_justified() { | = note: incompatible due to: #[rustc_no_mir_inline] -error: `callee` could not be inlined into `async_caller::{closure#0}` but is required to be inlined +error: `callee` could not be inlined into `async_caller::{closure:async#0}` but is required to be inlined --> $DIR/deny-async.rs:22:5 | LL | callee(); @@ -28,7 +28,7 @@ LL | callee(); | = note: could not be inlined due to: #[rustc_no_mir_inline] -error: `callee_justified` could not be inlined into `async_caller::{closure#0}` but is required to be inlined +error: `callee_justified` could not be inlined into `async_caller::{closure:async#0}` but is required to be inlined --> $DIR/deny-async.rs:24:5 | LL | callee_justified(); diff --git a/tests/ui/pattern/non-structural-match-types-cycle-err.stderr b/tests/ui/pattern/non-structural-match-types-cycle-err.stderr index 2f4ac63fc570a..89e72128d9eee 100644 --- a/tests/ui/pattern/non-structural-match-types-cycle-err.stderr +++ b/tests/ui/pattern/non-structural-match-types-cycle-err.stderr @@ -16,12 +16,12 @@ LL | const NONE: Option = None; | ^^^^^^^^^^^^^^^^^^^^^ = note: ...which requires computing layout of `core::option::Option<{async block@$DIR/non-structural-match-types-cycle-err.rs:18:16: 18:21}>`... = note: ...which requires computing layout of `{async block@$DIR/non-structural-match-types-cycle-err.rs:18:16: 18:21}`... -note: ...which requires optimizing MIR for `defines::{closure#0}`... +note: ...which requires optimizing MIR for `defines::{closure:async#0}`... --> $DIR/non-structural-match-types-cycle-err.rs:18:16 | LL | match Some(async {}) { | ^^^^^ -note: ...which requires elaborating drops for `defines::{closure#0}`... +note: ...which requires elaborating drops for `defines::{closure:async#0}`... --> $DIR/non-structural-match-types-cycle-err.rs:18:16 | LL | match Some(async {}) { diff --git a/tests/ui/stable-mir-print/async-closure.stdout b/tests/ui/stable-mir-print/async-closure.stdout index 12e7a5530ace6..af35e6aa127a1 100644 --- a/tests/ui/stable-mir-print/async-closure.stdout +++ b/tests/ui/stable-mir-print/async-closure.stdout @@ -24,7 +24,7 @@ fn foo::{closure#0}(_1: &{async closure@$DIR/async-closure.rs:9:13: 9:21}) -> {a return; } } -fn foo::{closure#0}::{closure#0}(_1: Pin<&mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}>, _2: &mut Context<'_>) -> Poll<()> { +fn foo::{closure#0}::{closure:async#0}(_1: Pin<&mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}>, _2: &mut Context<'_>) -> Poll<()> { let mut _0: Poll<()>; let _3: i32; let mut _4: &i32;