Skip to content

Commit 7c0a403

Browse files
Split DepNode::ItemSignature into non-overlapping variants.
1 parent 4c225c4 commit 7c0a403

File tree

5 files changed

+63
-41
lines changed

5 files changed

+63
-41
lines changed

src/librustc/dep_graph/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The nodes of the graph are defined by the enum `DepNode`. They represent
1616
one of three things:
1717

1818
1. HIR nodes (like `Hir(DefId)`) represent the HIR input itself.
19-
2. Data nodes (like `ItemSignature(DefId)`) represent some computed
19+
2. Data nodes (like `TypeOfItem(DefId)`) represent some computed
2020
information about a particular item.
2121
3. Procedure nodes (like `CoherenceCheckTrait(DefId)`) represent some
2222
procedure that is executing. Usually this procedure is
@@ -289,7 +289,7 @@ to see something like:
289289

290290
Hir(foo) -> Collect(bar)
291291
Collect(bar) -> TypeckTables(bar)
292-
292+
293293
That first edge looks suspicious to you. So you set
294294
`RUST_FORBID_DEP_GRAPH_EDGE` to `Hir&foo -> Collect&bar`, re-run, and
295295
then observe the backtrace. Voila, bug fixed!

src/librustc/dep_graph/dep_node.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,21 @@ define_dep_nodes!(
387387

388388
// Nodes representing bits of computed IR in the tcx. Each shared
389389
// table in the tcx (or elsewhere) maps to one of these
390-
// nodes. Often we map multiple tables to the same node if there
391-
// is no point in distinguishing them (e.g., both the type and
392-
// predicates for an item wind up in `ItemSignature`).
390+
// nodes.
393391
AssociatedItems(DefId),
394-
ItemSignature(DefId),
392+
TypeOfItem(DefId),
393+
GenericsOfItem(DefId),
394+
PredicatesOfItem(DefId),
395+
SuperPredicatesOfItem(DefId),
396+
TraitDefOfItem(DefId),
397+
AdtDefOfItem(DefId),
398+
IsDefaultImpl(DefId),
399+
ImplTraitRef(DefId),
400+
ImplPolarity(DefId),
401+
ClosureKind(DefId),
402+
FnSignature(DefId),
403+
CoerceUnsizedInfo(DefId),
404+
395405
ItemVarianceConstraints(DefId),
396406
ItemVariances(DefId),
397407
IsConstFn(DefId),

src/librustc/ty/maps.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -796,28 +796,28 @@ macro_rules! define_provider_struct {
796796
// the driver creates (using several `rustc_*` crates).
797797
define_maps! { <'tcx>
798798
/// Records the type of every item.
799-
[] type_of: ItemSignature(DefId) -> Ty<'tcx>,
799+
[] type_of: TypeOfItem(DefId) -> Ty<'tcx>,
800800

801801
/// Maps from the def-id of an item (trait/struct/enum/fn) to its
802802
/// associated generics and predicates.
803-
[] generics_of: ItemSignature(DefId) -> &'tcx ty::Generics,
804-
[] predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
803+
[] generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
804+
[] predicates_of: PredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
805805

806806
/// Maps from the def-id of a trait to the list of
807807
/// super-predicates. This is a subset of the full list of
808808
/// predicates. We store these in a separate map because we must
809809
/// evaluate them even during type conversion, often before the
810810
/// full predicates are available (note that supertraits have
811811
/// additional acyclicity requirements).
812-
[] super_predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
812+
[] super_predicates_of: SuperPredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
813813

814814
/// To avoid cycles within the predicates of a single item we compute
815815
/// per-type-parameter predicates for resolving `T::AssocTy`.
816816
[] type_param_predicates: type_param_predicates((DefId, DefId))
817817
-> ty::GenericPredicates<'tcx>,
818818

819-
[] trait_def: ItemSignature(DefId) -> &'tcx ty::TraitDef,
820-
[] adt_def: ItemSignature(DefId) -> &'tcx ty::AdtDef,
819+
[] trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
820+
[] adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
821821
[] adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
822822
[] adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
823823
[] adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
@@ -829,7 +829,7 @@ define_maps! { <'tcx>
829829
[] is_foreign_item: IsForeignItem(DefId) -> bool,
830830

831831
/// True if this is a default impl (aka impl Foo for ..)
832-
[] is_default_impl: ItemSignature(DefId) -> bool,
832+
[] is_default_impl: IsDefaultImpl(DefId) -> bool,
833833

834834
/// Get a map with the variance of every item; use `item_variance`
835835
/// instead.
@@ -845,8 +845,8 @@ define_maps! { <'tcx>
845845
/// Maps from a trait item to the trait item "descriptor"
846846
[] associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
847847

848-
[] impl_trait_ref: ItemSignature(DefId) -> Option<ty::TraitRef<'tcx>>,
849-
[] impl_polarity: ItemSignature(DefId) -> hir::ImplPolarity,
848+
[] impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
849+
[] impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
850850

851851
/// Maps a DefId of a type to a list of its inherent impls.
852852
/// Contains implementations of methods that are inherent to a type.
@@ -877,13 +877,13 @@ define_maps! { <'tcx>
877877

878878
/// Type of each closure. The def ID is the ID of the
879879
/// expression defining the closure.
880-
[] closure_kind: ItemSignature(DefId) -> ty::ClosureKind,
880+
[] closure_kind: ClosureKind(DefId) -> ty::ClosureKind,
881881

882882
/// The signature of functions and closures.
883-
[] fn_sig: ItemSignature(DefId) -> ty::PolyFnSig<'tcx>,
883+
[] fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
884884

885885
/// Caches CoerceUnsized kinds for impls on custom types.
886-
[] coerce_unsized_info: ItemSignature(DefId)
886+
[] coerce_unsized_info: CoerceUnsizedInfo(DefId)
887887
-> ty::adjustment::CoerceUnsizedInfo,
888888

889889
[] typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,

src/test/compile-fail/dep-graph-struct-signature.rs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,54 +34,64 @@ struct WontChange {
3434
mod signatures {
3535
use WillChange;
3636

37-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
37+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
38+
#[rustc_then_this_would_need(AssociatedItems)] //~ ERROR no path
39+
#[rustc_then_this_would_need(TraitDefOfItem)] //~ ERROR no path
3840
trait Bar {
39-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
41+
#[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
4042
fn do_something(x: WillChange);
4143
}
4244

43-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
45+
#[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
46+
#[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
4447
fn some_fn(x: WillChange) { }
4548

46-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
49+
#[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
50+
#[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
4751
fn new_foo(x: u32, y: u32) -> WillChange {
4852
WillChange { x: x, y: y }
4953
}
5054

51-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
55+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
5256
impl WillChange {
57+
#[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
58+
#[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
5359
fn new(x: u32, y: u32) -> WillChange { loop { } }
5460
}
5561

56-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
62+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
5763
impl WillChange {
64+
#[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
65+
#[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
5866
fn method(&self, x: u32) { }
5967
}
6068

6169
struct WillChanges {
62-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
70+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
6371
x: WillChange,
64-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
72+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
6573
y: WillChange
6674
}
6775

6876
// The fields change, not the type itself.
69-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
77+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
7078
fn indirect(x: WillChanges) { }
7179
}
7280

7381
mod invalid_signatures {
7482
use WontChange;
7583

76-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
84+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
7785
trait A {
86+
#[rustc_then_this_would_need(FnSignature)] //~ ERROR no path
7887
fn do_something_else_twice(x: WontChange);
7988
}
8089

81-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
90+
#[rustc_then_this_would_need(FnSignature)] //~ ERROR no path
91+
#[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path
8292
fn b(x: WontChange) { }
8393

84-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path from `WillChange`
94+
#[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange`
95+
#[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path from `WillChange`
8596
fn c(x: u32) { }
8697
}
87-

src/test/compile-fail/dep-graph-type-alias.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,42 @@ type TypeAlias = u32;
2525

2626
// The type alias directly affects the type of the field,
2727
// not the enclosing struct:
28-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
28+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
2929
struct Struct {
30-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
30+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
3131
x: TypeAlias,
3232
y: u32
3333
}
3434

35-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
35+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
3636
enum Enum {
3737
Variant1 {
38-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
38+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
3939
t: TypeAlias
4040
},
4141
Variant2(i32)
4242
}
4343

44-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
44+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
4545
trait Trait {
46-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
46+
#[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
4747
fn method(&self, _: TypeAlias);
4848
}
4949

5050
struct SomeType;
5151

52-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path
52+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path
5353
impl SomeType {
54-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
54+
#[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
55+
#[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
5556
fn method(&self, _: TypeAlias) {}
5657
}
5758

58-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
59+
#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK
5960
type TypeAlias2 = TypeAlias;
6061

61-
#[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK
62+
#[rustc_then_this_would_need(FnSignature)] //~ ERROR OK
63+
#[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
6264
fn function(_: TypeAlias) {
6365

6466
}

0 commit comments

Comments
 (0)