]> git.proxmox.com Git - rustc.git/blame - src/librustc/middle/ty/maps.rs
Imported Upstream version 1.8.0+dfsg1
[rustc.git] / src / librustc / middle / ty / maps.rs
CommitLineData
9cc50fc6
SL
1// Copyright 2012-2015 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.
4//
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.
10
11use dep_graph::{DepNode, DepTrackingMapConfig};
12use middle::def_id::DefId;
13use middle::ty;
14use std::marker::PhantomData;
15use std::rc::Rc;
7453a54e 16use syntax::{attr, ast};
9cc50fc6
SL
17
18macro_rules! dep_map_ty {
19 ($ty_name:ident : $node_name:ident ($key:ty) -> $value:ty) => {
20 pub struct $ty_name<'tcx> {
21 data: PhantomData<&'tcx ()>
22 }
23
24 impl<'tcx> DepTrackingMapConfig for $ty_name<'tcx> {
25 type Key = $key;
26 type Value = $value;
27 fn to_dep_node(key: &$key) -> DepNode { DepNode::$node_name(*key) }
28 }
29 }
30}
31
32dep_map_ty! { ImplOrTraitItems: ImplOrTraitItems(DefId) -> ty::ImplOrTraitItem<'tcx> }
33dep_map_ty! { Tcache: ItemSignature(DefId) -> ty::TypeScheme<'tcx> }
34dep_map_ty! { Predicates: ItemSignature(DefId) -> ty::GenericPredicates<'tcx> }
35dep_map_ty! { SuperPredicates: ItemSignature(DefId) -> ty::GenericPredicates<'tcx> }
36dep_map_ty! { TraitItemDefIds: TraitItemDefIds(DefId) -> Rc<Vec<ty::ImplOrTraitItemId>> }
37dep_map_ty! { ImplTraitRefs: ItemSignature(DefId) -> Option<ty::TraitRef<'tcx>> }
38dep_map_ty! { TraitDefs: ItemSignature(DefId) -> &'tcx ty::TraitDef<'tcx> }
39dep_map_ty! { AdtDefs: ItemSignature(DefId) -> ty::AdtDefMaster<'tcx> }
40dep_map_ty! { ItemVariances: ItemSignature(DefId) -> Rc<ty::ItemVariances> }
41dep_map_ty! { InherentImpls: InherentImpls(DefId) -> Rc<Vec<DefId>> }
42dep_map_ty! { ImplItems: ImplItems(DefId) -> Vec<ty::ImplOrTraitItemId> }
43dep_map_ty! { TraitItems: TraitItems(DefId) -> Rc<Vec<ty::ImplOrTraitItem<'tcx>>> }
44dep_map_ty! { ReprHints: ReprHints(DefId) -> Rc<Vec<attr::ReprAttr>> }
7453a54e 45dep_map_ty! { InlinedClosures: Hir(DefId) -> ast::NodeId }