diff options
| author | Michael Woerister <michaelwoerister@posteo> | 2017-11-16 18:07:49 +0100 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo> | 2017-11-16 18:09:04 +0100 |
| commit | 0a1f6dd8a8c27caf913a16eb0a1afeaa8183b983 (patch) | |
| tree | 38430568b9208d2bef6f2bebc92c798ae674b24c | |
| parent | 4c4f7a3189c837805e203decacb2f43d0866aac6 (diff) | |
| download | rust-0a1f6dd8a8c27caf913a16eb0a1afeaa8183b983.tar.gz rust-0a1f6dd8a8c27caf913a16eb0a1afeaa8183b983.zip | |
Add doc comment for LocalDefId.
| -rw-r--r-- | src/librustc/hir/def_id.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/librustc/hir/def_id.rs b/src/librustc/hir/def_id.rs index 05d021ac6d2..f6fcff37ca5 100644 --- a/src/librustc/hir/def_id.rs +++ b/src/librustc/hir/def_id.rs @@ -198,7 +198,7 @@ impl DefId { self.krate == LOCAL_CRATE } - #[inline] + #[inline] pub fn to_local(self) -> LocalDefId { LocalDefId::from_def_id(self) } @@ -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); |
