]> git.lizzy.rs Git - rust.git/commitdiff
Split DepNode::ItemSignature into non-overlapping variants.
authorMichael Woerister <michaelwoerister@posteo.net>
Thu, 22 Jun 2017 08:54:26 +0000 (10:54 +0200)
committerMichael Woerister <michaelwoerister@posteo.net>
Mon, 10 Jul 2017 10:20:56 +0000 (12:20 +0200)
src/librustc/dep_graph/README.md
src/librustc/dep_graph/dep_node.rs
src/librustc/ty/maps.rs
src/test/compile-fail/dep-graph-struct-signature.rs
src/test/compile-fail/dep-graph-type-alias.rs

index c747c443b3a4ab76215e96853862963167836e28..c8d0362f17c8ed9a4f026a9e95b69bbe48f1319f 100644 (file)
@@ -16,7 +16,7 @@ The nodes of the graph are defined by the enum `DepNode`. They represent
 one of three things:
 
 1. HIR nodes (like `Hir(DefId)`) represent the HIR input itself.
-2. Data nodes (like `ItemSignature(DefId)`) represent some computed
+2. Data nodes (like `TypeOfItem(DefId)`) represent some computed
    information about a particular item.
 3. Procedure nodes (like `CoherenceCheckTrait(DefId)`) represent some
    procedure that is executing. Usually this procedure is
@@ -289,7 +289,7 @@ to see something like:
 
     Hir(foo) -> Collect(bar)
     Collect(bar) -> TypeckTables(bar)
-    
+
 That first edge looks suspicious to you. So you set
 `RUST_FORBID_DEP_GRAPH_EDGE` to `Hir&foo -> Collect&bar`, re-run, and
 then observe the backtrace. Voila, bug fixed!
