Skip to content

Commit 4187560

Browse files
committed
Add comments for new AdtDef functions.
1 parent 4691471 commit 4187560

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/librustc/ty/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,6 +2146,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
21462146
debug!("found non-exhaustive variant list for {:?}", did);
21472147
flags = flags | AdtFlags::IS_VARIANT_LIST_NON_EXHAUSTIVE;
21482148
}
2149+
21492150
flags |= match kind {
21502151
AdtKind::Enum => AdtFlags::IS_ENUM,
21512152
AdtKind::Union => AdtFlags::IS_UNION,
@@ -2299,21 +2300,25 @@ impl<'a, 'gcx, 'tcx> AdtDef {
22992300
self.variants.iter().all(|v| v.fields.is_empty())
23002301
}
23012302

2303+
/// Return a `VariantDef` given a variant id.
23022304
pub fn variant_with_id(&self, vid: DefId) -> &VariantDef {
23032305
self.variants.iter().find(|v| v.def_id == vid)
23042306
.expect("variant_with_id: unknown variant")
23052307
}
23062308

2309+
/// Return a `VariantDef` given a constructor id.
23072310
pub fn variant_with_ctor_id(&self, cid: DefId) -> &VariantDef {
23082311
self.variants.iter().find(|v| v.ctor_def_id == Some(cid))
23092312
.expect("variant_with_ctor_id: unknown variant")
23102313
}
23112314

2315+
/// Return the index of `VariantDef` given a variant id.
23122316
pub fn variant_index_with_id(&self, vid: DefId) -> VariantIdx {
23132317
self.variants.iter_enumerated().find(|(_, v)| v.def_id == vid)
23142318
.expect("variant_index_with_id: unknown variant").0
23152319
}
23162320

2321+
/// Return the index of `VariantDef` given a constructor id.
23172322
pub fn variant_index_with_ctor_id(&self, cid: DefId) -> VariantIdx {
23182323
self.variants.iter_enumerated().find(|(_, v)| v.ctor_def_id == Some(cid))
23192324
.expect("variant_index_with_ctor_id: unknown variant").0

0 commit comments

Comments
 (0)