Skip to content

Commit

Permalink
Add doc comment for LocalDefId.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Nov 16, 2017
1 parent 4c4f7a3 commit 0a1f6dd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/librustc/hir/def_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl DefId {
self.krate == LOCAL_CRATE
}

#[inline]
#[inline]
pub fn to_local(self) -> LocalDefId {
LocalDefId::from_def_id(self)
}
Expand All @@ -207,7 +207,12 @@ impl DefId {
impl serialize::UseSpecializedEncodable for DefId {}
impl serialize::UseSpecializedDecodable for DefId {}


/// A LocalDefId is equivalent to a DefId with `krate == LOCAL_CRATE`. Since
/// we encode this information in the type, we can ensure at compile time that
/// no DefIds from upstream crates get thrown into the mix. There are quite a
/// few cases where we know that only DefIds from the local crate are expected
/// and a DefId from a different crate would signify a bug somewhere. This
/// is when LocalDefId comes in handy.
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct LocalDefId(DefIndex);

Expand Down

0 comments on commit 0a1f6dd

Please sign in to comment.