Encode synthetic by-move coroutine body with a different DefPathData
This commit is contained in:
parent
46424fb505
commit
897acc3e5d
17 changed files with 67 additions and 32 deletions
|
@ -294,7 +294,7 @@ impl DefKind {
|
|||
DefKind::GlobalAsm => DefPathData::GlobalAsm,
|
||||
DefKind::Impl { .. } => DefPathData::Impl,
|
||||
DefKind::Closure => DefPathData::Closure,
|
||||
DefKind::SyntheticCoroutineBody => DefPathData::Closure,
|
||||
DefKind::SyntheticCoroutineBody => DefPathData::SyntheticCoroutineBody,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -291,6 +291,8 @@ pub enum DefPathData {
|
|||
/// An existential `impl Trait` type node.
|
||||
/// Argument position `impl Trait` have a `TypeNs` with their pretty-printed name.
|
||||
OpaqueTy,
|
||||
/// A synthetic body for a coroutine's by-move body.
|
||||
SyntheticCoroutineBody,
|
||||
}
|
||||
|
||||
impl Definitions {
|
||||
|
@ -415,8 +417,16 @@ impl DefPathData {
|
|||
|
||||
ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name),
|
||||
|
||||
Impl | ForeignMod | CrateRoot | Use | GlobalAsm | Closure | Ctor | AnonConst
|
||||
| OpaqueTy => None,
|
||||
Impl
|
||||
| ForeignMod
|
||||
| CrateRoot
|
||||
| Use
|
||||
| GlobalAsm
|
||||
| Closure
|
||||
| Ctor
|
||||
| AnonConst
|
||||
| OpaqueTy
|
||||
| SyntheticCoroutineBody => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -441,6 +451,7 @@ impl DefPathData {
|
|||
Ctor => DefPathDataName::Anon { namespace: sym::constructor },
|
||||
AnonConst => DefPathDataName::Anon { namespace: sym::constant },
|
||||
OpaqueTy => DefPathDataName::Anon { namespace: sym::opaque },
|
||||
SyntheticCoroutineBody => DefPathDataName::Anon { namespace: sym::synthetic },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1930,10 +1930,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
// As a consequence, this LocalDefId is always re-created before it is needed by the incr.
|
||||
// comp. engine itself.
|
||||
//
|
||||
// This call also writes to the value of `source_span` and `expn_that_defined` queries.
|
||||
// This call also writes to the value of the `source_span` query.
|
||||
// This is fine because:
|
||||
// - those queries are `eval_always` so we won't miss their result changing;
|
||||
// - this write will have happened before these queries are called.
|
||||
// - that query is `eval_always` so we won't miss its result changing;
|
||||
// - this write will have happened before that query is called.
|
||||
let def_id = self.untracked.definitions.write().create_def(parent, data);
|
||||
|
||||
// This function modifies `self.definitions` using a side-effect.
|
||||
|
|
|
@ -139,8 +139,7 @@ pub trait Printer<'tcx>: Sized {
|
|||
|
||||
match key.disambiguated_data.data {
|
||||
DefPathData::Closure => {
|
||||
// FIXME(async_closures): This is somewhat ugly.
|
||||
// We need to additionally print the `kind` field of a closure if
|
||||
// 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(
|
||||
_,
|
||||
|
@ -156,6 +155,10 @@ pub trait Printer<'tcx>: Sized {
|
|||
// Closures' own generics are only captures, don't print them.
|
||||
}
|
||||
}
|
||||
DefPathData::SyntheticCoroutineBody => {
|
||||
// Synthetic coroutine bodies have no distinct generics, since like
|
||||
// closures they're all just internal state of the coroutine.
|
||||
}
|
||||
// This covers both `DefKind::AnonConst` and `DefKind::InlineConst`.
|
||||
// Anon consts doesn't have their own generics, and inline consts' own
|
||||
// generics are their inferred types, so don't print them.
|
||||
|
|
|
@ -66,6 +66,7 @@ pub struct MarkFrame<'a> {
|
|||
parent: Option<&'a MarkFrame<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) enum DepNodeColor {
|
||||
Red,
|
||||
Green(DepNodeIndex),
|
||||
|
@ -909,7 +910,7 @@ impl<D: Deps> DepGraphData<D> {
|
|||
self.try_mark_previous_green(qcx, parent_dep_node_index, dep_dep_node, frame);
|
||||
|
||||
if node_index.is_some() {
|
||||
debug!("managed to MARK dependency {dep_dep_node:?} as green",);
|
||||
debug!("managed to MARK dependency {dep_dep_node:?} as green");
|
||||
return Some(());
|
||||
}
|
||||
}
|
||||
|
@ -930,7 +931,7 @@ impl<D: Deps> DepGraphData<D> {
|
|||
return Some(());
|
||||
}
|
||||
Some(DepNodeColor::Red) => {
|
||||
debug!("dependency {dep_dep_node:?} was red after forcing",);
|
||||
debug!("dependency {dep_dep_node:?} was red after forcing");
|
||||
return None;
|
||||
}
|
||||
None => {}
|
||||
|
@ -950,7 +951,7 @@ impl<D: Deps> DepGraphData<D> {
|
|||
// invalid state will not be persisted to the
|
||||
// incremental compilation cache because of
|
||||
// compilation errors being present.
|
||||
debug!("dependency {dep_dep_node:?} resulted in compilation error",);
|
||||
debug!("dependency {dep_dep_node:?} resulted in compilation error");
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
@ -716,6 +716,7 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String {
|
|||
hir::definitions::DefPathData::Ctor => "c",
|
||||
hir::definitions::DefPathData::AnonConst => "k",
|
||||
hir::definitions::DefPathData::OpaqueTy => "i",
|
||||
hir::definitions::DefPathData::SyntheticCoroutineBody => "s",
|
||||
hir::definitions::DefPathData::CrateRoot
|
||||
| hir::definitions::DefPathData::Use
|
||||
| hir::definitions::DefPathData::GlobalAsm
|
||||
|
|
|
@ -28,7 +28,10 @@ pub(super) fn mangle<'tcx>(
|
|||
loop {
|
||||
let key = tcx.def_key(ty_def_id);
|
||||
match key.disambiguated_data.data {
|
||||
DefPathData::TypeNs(_) | DefPathData::ValueNs(_) | DefPathData::Closure => {
|
||||
DefPathData::TypeNs(_)
|
||||
| DefPathData::ValueNs(_)
|
||||
| DefPathData::Closure
|
||||
| DefPathData::SyntheticCoroutineBody => {
|
||||
instance_ty = tcx.type_of(ty_def_id).instantiate_identity();
|
||||
debug!(?instance_ty);
|
||||
break;
|
||||
|
|
|
@ -850,6 +850,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
|
|||
DefPathData::Ctor => 'c',
|
||||
DefPathData::AnonConst => 'k',
|
||||
DefPathData::OpaqueTy => 'i',
|
||||
DefPathData::SyntheticCoroutineBody => 's',
|
||||
|
||||
// These should never show up as `path_append` arguments.
|
||||
DefPathData::CrateRoot
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue