aboutsummaryrefslogtreecommitdiff
path: root/src/comp
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-03-31 18:45:24 -0700
committerPatrick Walton <[email protected]>2011-03-31 18:45:24 -0700
commit1eeedbd00865fbc8c2650b8e2feba0b6e7f290dc (patch)
treee48d4bf8258c1c27d406031157529013aad37f18 /src/comp
parentrustc: Use the path index. Speeds up compilation a lot. (diff)
downloadrust-1eeedbd00865fbc8c2650b8e2feba0b6e7f290dc.tar.xz
rust-1eeedbd00865fbc8c2650b8e2feba0b6e7f290dc.zip
rustc: Make tag_ty_params() and substitute_ty_params() take def ids instead of ty_params, and to check in external crates
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/trans.rs10
-rw-r--r--src/comp/middle/ty.rs6
2 files changed, 6 insertions, 10 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 38aff67b..3c0df9bd 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -1103,7 +1103,7 @@ fn static_size_of_tag(@crate_ctxt cx, @ty.t t) -> uint {
}
// Pull the type parameters out of the corresponding tag item.
- let vec[ast.ty_param] ty_params = tag_ty_params(cx, tid);
+ let vec[ast.def_id] ty_params = tag_ty_params(cx, tid);
// Compute max(variant sizes).
auto max_size = 0u;
@@ -1905,12 +1905,8 @@ fn variant_types(@crate_ctxt cx, &ast.variant v) -> vec[@ty.t] {
}
// Returns the type parameters of a tag.
-fn tag_ty_params(@crate_ctxt cx, ast.def_id id) -> vec[ast.ty_param] {
- check (cx.items.contains_key(id));
- alt (cx.items.get(id).node) {
- case (ast.item_tag(_, _, ?tps, _)) { ret tps; }
- }
- fail; // not reached
+fn tag_ty_params(@crate_ctxt cx, ast.def_id id) -> vec[ast.def_id] {
+ ret ty.lookup_generic_item_type(cx.sess, cx.type_cache, id)._0;
}
// Returns the variants in a tag.
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 4e4cf34c..00d4b0b3 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -1664,15 +1664,15 @@ fn replace_type_params(@t typ, hashmap[ast.def_id,@t] param_map) -> @t {
// Substitutes the type parameters specified by @ty_params with the
// corresponding types in @bound in the given type. The two vectors must have
// the same length.
-fn substitute_ty_params(vec[ast.ty_param] ty_params, vec[@t] bound, @t ty)
+fn substitute_ty_params(vec[ast.def_id] ty_params, vec[@t] bound, @t ty)
-> @t {
- auto ty_param_len = _vec.len[ast.ty_param](ty_params);
+ auto ty_param_len = _vec.len[ast.def_id](ty_params);
check (ty_param_len == _vec.len[@t](bound));
auto bindings = common.new_def_hash[@t]();
auto i = 0u;
while (i < ty_param_len) {
- bindings.insert(ty_params.(i).id, bound.(i));
+ bindings.insert(ty_params.(i), bound.(i));
i += 1u;
}