- fn to_dep_node(tcx: TyCtxt, key: &Self::Key) -> DepNode {
- // Ideally, we'd just put `key` into the dep-node, but we
- // can't put full types in there. So just collect up all the
- // def-ids of structs/enums as well as any traits that we
- // project out of. It doesn't matter so much what we do here,
- // except that if we are too coarse, we'll create overly
- // coarse edges between impls and the trans. For example, if
- // we just used the def-id of things we are projecting out of,
- // then the key for `<Foo as SomeTrait>::T` and `<Bar as
- // SomeTrait>::T` would both share a dep-node
- // (`TraitSelect(SomeTrait)`), and hence the impls for both
- // `Foo` and `Bar` would be considered inputs. So a change to
- // `Bar` would affect things that just normalized `Foo`.
- // Anyway, this heuristic is not ideal, but better than
- // nothing.
- let def_ids: Vec<DefId> =
- key.walk()
- .filter_map(|t| match t.sty {
- ty::TyAdt(adt_def, _) => Some(adt_def.did),
- ty::TyProjection(ref proj) => Some(proj.item_def_id),
- _ => None,
- })
- .collect();
-
- DepNode::new(tcx, DepConstructor::ProjectionCache { def_ids: def_ids })