diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-01-05 15:05:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-05 15:05:46 +0100 |
| commit | bf9546c127df1a7a6b641a5cd6d741a32b6fddad (patch) | |
| tree | cd3c9248c375936b9730a2344d50f4a5d5a7fc29 /compiler/rustc_span/src | |
| parent | 84e48a41d3feeb65cc90cc13fd30e3997d313535 (diff) | |
| parent | 0bac713569a56089c3b5435f49d7e8d900535d30 (diff) | |
| download | rust-bf9546c127df1a7a6b641a5cd6d741a32b6fddad.tar.gz rust-bf9546c127df1a7a6b641a5cd6d741a32b6fddad.zip | |
Rollup merge of #92442 - pierwill:localdefid-doc-ord, r=Aaron1011
Add negative `impl` for `Ord`, `PartialOrd` on `LocalDefId` Suggested in https://github.com/rust-lang/rust/pull/92233#discussion_r776123222. This also fixes some formatting in the doc comment. r? `@cjgillot`
Diffstat (limited to 'compiler/rustc_span/src')
| -rw-r--r-- | compiler/rustc_span/src/def_id.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index d15befbf287..f6b0785a07c 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -316,17 +316,23 @@ impl fmt::Debug for DefId { rustc_data_structures::define_id_collections!(DefIdMap, DefIdSet, DefId); -/// A LocalDefId is equivalent to a DefId with `krate == LOCAL_CRATE`. Since +/// 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. +/// no `DefId`s from upstream crates get thrown into the mix. There are quite a +/// few cases where we know that only `DefId`s from the local crate are expected; +/// a `DefId` from a different crate would signify a bug somewhere. This +/// is when `LocalDefId` comes in handy. #[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct LocalDefId { pub local_def_index: DefIndex, } +// To ensure correctness of incremental compilation, +// `LocalDefId` must not implement `Ord` or `PartialOrd`. +// See https://github.com/rust-lang/rust/issues/90317. +impl !Ord for LocalDefId {} +impl !PartialOrd for LocalDefId {} + pub const CRATE_DEF_ID: LocalDefId = LocalDefId { local_def_index: CRATE_DEF_INDEX }; impl Idx for LocalDefId { |
