1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
14 pub enum DepNode
<D
: Clone
+ Debug
> {
15 // The `D` type is "how definitions are identified".
16 // During compilation, it is always `DefId`, but when serializing
17 // it is mapped to `DefPath`.
19 // Represents the `Krate` as a whole (the `hir::Krate` value) (as
20 // distinct from the krate module). This is basically a hash of
21 // the entire krate, so if you read from `Krate` (e.g., by calling
22 // `tcx.map.krate()`), we will have to assume that any change
23 // means that you need to be recompiled. This is because the
24 // `Krate` value gives you access to all other items. To avoid
25 // this fate, do not call `tcx.map.krate()`; instead, prefer
26 // wrappers like `tcx.visit_all_items_in_krate()`. If there is no
27 // suitable wrapper, you can use `tcx.dep_graph.ignore()` to gain
28 // access to the krate, but you must remember to add suitable
29 // edges yourself for the individual items that you read.
32 // Represents the HIR node with the given node-id
35 // Represents different phases in the compiler.
51 CoherenceCheckImpl(D
),
52 CoherenceOverlapCheck(D
),
53 CoherenceOverlapCheckSpecial(D
),
54 CoherenceOverlapInherentCheck(D
),
55 CoherenceOrphanCheck(D
),
66 MirMapConstruction(D
),
79 // Nodes representing bits of computed IR in the tcx. Each shared
80 // table in the tcx (or elsewhere) maps to one of these
81 // nodes. Often we map multiple tables to the same node if there
82 // is no point in distinguishing them (e.g., both the type and
83 // predicates for an item wind up in `ItemSignature`). Other
84 // times, such as `ImplItems` vs `TraitItemDefIds`, tables which
85 // might be mergable are kept distinct because the sets of def-ids
86 // to which they apply are disjoint, and hence we might as well
87 // have distinct labels for easier debugging.
95 // The set of impls for a given trait. Ultimately, it would be
96 // nice to get more fine-grained here (e.g., to include a
97 // simplified type), but we can't do that until we restructure the
98 // HIR to distinguish the *header* of an impl from its body. This
99 // is because changes to the header may change the self-type of
100 // the impl and hence would require us to be more conservative
101 // than changes in the impl body.
104 // Nodes representing caches. To properly handle a true cache, we
105 // don't use a DepTrackingMap, but rather we push a task node.
106 // Otherwise the write into the map would be incorrectly
107 // attributed to the first task that happened to fill the cache,
108 // which would yield an overly conservative dep-graph.
114 impl<D
: Clone
+ Debug
> DepNode
<D
> {
116 pub fn from_label_string(label
: &str, data
: D
) -> Result
<DepNode
<D
>, ()> {
118 ($
($name
:ident
,)*) => {
120 $
(stringify
!($name
) => Ok(DepNode
::$
name(data
)),)*
143 pub fn map_def
<E
, OP
>(&self, mut op
: OP
) -> Option
<DepNode
<E
>>
144 where OP
: FnMut(&D
) -> Option
<E
>, E
: Clone
+ Debug
146 use self::DepNode
::*;
149 Krate
=> Some(Krate
),
150 CrateReader
=> Some(CrateReader
),
151 CollectLanguageItems
=> Some(CollectLanguageItems
),
152 CheckStaticRecursion
=> Some(CheckStaticRecursion
),
153 ResolveLifetimes
=> Some(ResolveLifetimes
),
154 RegionResolveCrate
=> Some(RegionResolveCrate
),
155 CheckLoops
=> Some(CheckLoops
),
156 PluginRegistrar
=> Some(PluginRegistrar
),
157 StabilityIndex
=> Some(StabilityIndex
),
158 Coherence
=> Some(Coherence
),
159 EffectCheck
=> Some(EffectCheck
),
160 Liveness
=> Some(Liveness
),
161 Resolve
=> Some(Resolve
),
162 EntryPoint
=> Some(EntryPoint
),
163 CheckEntryFn
=> Some(CheckEntryFn
),
164 Variance
=> Some(Variance
),
165 Dropck
=> Some(Dropck
),
166 Privacy
=> Some(Privacy
),
167 Reachability
=> Some(Reachability
),
168 DeadCheck
=> Some(DeadCheck
),
169 StabilityCheck
=> Some(StabilityCheck
),
170 LateLintCheck
=> Some(LateLintCheck
),
171 TransCrate
=> Some(TransCrate
),
172 TransWriteMetadata
=> Some(TransWriteMetadata
),
173 Hir(ref d
) => op(d
).map(Hir
),
174 CollectItem(ref d
) => op(d
).map(CollectItem
),
175 CoherenceCheckImpl(ref d
) => op(d
).map(CoherenceCheckImpl
),
176 CoherenceOverlapCheck(ref d
) => op(d
).map(CoherenceOverlapCheck
),
177 CoherenceOverlapCheckSpecial(ref d
) => op(d
).map(CoherenceOverlapCheckSpecial
),
178 CoherenceOverlapInherentCheck(ref d
) => op(d
).map(CoherenceOverlapInherentCheck
),
179 CoherenceOrphanCheck(ref d
) => op(d
).map(CoherenceOrphanCheck
),
180 WfCheck(ref d
) => op(d
).map(WfCheck
),
181 TypeckItemType(ref d
) => op(d
).map(TypeckItemType
),
182 TypeckItemBody(ref d
) => op(d
).map(TypeckItemBody
),
183 DropckImpl(ref d
) => op(d
).map(DropckImpl
),
184 CheckConst(ref d
) => op(d
).map(CheckConst
),
185 IntrinsicCheck(ref d
) => op(d
).map(IntrinsicCheck
),
186 MatchCheck(ref d
) => op(d
).map(MatchCheck
),
187 MirMapConstruction(ref d
) => op(d
).map(MirMapConstruction
),
188 MirTypeck(ref d
) => op(d
).map(MirTypeck
),
189 BorrowCheck(ref d
) => op(d
).map(BorrowCheck
),
190 RvalueCheck(ref d
) => op(d
).map(RvalueCheck
),
191 TransCrateItem(ref d
) => op(d
).map(TransCrateItem
),
192 TransInlinedItem(ref d
) => op(d
).map(TransInlinedItem
),
193 ImplOrTraitItems(ref d
) => op(d
).map(ImplOrTraitItems
),
194 ItemSignature(ref d
) => op(d
).map(ItemSignature
),
195 FieldTy(ref d
) => op(d
).map(FieldTy
),
196 TraitItemDefIds(ref d
) => op(d
).map(TraitItemDefIds
),
197 InherentImpls(ref d
) => op(d
).map(InherentImpls
),
198 ImplItems(ref d
) => op(d
).map(ImplItems
),
199 TraitImpls(ref d
) => op(d
).map(TraitImpls
),
200 TraitItems(ref d
) => op(d
).map(TraitItems
),
201 ReprHints(ref d
) => op(d
).map(ReprHints
),
202 TraitSelect(ref d
) => op(d
).map(TraitSelect
),