Skip to content

Commit cca64e7

Browse files
committed
Add some comments to mir::Static and mir::StaticKind
1 parent d6bf776 commit cca64e7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/librustc/mir/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,13 +1733,20 @@ pub enum PlaceBase<'tcx> {
17331733
pub struct Static<'tcx> {
17341734
pub ty: Ty<'tcx>,
17351735
pub kind: StaticKind<'tcx>,
1736+
/// The `DefId` of the item this static was declared in. For promoted values, usually, this is
1737+
/// the same as the `DefId` of the `mir::Body` containing the `Place` this promoted appears in.
1738+
/// However, after inlining, that might no longer be the case as inlined `Place`s are copied
1739+
/// into the calling frame.
17361740
pub def_id: DefId,
17371741
}
17381742

17391743
#[derive(
17401744
Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable, RustcEncodable, RustcDecodable,
17411745
)]
17421746
pub enum StaticKind<'tcx> {
1747+
/// Promoted references consist of an id (`Promoted`) and the substs necessary to monomorphize
1748+
/// it. Usually, these substs are just the identity substs for the item. However, the inliner
1749+
/// will adjust these substs when it inlines a function based on the substs at the callsite.
17431750
Promoted(Promoted, SubstsRef<'tcx>),
17441751
Static,
17451752
}

0 commit comments

Comments
 (0)