index 92efeb7fd8629acf6f1e68577d8dbff8219804f0..887a7a4fe04bd3ef14767e3f0aab58abddccd8ff 100644 (file)
@@ -387,11 +387,21 @@ pub fn to_dep_node(self, tcx: TyCtxt, kind: DepKind) -> DepNode {
 
     // Nodes representing bits of computed IR in the tcx. Each shared
     // table in the tcx (or elsewhere) maps to one of these
-    // nodes. Often we map multiple tables to the same node if there
-    // is no point in distinguishing them (e.g., both the type and
-    // predicates for an item wind up in `ItemSignature`).
+    // nodes.
     AssociatedItems(DefId),
-    ItemSignature(DefId),
+    TypeOfItem(DefId),
+    GenericsOfItem(DefId),
+    PredicatesOfItem(DefId),
+    SuperPredicatesOfItem(DefId),
+    TraitDefOfItem(DefId),
+    AdtDefOfItem(DefId),
+    IsDefaultImpl(DefId),
+    ImplTraitRef(DefId),
+    ImplPolarity(DefId),
+    ClosureKind(DefId),
+    FnSignature(DefId),
+    CoerceUnsizedInfo(DefId),
+
     ItemVarianceConstraints(DefId),
     ItemVariances(DefId),
     IsConstFn(DefId),
index f4e333228c94d75b54da73e2c555f462b855f9c8..b584143c52774df6184b1f58955f40e299cf873b 100644 (file)
@@ -796,12 +796,12 @@ fn default() -> Self {
 // the driver creates (using several `rustc_*` crates).
 define_maps! { <'tcx>
     /// Records the type of every item.
-    [] type_of: ItemSignature(DefId) -> Ty<'tcx>,
+    [] type_of: TypeOfItem(DefId) -> Ty<'tcx>,
 
     /// Maps from the def-id of an item (trait/struct/enum/fn) to its
     /// associated generics and predicates.
-    [] generics_of: ItemSignature(DefId) -> &'tcx ty::Generics,
-    [] predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
+    [] generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
+    [] predicates_of: PredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
 
     /// Maps from the def-id of a trait to the list of
     /// super-predicates. This is a subset of the full list of
@@ -809,15 +809,15 @@ fn default() -> Self {
     /// evaluate them even during type conversion, often before the
     /// full predicates are available (note that supertraits have
     /// additional acyclicity requirements).
-    [] super_predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
+    [] super_predicates_of: SuperPredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
 
     /// To avoid cycles within the predicates of a single item we compute
     /// per-type-parameter predicates for resolving `T::AssocTy`.
     [] type_param_predicates: type_param_predicates((DefId, DefId))
         -> ty::GenericPredicates<'tcx>,
 
-    [] trait_def: ItemSignature(DefId) -> &'tcx ty::TraitDef,
-    [] adt_def: ItemSignature(DefId) -> &'tcx ty::AdtDef,
+    [] trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
+    [] adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
     [] adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
     [] adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
     [] adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
@@ -829,7 +829,7 @@ fn default() -> Self {
     [] is_foreign_item: IsForeignItem(DefId) -> bool,
 
     /// True if this is a default impl (aka impl Foo for ..)
-    [] is_default_impl: ItemSignature(DefId) -> bool,
+    [] is_default_impl: IsDefaultImpl(DefId) -> bool,
 
     /// Get a map with the variance of every item; use `item_variance`
     /// instead.
@@ -845,8 +845,8 @@ fn default() -> Self {
     /// Maps from a trait item to the trait item "descriptor"
     [] associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
 
-    [] impl_trait_ref: ItemSignature(DefId) -> Option<ty::TraitRef<'tcx>>,
-    [] impl_polarity: ItemSignature(DefId) -> hir::ImplPolarity,
+    [] impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
+    [] impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
 
     /// Maps a DefId of a type to a list of its inherent impls.
     /// Contains implementations of methods that are inherent to a type.
@@ -877,13 +877,13 @@ fn default() -> Self {
 
     /// Type of each closure. The def ID is the ID of the
     /// expression defining the closure.
-    [] closure_kind: ItemSignature(DefId) -> ty::ClosureKind,
+    [] closure_kind: ClosureKind(DefId) -> ty::ClosureKind,
 
     /// The signature of functions and closures.
-    [] fn_sig: ItemSignature(DefId) -> ty::PolyFnSig<'tcx>,
+    [] fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
 
     /// Caches CoerceUnsized kinds for impls on custom types.
-    [] coerce_unsized_info: ItemSignature(DefId)
+    [] coerce_unsized_info: CoerceUnsizedInfo(DefId)
         -> ty::adjustment::CoerceUnsizedInfo,
 
     [] typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
index 3f568194e23d8071fc9bd67c7fe05d1f2120d02f..647605ae4383e823623bf7314139624dc798b0bd 100644 (file)
@@ -34,54 +34,64 @@ struct WontChange {
 mod signatures {
     use WillChange;
 
-    #[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
+    #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
+    #[rustc_then_this_would_need(AssociatedItems)] //~ ERROR no path
+    #[rustc_then_this_would_need(TraitDefOfItem)] //~ ERROR no path
     trait Bar {
-        #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
+        #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
         fn do_something(x: WillChange);
     }
 
-    #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
+    #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
+    #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
     fn some_fn(x: WillChange) { }
 
-    #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
+    #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
+    #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
     fn new_foo(x: u32, y: u32) -> WillChange {
         WillChange { x: x, y: y }
     }
 
-    #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
+    #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
     impl WillChange {
+        #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
+        #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
         fn new(x: u32, y: u32) -> WillChange { loop { } }
     }
 
-    #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
+    #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
     impl WillChange {
+        #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
+        #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
         fn method(&self, x: u32) { }
     }
 
     struct WillChanges {
-        #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
+        #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
         x: WillChange,
-        #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
+        #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
         y: WillChange
     }
 
     // The fields change, not the type itself.
-    #[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
+    #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
     fn indirect(x: WillChanges) { }
 }
 
 mod invalid_signatures {
     use WontChange;
 
-    #[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
+    #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
     trait A {
+        #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path
         fn do_something_else_twice(x: WontChange);
     }
 
-    #[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
+    #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path
+    #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path
     fn b(x: WontChange) { }
 
-    #[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path from `WillChange`
+    #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange`
+    #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path from `WillChange`
     fn c(x: u32) { }
 }
-
index 56636a00a313a26afb911c4cce8f3a32d517d709..dca1fa4d98f95d97226ff11a32a79306e26cdb45 100644 (file)
@@ -25,40 +25,42 @@ fn main() { }
 
 // The type alias directly affects the type of the field,
 // not the enclosing struct:
-#[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
+#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
 struct Struct {
-    #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
+    #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
     x: TypeAlias,
     y: u32
 }
 
-#[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
+#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
 enum Enum {
     Variant1 {
-        #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
+        #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
         t: TypeAlias
     },
     Variant2(i32)
 }
 
-#[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
+#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
 trait Trait {
-    #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
+    #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
     fn method(&self, _: TypeAlias);
 }
 
 struct SomeType;
 
-#[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
+#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
 impl SomeType {
-    #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
+    #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
+    #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
     fn method(&self, _: TypeAlias) {}
 }
 
-#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
+#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
 type TypeAlias2 = TypeAlias;
 
-#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
+#[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
+#[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
 fn function(_: TypeAlias) {
 
 }