rustc: Remove uses of DVec
This commit is contained in:
parent
87f864292d
commit
2a72099063
@ -19,7 +19,6 @@ use metadata::decoder;
|
||||
use metadata;
|
||||
use middle::{ty, resolve};
|
||||
|
||||
use core::dvec::DVec;
|
||||
use core::vec;
|
||||
use reader = std::ebml::reader;
|
||||
use syntax::ast;
|
||||
@ -136,7 +135,7 @@ pub fn get_supertraits(tcx: ty::ctxt, def: ast::def_id) -> ~[ty::t] {
|
||||
|
||||
pub fn get_method_names_if_trait(cstore: @mut cstore::CStore,
|
||||
def: ast::def_id)
|
||||
-> Option<@DVec<(ast::ident, ast::self_ty_)>> {
|
||||
-> Option<~[(ast::ident, ast::self_ty_)]> {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
return decoder::get_method_names_if_trait(cstore.intr, cdata, def.node);
|
||||
}
|
||||
|
@ -22,8 +22,6 @@ use metadata::decoder;
|
||||
use metadata::tydecode::{parse_ty_data, parse_def_id, parse_bounds_data};
|
||||
use middle::{ty, resolve};
|
||||
|
||||
use core::dvec;
|
||||
use core::dvec::DVec;
|
||||
use core::hash::{Hash, HashUtil};
|
||||
use core::int;
|
||||
use core::io::WriterUtil;
|
||||
@ -766,12 +764,12 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
|
||||
/// Returns the supertraits of the given trait.
|
||||
pub fn get_supertraits(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
|
||||
-> ~[ty::t] {
|
||||
let results = dvec::DVec();
|
||||
let mut results = ~[];
|
||||
let item_doc = lookup_item(id, cdata.data);
|
||||
for reader::tagged_docs(item_doc, tag_impl_trait) |trait_doc| {
|
||||
results.push(doc_type(trait_doc, tcx, cdata));
|
||||
}
|
||||
return dvec::unwrap(results);
|
||||
return results;
|
||||
}
|
||||
|
||||
// If the item in question is a trait, returns its set of methods and
|
||||
@ -779,14 +777,14 @@ pub fn get_supertraits(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
|
||||
// annoying way with get_trait_methods.
|
||||
pub fn get_method_names_if_trait(intr: @ident_interner, cdata: cmd,
|
||||
node_id: ast::node_id)
|
||||
-> Option<@DVec<(ast::ident, ast::self_ty_)>> {
|
||||
-> Option<~[(ast::ident, ast::self_ty_)]> {
|
||||
|
||||
let item = lookup_item(node_id, cdata.data);
|
||||
if item_family(item) != Trait {
|
||||
return None;
|
||||
}
|
||||
|
||||
let resulting_methods = @DVec();
|
||||
let mut resulting_methods = ~[];
|
||||
for reader::tagged_docs(item, tag_item_trait_method) |method| {
|
||||
resulting_methods.push(
|
||||
(item_name(intr, method), get_self_ty(method)));
|
||||
@ -823,12 +821,12 @@ pub fn get_static_methods_if_impl(intr: @ident_interner,
|
||||
return None;
|
||||
}
|
||||
|
||||
let impl_method_ids = DVec();
|
||||
let mut impl_method_ids = ~[];
|
||||
for reader::tagged_docs(item, tag_item_impl_method) |impl_method_doc| {
|
||||
impl_method_ids.push(parse_def_id(reader::doc_data(impl_method_doc)));
|
||||
}
|
||||
|
||||
let static_impl_methods = DVec();
|
||||
let mut static_impl_methods = ~[];
|
||||
for impl_method_ids.each |impl_method_id| {
|
||||
let impl_method_doc = lookup_item(impl_method_id.node, cdata.data);
|
||||
let family = item_family(impl_method_doc);
|
||||
@ -852,7 +850,7 @@ pub fn get_static_methods_if_impl(intr: @ident_interner,
|
||||
}
|
||||
}
|
||||
|
||||
return Some(dvec::unwrap(static_impl_methods));
|
||||
return Some(static_impl_methods);
|
||||
}
|
||||
|
||||
pub fn get_item_attrs(cdata: cmd,
|
||||
|
@ -22,7 +22,6 @@ use middle::ty;
|
||||
use middle;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use core::dvec;
|
||||
use core::flate;
|
||||
use core::hash::{Hash, HashUtil};
|
||||
use core::int;
|
||||
@ -857,7 +856,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
|
||||
}
|
||||
}
|
||||
item_trait(ref generics, ref traits, ref ms) => {
|
||||
let provided_methods = dvec::DVec();
|
||||
let mut provided_methods = ~[];
|
||||
|
||||
add_to_index();
|
||||
ebml_w.start_tag(tag_items_data_item);
|
||||
@ -1366,13 +1365,11 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
|
||||
|
||||
if (parms.tcx.sess.meta_stats()) {
|
||||
|
||||
do wr.bytes.borrow |v| {
|
||||
do v.each |e| {
|
||||
if *e == 0 {
|
||||
ecx.stats.zero_bytes += 1;
|
||||
}
|
||||
true
|
||||
do wr.bytes.each |e| {
|
||||
if *e == 0 {
|
||||
ecx.stats.zero_bytes += 1;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
io::println("metadata stats:");
|
||||
@ -1401,7 +1398,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
|
||||
|
||||
(do str::as_bytes(&~"rust\x00\x00\x00\x01") |bytes| {
|
||||
vec::slice(*bytes, 0, 8).to_vec()
|
||||
}) + flate::deflate_bytes(wr.bytes.check_out(|buf| buf))
|
||||
}) + flate::deflate_bytes(wr.bytes)
|
||||
}
|
||||
|
||||
// Get the encoded string for a type
|
||||
|
@ -25,7 +25,7 @@ use middle::{ty, typeck, moves};
|
||||
use middle;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use core::{dvec, io, option, vec};
|
||||
use core::{io, option, vec};
|
||||
use std::ebml::reader;
|
||||
use std::ebml;
|
||||
use std::serialize;
|
||||
@ -912,11 +912,11 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
|
||||
}
|
||||
}
|
||||
|
||||
for maps.last_use_map.find(&id).each |m| {
|
||||
for maps.last_use_map.find(&id).each |&m| {
|
||||
do ebml_w.tag(c::tag_table_last_use) {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {
|
||||
do ebml_w.emit_from_vec((*m).get()) |id| {
|
||||
do ebml_w.emit_from_vec(/*bad*/ copy *m) |id| {
|
||||
id.encode(&ebml_w);
|
||||
}
|
||||
}
|
||||
@ -1131,8 +1131,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
|
||||
let ids = val_dsr.read_to_vec(|| {
|
||||
xcx.tr_id(val_dsr.read_int())
|
||||
});
|
||||
let dvec = @dvec::from_vec(ids);
|
||||
dcx.maps.last_use_map.insert(id, dvec);
|
||||
dcx.maps.last_use_map.insert(id, @mut ids);
|
||||
} else if tag == (c::tag_table_method_map as uint) {
|
||||
dcx.maps.method_map.insert(
|
||||
id,
|
||||
|
@ -32,7 +32,6 @@ use middle::ty;
|
||||
use util::common::indenter;
|
||||
use util::ppaux::{expr_repr, region_to_str};
|
||||
|
||||
use core::dvec;
|
||||
use core::hashmap::linear::LinearSet;
|
||||
use core::vec;
|
||||
use std::oldmap::HashMap;
|
||||
@ -575,9 +574,8 @@ pub impl GatherLoanCtxt {
|
||||
req_loans.push_all(loans);
|
||||
}
|
||||
None => {
|
||||
let dvec = @dvec::from_vec(loans);
|
||||
let req_loan_map = self.req_maps.req_loan_map;
|
||||
req_loan_map.insert(scope_id, dvec);
|
||||
req_loan_map.insert(scope_id, @mut loans);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +234,6 @@ use middle::moves;
|
||||
use util::common::{indenter, stmt_set};
|
||||
use util::ppaux::note_and_explain_region;
|
||||
|
||||
use core::dvec::DVec;
|
||||
use core::io;
|
||||
use core::result::{Result, Ok, Err};
|
||||
use core::to_bytes;
|
||||
@ -406,7 +405,7 @@ pub struct Loan {
|
||||
/// - `pure_map`: map from block/expr that must be pure to the error message
|
||||
/// that should be reported if they are not pure
|
||||
pub struct ReqMaps {
|
||||
req_loan_map: HashMap<ast::node_id, @DVec<Loan>>,
|
||||
req_loan_map: HashMap<ast::node_id, @mut ~[Loan]>,
|
||||
pure_map: HashMap<ast::node_id, bckerr>
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,6 @@ use middle::moves;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use core::cmp;
|
||||
use core::dvec::DVec;
|
||||
use core::io::WriterUtil;
|
||||
use core::io;
|
||||
use core::ptr;
|
||||
@ -136,7 +135,7 @@ use syntax::{visit, ast_util};
|
||||
//
|
||||
// Very subtle (#2633): borrowck will remove entries from this table
|
||||
// if it detects an outstanding loan (that is, the addr is taken).
|
||||
pub type last_use_map = HashMap<node_id, @DVec<node_id>>;
|
||||
pub type last_use_map = HashMap<node_id, @mut ~[node_id]>;
|
||||
|
||||
enum Variable = uint;
|
||||
enum LiveNode = uint;
|
||||
@ -419,13 +418,13 @@ pub impl IrMaps {
|
||||
let v = match self.last_use_map.find(&expr_id) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
let v = @DVec();
|
||||
let v = @mut ~[];
|
||||
self.last_use_map.insert(expr_id, v);
|
||||
v
|
||||
}
|
||||
};
|
||||
|
||||
(*v).push(id);
|
||||
v.push(id);
|
||||
}
|
||||
Arg(_, _, by_ref) |
|
||||
Arg(_, _, by_val) | ImplicitRet => {
|
||||
@ -667,7 +666,7 @@ struct Liveness {
|
||||
users: @mut ~[Users],
|
||||
// The list of node IDs for the nested loop scopes
|
||||
// we're in.
|
||||
loop_scope: DVec<node_id>,
|
||||
loop_scope: @mut ~[node_id],
|
||||
// mappings from loop node ID to LiveNode
|
||||
// ("break" label should map to loop node ID,
|
||||
// it probably doesn't now)
|
||||
@ -683,7 +682,7 @@ fn Liveness(ir: @mut IrMaps, specials: Specials) -> Liveness {
|
||||
successors: @mut vec::from_elem(ir.num_live_nodes, invalid_node()),
|
||||
users: @mut vec::from_elem(ir.num_live_nodes * ir.num_vars,
|
||||
invalid_users()),
|
||||
loop_scope: DVec(),
|
||||
loop_scope: @mut ~[],
|
||||
break_ln: HashMap(),
|
||||
cont_ln: HashMap()
|
||||
}
|
||||
@ -856,11 +855,16 @@ pub impl Liveness {
|
||||
self.tcx.sess.span_bug(sp, ~"break outside loop");
|
||||
}
|
||||
else {
|
||||
self.loop_scope.last()
|
||||
// FIXME(#5275): this shouldn't have to be a method...
|
||||
self.last_loop_scope()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn last_loop_scope(&self) -> node_id {
|
||||
*self.loop_scope.last()
|
||||
}
|
||||
|
||||
fn ln_str(&self, ln: LiveNode) -> ~str {
|
||||
do io::with_str_writer |wr| {
|
||||
wr.write_str(~"[ln(");
|
||||
|
@ -21,7 +21,6 @@ use middle::typeck::{method_map, method_origin, method_param, method_self};
|
||||
use middle::typeck::{method_super};
|
||||
use middle::typeck::{method_static, method_trait};
|
||||
|
||||
use core::dvec::DVec;
|
||||
use core::util::ignore;
|
||||
use syntax::ast::{def_variant, expr_field, expr_method_call, expr_struct};
|
||||
use syntax::ast::{expr_unary, ident, item_struct, item_enum, item_impl};
|
||||
@ -38,7 +37,7 @@ use syntax::visit;
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
method_map: &method_map,
|
||||
crate: @ast::crate) {
|
||||
let privileged_items = @DVec();
|
||||
let privileged_items = @mut ~[];
|
||||
|
||||
// Adds structs that are privileged to this scope.
|
||||
let add_privileged_items: @fn(&[@ast::item]) -> uint = |items| {
|
||||
|
@ -26,7 +26,6 @@ use middle::ty::{region_variance, rv_covariant, rv_invariant};
|
||||
use middle::ty::{rv_contravariant};
|
||||
use middle::ty;
|
||||
|
||||
use core::dvec::DVec;
|
||||
use core::vec;
|
||||
use std::oldmap::HashMap;
|
||||
use syntax::ast_map;
|
||||
@ -395,7 +394,7 @@ pub struct region_dep {
|
||||
id: ast::node_id
|
||||
}
|
||||
|
||||
pub type dep_map = HashMap<ast::node_id, @DVec<region_dep>>;
|
||||
pub type dep_map = HashMap<ast::node_id, @mut ~[region_dep]>;
|
||||
|
||||
pub struct DetermineRpCtxt {
|
||||
sess: Session,
|
||||
@ -498,7 +497,7 @@ pub impl DetermineRpCtxt {
|
||||
let vec = match self.dep_map.find(&from) {
|
||||
Some(vec) => vec,
|
||||
None => {
|
||||
let vec = @DVec();
|
||||
let vec = @mut ~[];
|
||||
let dep_map = self.dep_map;
|
||||
dep_map.insert(from, vec);
|
||||
vec
|
||||
|
@ -75,7 +75,6 @@ use syntax::visit::{visit_foreign_item, visit_item, visit_method_helper};
|
||||
use syntax::visit::{visit_mod, visit_ty, vt};
|
||||
use syntax::opt_vec::OptVec;
|
||||
|
||||
use core::dvec::DVec;
|
||||
use core::option::{Some, get, is_some, is_none};
|
||||
use core::str::{connect, split_str};
|
||||
use std::oldmap::HashMap;
|
||||
@ -110,7 +109,7 @@ pub struct Impl {
|
||||
}
|
||||
|
||||
// Trait method resolution
|
||||
pub type TraitMap = @HashMap<node_id,@DVec<def_id>>;
|
||||
pub type TraitMap = @HashMap<node_id,@mut ~[def_id]>;
|
||||
|
||||
// This is the replacement export map. It maps a module to all of the exports
|
||||
// within.
|
||||
@ -350,13 +349,13 @@ pub fn Rib(kind: RibKind) -> Rib {
|
||||
/// One import directive.
|
||||
pub struct ImportDirective {
|
||||
privacy: Privacy,
|
||||
module_path: @DVec<ident>,
|
||||
module_path: ~[ident],
|
||||
subclass: @ImportDirectiveSubclass,
|
||||
span: span,
|
||||
}
|
||||
|
||||
pub fn ImportDirective(privacy: Privacy,
|
||||
module_path: @DVec<ident>,
|
||||
+module_path: ~[ident],
|
||||
subclass: @ImportDirectiveSubclass,
|
||||
span: span)
|
||||
-> ImportDirective {
|
||||
@ -458,7 +457,7 @@ pub struct Module {
|
||||
kind: ModuleKind,
|
||||
|
||||
children: @HashMap<ident,@mut NameBindings>,
|
||||
imports: @DVec<@ImportDirective>,
|
||||
imports: ~[@ImportDirective],
|
||||
|
||||
// The anonymous children of this node. Anonymous children are pseudo-
|
||||
// modules that are implicitly created around items contained within
|
||||
@ -496,7 +495,7 @@ pub fn Module(parent_link: ParentLink,
|
||||
def_id: def_id,
|
||||
kind: kind,
|
||||
children: @HashMap(),
|
||||
imports: @DVec(),
|
||||
imports: ~[],
|
||||
anonymous_children: @HashMap(),
|
||||
import_resolutions: @HashMap(),
|
||||
glob_count: 0,
|
||||
@ -781,9 +780,9 @@ pub fn Resolver(session: Session,
|
||||
unresolved_imports: 0,
|
||||
|
||||
current_module: current_module,
|
||||
value_ribs: @DVec(),
|
||||
type_ribs: @DVec(),
|
||||
label_ribs: @DVec(),
|
||||
value_ribs: ~[],
|
||||
type_ribs: ~[],
|
||||
label_ribs: ~[],
|
||||
|
||||
xray_context: NoXray,
|
||||
current_trait_refs: None,
|
||||
@ -830,20 +829,20 @@ pub struct Resolver {
|
||||
|
||||
// The current set of local scopes, for values.
|
||||
// FIXME #4948: Reuse ribs to avoid allocation.
|
||||
value_ribs: @DVec<@Rib>,
|
||||
value_ribs: ~[@Rib],
|
||||
|
||||
// The current set of local scopes, for types.
|
||||
type_ribs: @DVec<@Rib>,
|
||||
type_ribs: ~[@Rib],
|
||||
|
||||
// The current set of local scopes, for labels.
|
||||
label_ribs: @DVec<@Rib>,
|
||||
label_ribs: ~[@Rib],
|
||||
|
||||
// Whether the current context is an X-ray context. An X-ray context is
|
||||
// allowed to access private names of any module.
|
||||
xray_context: XrayFlag,
|
||||
|
||||
// The trait that the current context can refer to.
|
||||
current_trait_refs: Option<@DVec<def_id>>,
|
||||
current_trait_refs: Option<~[def_id]>,
|
||||
|
||||
// The ident for the keyword "self".
|
||||
self_ident: ident,
|
||||
@ -1407,7 +1406,7 @@ pub impl Resolver {
|
||||
// globs and lists, the path is found directly in the AST;
|
||||
// for simple paths we have to munge the path a little.
|
||||
|
||||
let module_path = @DVec();
|
||||
let mut module_path = ~[];
|
||||
match view_path.node {
|
||||
view_path_simple(_, full_path, _, _) => {
|
||||
let path_len = full_path.idents.len();
|
||||
@ -1415,7 +1414,7 @@ pub impl Resolver {
|
||||
|
||||
for full_path.idents.eachi |i, ident| {
|
||||
if i != path_len - 1 {
|
||||
(*module_path).push(*ident);
|
||||
module_path.push(*ident);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1423,7 +1422,7 @@ pub impl Resolver {
|
||||
view_path_glob(module_ident_path, _) |
|
||||
view_path_list(module_ident_path, _, _) => {
|
||||
for module_ident_path.idents.each |ident| {
|
||||
(*module_path).push(*ident);
|
||||
module_path.push(*ident);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1457,7 +1456,7 @@ pub impl Resolver {
|
||||
AnyNS);
|
||||
self.build_import_directive(privacy,
|
||||
module_,
|
||||
module_path,
|
||||
copy module_path,
|
||||
subclass,
|
||||
view_path.span,
|
||||
state);
|
||||
@ -1857,7 +1856,7 @@ pub impl Resolver {
|
||||
fn build_import_directive(@mut self,
|
||||
privacy: Privacy,
|
||||
module_: @mut Module,
|
||||
module_path: @DVec<ident>,
|
||||
+module_path: ~[ident],
|
||||
subclass: @ImportDirectiveSubclass,
|
||||
span: span,
|
||||
state: @mut ImportState) {
|
||||
@ -1873,7 +1872,7 @@ pub impl Resolver {
|
||||
debug!("(building import directive) building import \
|
||||
directive: privacy %? %s::%s",
|
||||
privacy,
|
||||
self.idents_to_str(module_path.get()),
|
||||
self.idents_to_str(directive.module_path),
|
||||
*self.session.str_of(target));
|
||||
|
||||
match module_.import_resolutions.find(&target) {
|
||||
@ -1887,7 +1886,7 @@ pub impl Resolver {
|
||||
let resolution = @mut ImportResolution(privacy,
|
||||
span,
|
||||
state);
|
||||
let name = self.idents_to_str(module_path.get());
|
||||
let name = self.idents_to_str(directive.module_path);
|
||||
// Don't warn about unused intrinsics because they're
|
||||
// automatically appended to all files
|
||||
if name == ~"intrinsic::rusti" {
|
||||
@ -1982,13 +1981,13 @@ pub impl Resolver {
|
||||
let import_count = module.imports.len();
|
||||
while module.resolved_import_count < import_count {
|
||||
let import_index = module.resolved_import_count;
|
||||
let import_directive = module.imports.get_elt(import_index);
|
||||
let import_directive = module.imports[import_index];
|
||||
match self.resolve_import_for_module(module, import_directive) {
|
||||
Failed => {
|
||||
// We presumably emitted an error. Continue.
|
||||
let idents = import_directive.module_path.get();
|
||||
let msg = fmt!("failed to resolve import: %s",
|
||||
*self.import_path_to_str(idents,
|
||||
*self.import_path_to_str(
|
||||
import_directive.module_path,
|
||||
*import_directive.subclass));
|
||||
self.session.span_err(import_directive.span, msg);
|
||||
}
|
||||
@ -2005,7 +2004,7 @@ pub impl Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
fn idents_to_str(@mut self, idents: ~[ident]) -> ~str {
|
||||
fn idents_to_str(@mut self, idents: &[ident]) -> ~str {
|
||||
let ident_strs = do idents.map |ident| {
|
||||
/*bad*/ copy *self.session.str_of(*ident)
|
||||
};
|
||||
@ -2043,11 +2042,11 @@ pub impl Resolver {
|
||||
import_directive: @ImportDirective)
|
||||
-> ResolveResult<()> {
|
||||
let mut resolution_result = Failed;
|
||||
let module_path = import_directive.module_path;
|
||||
let module_path = &import_directive.module_path;
|
||||
|
||||
debug!("(resolving import for module) resolving import `%s::...` in \
|
||||
`%s`",
|
||||
self.idents_to_str(module_path.get()),
|
||||
self.idents_to_str(*module_path),
|
||||
self.module_to_str(module_));
|
||||
|
||||
// First, resolve the module path for the directive, if necessary.
|
||||
@ -2056,7 +2055,7 @@ pub impl Resolver {
|
||||
Some(self.graph_root.get_module())
|
||||
} else {
|
||||
match self.resolve_module_path_for_import(module_,
|
||||
module_path,
|
||||
*module_path,
|
||||
DontUseLexicalScope,
|
||||
import_directive.span) {
|
||||
|
||||
@ -2574,21 +2573,21 @@ pub impl Resolver {
|
||||
/// Resolves the given module path from the given root `module_`.
|
||||
fn resolve_module_path_from_root(@mut self,
|
||||
module_: @mut Module,
|
||||
module_path: @DVec<ident>,
|
||||
module_path: ~[ident],
|
||||
index: uint,
|
||||
span: span,
|
||||
mut name_search_type: NameSearchType)
|
||||
-> ResolveResult<@mut Module> {
|
||||
let mut search_module = module_;
|
||||
let mut index = index;
|
||||
let module_path_len = (*module_path).len();
|
||||
let module_path_len = module_path.len();
|
||||
|
||||
// Resolve the module part of the path. This does not involve looking
|
||||
// upward though scope chains; we simply resolve names directly in
|
||||
// modules as we go.
|
||||
|
||||
while index < module_path_len {
|
||||
let name = (*module_path).get_elt(index);
|
||||
let name = module_path[index];
|
||||
match self.resolve_name_in_module(search_module,
|
||||
name,
|
||||
TypeNS,
|
||||
@ -2659,7 +2658,7 @@ pub impl Resolver {
|
||||
/// rooted at the given module.
|
||||
fn resolve_module_path_for_import(@mut self,
|
||||
module_: @mut Module,
|
||||
module_path: @DVec<ident>,
|
||||
module_path: ~[ident],
|
||||
use_lexical_scope: UseLexicalScopeFlag,
|
||||
span: span)
|
||||
-> ResolveResult<@mut Module> {
|
||||
@ -2668,7 +2667,7 @@ pub impl Resolver {
|
||||
|
||||
debug!("(resolving module path for import) processing `%s` rooted at \
|
||||
`%s`",
|
||||
self.idents_to_str((*module_path).get()),
|
||||
self.idents_to_str(module_path),
|
||||
self.module_to_str(module_));
|
||||
|
||||
// Resolve the module prefix, if any.
|
||||
@ -2704,7 +2703,7 @@ pub impl Resolver {
|
||||
// scope and then proceed to resolve below that.
|
||||
let result = self.resolve_module_in_lexical_scope(
|
||||
module_,
|
||||
module_path.get_elt(0));
|
||||
module_path[0]);
|
||||
match result {
|
||||
Failed => {
|
||||
self.session.span_err(span,
|
||||
@ -2945,7 +2944,7 @@ pub impl Resolver {
|
||||
*/
|
||||
fn resolve_module_prefix(@mut self,
|
||||
module_: @mut Module,
|
||||
module_path: @DVec<ident>)
|
||||
module_path: ~[ident])
|
||||
-> ResolveResult<ModulePrefixResult> {
|
||||
let interner = self.session.parse_sess.interner;
|
||||
|
||||
@ -2953,11 +2952,11 @@ pub impl Resolver {
|
||||
// top of the crate otherwise.
|
||||
let mut containing_module;
|
||||
let mut i;
|
||||
if *interner.get(module_path.get_elt(0)) == ~"self" {
|
||||
if *interner.get(module_path[0]) == ~"self" {
|
||||
containing_module =
|
||||
self.get_nearest_normal_module_parent_or_self(module_);
|
||||
i = 1;
|
||||
} else if *interner.get(module_path.get_elt(0)) == ~"super" {
|
||||
} else if *interner.get(module_path[0]) == ~"super" {
|
||||
containing_module =
|
||||
self.get_nearest_normal_module_parent_or_self(module_);
|
||||
i = 0; // We'll handle `super` below.
|
||||
@ -2967,7 +2966,7 @@ pub impl Resolver {
|
||||
|
||||
// Now loop through all the `super`s we find.
|
||||
while i < module_path.len() &&
|
||||
*interner.get(module_path.get_elt(i)) == ~"super" {
|
||||
*interner.get(module_path[i]) == ~"super" {
|
||||
debug!("(resolving module prefix) resolving `super` at %s",
|
||||
self.module_to_str(containing_module));
|
||||
match self.get_nearest_normal_module_parent(containing_module) {
|
||||
@ -3064,7 +3063,7 @@ pub impl Resolver {
|
||||
let index = module_.resolved_import_count;
|
||||
let import_count = module_.imports.len();
|
||||
if index != import_count {
|
||||
self.session.span_err(module_.imports.get_elt(index).span,
|
||||
self.session.span_err(module_.imports[index].span,
|
||||
~"unresolved import");
|
||||
}
|
||||
|
||||
@ -3283,7 +3282,7 @@ pub impl Resolver {
|
||||
// wrappers.
|
||||
|
||||
fn upvarify(@mut self,
|
||||
ribs: @DVec<@Rib>,
|
||||
ribs: &mut ~[@Rib],
|
||||
rib_index: uint,
|
||||
def_like: def_like,
|
||||
span: span,
|
||||
@ -3313,9 +3312,8 @@ pub impl Resolver {
|
||||
}
|
||||
|
||||
let mut rib_index = rib_index + 1;
|
||||
while rib_index < (*ribs).len() {
|
||||
let rib = (*ribs).get_elt(rib_index);
|
||||
match rib.kind {
|
||||
while rib_index < ribs.len() {
|
||||
match ribs[rib_index].kind {
|
||||
NormalRibKind => {
|
||||
// Nothing to do. Continue.
|
||||
}
|
||||
@ -3393,7 +3391,7 @@ pub impl Resolver {
|
||||
}
|
||||
|
||||
fn search_ribs(@mut self,
|
||||
ribs: @DVec<@Rib>,
|
||||
ribs: &mut ~[@Rib],
|
||||
name: ident,
|
||||
span: span,
|
||||
allow_capturing_self: AllowCapturingSelfFlag)
|
||||
@ -3401,14 +3399,13 @@ pub impl Resolver {
|
||||
// FIXME #4950: This should not use a while loop.
|
||||
// FIXME #4950: Try caching?
|
||||
|
||||
let mut i = (*ribs).len();
|
||||
let mut i = ribs.len();
|
||||
while i != 0 {
|
||||
i -= 1;
|
||||
let rib = (*ribs).get_elt(i);
|
||||
match rib.bindings.find(&name) {
|
||||
match ribs[i].bindings.find(&name) {
|
||||
Some(def_like) => {
|
||||
return self.upvarify(ribs, i, def_like, span,
|
||||
allow_capturing_self);
|
||||
allow_capturing_self);
|
||||
}
|
||||
None => {
|
||||
// Continue.
|
||||
@ -3502,7 +3499,7 @@ pub impl Resolver {
|
||||
item_trait(ref generics, ref traits, ref methods) => {
|
||||
// Create a new rib for the self type.
|
||||
let self_type_rib = @Rib(NormalRibKind);
|
||||
(*self.type_ribs).push(self_type_rib);
|
||||
self.type_ribs.push(self_type_rib);
|
||||
self_type_rib.bindings.insert(self.type_self_ident,
|
||||
dl_def(def_self_ty(item.id)));
|
||||
|
||||
@ -3573,7 +3570,7 @@ pub impl Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
(*self.type_ribs).pop();
|
||||
self.type_ribs.pop();
|
||||
}
|
||||
|
||||
item_struct(struct_def, ref generics) => {
|
||||
@ -3706,15 +3703,15 @@ pub impl Resolver {
|
||||
}
|
||||
|
||||
fn with_label_rib(@mut self, f: fn()) {
|
||||
(*self.label_ribs).push(@Rib(NormalRibKind));
|
||||
self.label_ribs.push(@Rib(NormalRibKind));
|
||||
f();
|
||||
(*self.label_ribs).pop();
|
||||
self.label_ribs.pop();
|
||||
}
|
||||
|
||||
fn with_constant_rib(@mut self, f: fn()) {
|
||||
(*self.value_ribs).push(@Rib(ConstantItemRibKind));
|
||||
self.value_ribs.push(@Rib(ConstantItemRibKind));
|
||||
f();
|
||||
(*self.value_ribs).pop();
|
||||
self.value_ribs.pop();
|
||||
}
|
||||
|
||||
fn resolve_function(@mut self,
|
||||
@ -3726,11 +3723,11 @@ pub impl Resolver {
|
||||
visitor: ResolveVisitor) {
|
||||
// Create a value rib for the function.
|
||||
let function_value_rib = @Rib(rib_kind);
|
||||
(*self.value_ribs).push(function_value_rib);
|
||||
self.value_ribs.push(function_value_rib);
|
||||
|
||||
// Create a label rib for the function.
|
||||
let function_label_rib = @Rib(rib_kind);
|
||||
(*self.label_ribs).push(function_label_rib);
|
||||
self.label_ribs.push(function_label_rib);
|
||||
|
||||
// If this function has type parameters, add them now.
|
||||
do self.with_type_parameter_rib(type_parameters) {
|
||||
@ -3790,8 +3787,8 @@ pub impl Resolver {
|
||||
debug!("(resolving function) leaving function");
|
||||
}
|
||||
|
||||
(*self.label_ribs).pop();
|
||||
(*self.value_ribs).pop();
|
||||
self.label_ribs.pop();
|
||||
self.value_ribs.pop();
|
||||
}
|
||||
|
||||
fn resolve_type_parameters(@mut self,
|
||||
@ -3891,10 +3888,10 @@ pub impl Resolver {
|
||||
visitor);
|
||||
|
||||
// Resolve the trait reference, if necessary.
|
||||
let original_trait_refs = self.current_trait_refs;
|
||||
let original_trait_refs;
|
||||
match opt_trait_reference {
|
||||
Some(trait_reference) => {
|
||||
let new_trait_refs = @DVec();
|
||||
let mut new_trait_refs = ~[];
|
||||
match self.resolve_path(
|
||||
trait_reference.path, TypeNS, true, visitor) {
|
||||
None => {
|
||||
@ -3906,13 +3903,17 @@ pub impl Resolver {
|
||||
self.record_def(trait_reference.ref_id, def);
|
||||
|
||||
// Record the current trait reference.
|
||||
(*new_trait_refs).push(def_id_of_def(def));
|
||||
new_trait_refs.push(def_id_of_def(def));
|
||||
}
|
||||
}
|
||||
// Record the current set of trait references.
|
||||
self.current_trait_refs = Some(new_trait_refs);
|
||||
let mut old = Some(new_trait_refs);
|
||||
self.current_trait_refs <-> old;
|
||||
original_trait_refs = Some(old);
|
||||
}
|
||||
None => {
|
||||
original_trait_refs = None;
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
|
||||
// Resolve the self type.
|
||||
@ -3945,7 +3946,10 @@ pub impl Resolver {
|
||||
}
|
||||
|
||||
// Restore the original trait references.
|
||||
self.current_trait_refs = original_trait_refs;
|
||||
match original_trait_refs {
|
||||
Some(r) => { self.current_trait_refs = r; }
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4032,7 +4036,7 @@ pub impl Resolver {
|
||||
}
|
||||
|
||||
fn resolve_arm(@mut self, arm: &arm, visitor: ResolveVisitor) {
|
||||
(*self.value_ribs).push(@Rib(NormalRibKind));
|
||||
self.value_ribs.push(@Rib(NormalRibKind));
|
||||
|
||||
let bindings_list = HashMap();
|
||||
for arm.pats.each |pattern| {
|
||||
@ -4047,12 +4051,12 @@ pub impl Resolver {
|
||||
visit_expr_opt(arm.guard, (), visitor);
|
||||
self.resolve_block(&arm.body, visitor);
|
||||
|
||||
(*self.value_ribs).pop();
|
||||
self.value_ribs.pop();
|
||||
}
|
||||
|
||||
fn resolve_block(@mut self, block: &blk, visitor: ResolveVisitor) {
|
||||
debug!("(resolving block) entering block");
|
||||
(*self.value_ribs).push(@Rib(NormalRibKind));
|
||||
self.value_ribs.push(@Rib(NormalRibKind));
|
||||
|
||||
// Move down in the graph, if there's an anonymous module rooted here.
|
||||
let orig_module = self.current_module;
|
||||
@ -4071,7 +4075,7 @@ pub impl Resolver {
|
||||
// Move back up.
|
||||
self.current_module = orig_module;
|
||||
|
||||
(*self.value_ribs).pop();
|
||||
self.value_ribs.pop();
|
||||
debug!("(resolving block) leaving block");
|
||||
}
|
||||
|
||||
@ -4251,7 +4255,8 @@ pub impl Resolver {
|
||||
Some(bindings_list)
|
||||
if !bindings_list.contains_key(&ident)
|
||||
=> {
|
||||
let last_rib = (*self.value_ribs).last();
|
||||
let last_rib = self.value_ribs[
|
||||
self.value_ribs.len() - 1];
|
||||
last_rib.bindings.insert(ident,
|
||||
dl_def(def));
|
||||
bindings_list.insert(ident, pat_id);
|
||||
@ -4270,7 +4275,8 @@ pub impl Resolver {
|
||||
// Not bound in the same pattern: do nothing
|
||||
}
|
||||
None => {
|
||||
let last_rib = (*self.value_ribs).last();
|
||||
let last_rib = self.value_ribs[
|
||||
self.value_ribs.len() - 1];
|
||||
last_rib.bindings.insert(ident,
|
||||
dl_def(def));
|
||||
}
|
||||
@ -4510,14 +4516,14 @@ pub impl Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
fn intern_module_part_of_path(@mut self, path: @path) -> @DVec<ident> {
|
||||
let module_path_idents = @DVec();
|
||||
fn intern_module_part_of_path(@mut self, path: @path) -> ~[ident] {
|
||||
let mut module_path_idents = ~[];
|
||||
for path.idents.eachi |index, ident| {
|
||||
if index == path.idents.len() - 1 {
|
||||
break;
|
||||
}
|
||||
|
||||
(*module_path_idents).push(*ident);
|
||||
module_path_idents.push(*ident);
|
||||
}
|
||||
|
||||
return module_path_idents;
|
||||
@ -4539,7 +4545,7 @@ pub impl Resolver {
|
||||
self.session.span_err(path.span,
|
||||
fmt!("use of undeclared module `%s`",
|
||||
self.idents_to_str(
|
||||
(*module_path_idents).get())));
|
||||
module_path_idents)));
|
||||
return None;
|
||||
}
|
||||
|
||||
@ -4587,8 +4593,8 @@ pub impl Resolver {
|
||||
Failed => {
|
||||
self.session.span_err(path.span,
|
||||
fmt!("use of undeclared module `::%s`",
|
||||
self.idents_to_str
|
||||
((*module_path_idents).get())));
|
||||
self.idents_to_str(
|
||||
module_path_idents)));
|
||||
return None;
|
||||
}
|
||||
|
||||
@ -4625,12 +4631,13 @@ pub impl Resolver {
|
||||
let mut search_result;
|
||||
match namespace {
|
||||
ValueNS => {
|
||||
search_result = self.search_ribs(self.value_ribs, ident, span,
|
||||
search_result = self.search_ribs(&mut self.value_ribs, ident,
|
||||
span,
|
||||
DontAllowCapturingSelf);
|
||||
}
|
||||
TypeNS => {
|
||||
search_result = self.search_ribs(self.type_ribs, ident, span,
|
||||
AllowCapturingSelf);
|
||||
search_result = self.search_ribs(&mut self.type_ribs, ident,
|
||||
span, AllowCapturingSelf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4688,8 +4695,7 @@ pub impl Resolver {
|
||||
let mut j = self.value_ribs.len();
|
||||
while j != 0 {
|
||||
j -= 1;
|
||||
let rib = self.value_ribs.get_elt(j);
|
||||
for rib.bindings.each_entry |e| {
|
||||
for self.value_ribs[j].bindings.each_entry |e| {
|
||||
vec::push(&mut maybes, copy *self.session.str_of(e.key));
|
||||
vec::push(&mut values, uint::max_value);
|
||||
}
|
||||
@ -4721,8 +4727,7 @@ pub impl Resolver {
|
||||
let mut i = self.type_ribs.len();
|
||||
while i != 0 {
|
||||
i -= 1;
|
||||
let rib = self.type_ribs.get_elt(i);
|
||||
match rib.kind {
|
||||
match self.type_ribs[i].kind {
|
||||
MethodRibKind(node_id, _) =>
|
||||
for self.crate.node.module.items.each |item| {
|
||||
if item.id == node_id {
|
||||
@ -4839,14 +4844,15 @@ pub impl Resolver {
|
||||
expr_loop(_, Some(label)) => {
|
||||
do self.with_label_rib {
|
||||
let def_like = dl_def(def_label(expr.id));
|
||||
self.label_ribs.last().bindings.insert(label, def_like);
|
||||
let rib = self.label_ribs[self.label_ribs.len() - 1];
|
||||
rib.bindings.insert(label, def_like);
|
||||
|
||||
visit_expr(expr, (), visitor);
|
||||
}
|
||||
}
|
||||
|
||||
expr_break(Some(label)) | expr_again(Some(label)) => {
|
||||
match self.search_ribs(self.label_ribs, label, expr.span,
|
||||
match self.search_ribs(&mut self.label_ribs, label, expr.span,
|
||||
DontAllowCapturingSelf) {
|
||||
None =>
|
||||
self.session.span_err(expr.span,
|
||||
@ -4873,11 +4879,11 @@ pub impl Resolver {
|
||||
match expr.node {
|
||||
expr_field(_, ident, _) => {
|
||||
let traits = self.search_for_traits_containing_method(ident);
|
||||
self.trait_map.insert(expr.id, traits);
|
||||
self.trait_map.insert(expr.id, @mut traits);
|
||||
}
|
||||
expr_method_call(_, ident, _, _, _) => {
|
||||
let traits = self.search_for_traits_containing_method(ident);
|
||||
self.trait_map.insert(expr.id, traits);
|
||||
self.trait_map.insert(expr.id, @mut traits);
|
||||
}
|
||||
expr_binary(add, _, _) | expr_assign_op(add, _, _) => {
|
||||
self.add_fixed_trait_for_expr(expr.id,
|
||||
@ -4948,11 +4954,11 @@ pub impl Resolver {
|
||||
|
||||
fn search_for_traits_containing_method(@mut self,
|
||||
name: ident)
|
||||
-> @DVec<def_id> {
|
||||
-> ~[def_id] {
|
||||
debug!("(searching for traits containing method) looking for '%s'",
|
||||
*self.session.str_of(name));
|
||||
|
||||
let found_traits = @DVec();
|
||||
let mut found_traits = ~[];
|
||||
let mut search_module = self.current_module;
|
||||
loop {
|
||||
// Look for the current trait.
|
||||
@ -4960,7 +4966,7 @@ pub impl Resolver {
|
||||
Some(trait_def_ids) => {
|
||||
for trait_def_ids.each |trait_def_id| {
|
||||
self.add_trait_info_if_containing_method(
|
||||
found_traits, *trait_def_id, name);
|
||||
&mut found_traits, *trait_def_id, name);
|
||||
}
|
||||
}
|
||||
None => {
|
||||
@ -4975,7 +4981,7 @@ pub impl Resolver {
|
||||
match def {
|
||||
def_ty(trait_def_id) => {
|
||||
self.add_trait_info_if_containing_method(
|
||||
found_traits, trait_def_id, name);
|
||||
&mut found_traits, trait_def_id, name);
|
||||
}
|
||||
_ => {
|
||||
// Continue.
|
||||
@ -5003,7 +5009,8 @@ pub impl Resolver {
|
||||
def_ty(trait_def_id) => {
|
||||
let added = self.
|
||||
add_trait_info_if_containing_method(
|
||||
found_traits, trait_def_id, name);
|
||||
&mut found_traits,
|
||||
trait_def_id, name);
|
||||
if added {
|
||||
import_resolution.state.used =
|
||||
true;
|
||||
@ -5039,7 +5046,7 @@ pub impl Resolver {
|
||||
}
|
||||
|
||||
fn add_trait_info_if_containing_method(@mut self,
|
||||
found_traits: @DVec<def_id>,
|
||||
found_traits: &mut ~[def_id],
|
||||
trait_def_id: def_id,
|
||||
name: ident)
|
||||
-> bool {
|
||||
@ -5056,7 +5063,7 @@ pub impl Resolver {
|
||||
trait_def_id.crate,
|
||||
trait_def_id.node,
|
||||
*self.session.str_of(name));
|
||||
(*found_traits).push(trait_def_id);
|
||||
found_traits.push(trait_def_id);
|
||||
true
|
||||
}
|
||||
Some(_) | None => {
|
||||
@ -5068,9 +5075,7 @@ pub impl Resolver {
|
||||
fn add_fixed_trait_for_expr(@mut self,
|
||||
expr_id: node_id,
|
||||
+trait_id: def_id) {
|
||||
let traits = @DVec();
|
||||
traits.push(trait_id);
|
||||
self.trait_map.insert(expr_id, traits);
|
||||
self.trait_map.insert(expr_id, @mut ~[trait_id]);
|
||||
}
|
||||
|
||||
fn record_def(@mut self, node_id: node_id, def: def) {
|
||||
@ -5225,7 +5230,7 @@ pub impl Resolver {
|
||||
|
||||
/// A somewhat inefficient routine to obtain the name of a module.
|
||||
fn module_to_str(@mut self, module_: @mut Module) -> ~str {
|
||||
let idents = DVec();
|
||||
let mut idents = ~[];
|
||||
let mut current_module = module_;
|
||||
loop {
|
||||
match current_module.parent_link {
|
||||
@ -5246,7 +5251,7 @@ pub impl Resolver {
|
||||
if idents.len() == 0 {
|
||||
return ~"???";
|
||||
}
|
||||
return self.idents_to_str(vec::reversed(idents.get()));
|
||||
return self.idents_to_str(vec::reversed(idents));
|
||||
}
|
||||
|
||||
fn dump_module(@mut self, module_: @mut Module) {
|
||||
|
@ -167,8 +167,6 @@ use middle::trans::type_of;
|
||||
use middle::ty;
|
||||
use util::common::indenter;
|
||||
|
||||
use core::dvec::DVec;
|
||||
use core::dvec;
|
||||
use std::oldmap::HashMap;
|
||||
use syntax::ast;
|
||||
use syntax::ast::ident;
|
||||
@ -553,7 +551,7 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
|
||||
// Reorder the patterns into the same order they were
|
||||
// specified in the struct definition. Also fill in
|
||||
// unspecified fields with dummy.
|
||||
let reordered_patterns = dvec::DVec();
|
||||
let mut reordered_patterns = ~[];
|
||||
for ty::lookup_struct_fields(tcx, struct_id).each
|
||||
|field| {
|
||||
match field_pats.find(|p|
|
||||
@ -562,7 +560,7 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
|
||||
Some(fp) => reordered_patterns.push(fp.pat)
|
||||
}
|
||||
}
|
||||
Some(dvec::unwrap(reordered_patterns))
|
||||
Some(reordered_patterns)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -764,32 +762,32 @@ pub fn enter_region(bcx: block,
|
||||
// on a set of enum variants or a literal.
|
||||
pub fn get_options(bcx: block, m: &[@Match], col: uint) -> ~[Opt] {
|
||||
let ccx = bcx.ccx();
|
||||
fn add_to_set(tcx: ty::ctxt, set: &DVec<Opt>, +val: Opt) {
|
||||
fn add_to_set(tcx: ty::ctxt, set: &mut ~[Opt], +val: Opt) {
|
||||
if set.any(|l| opt_eq(tcx, l, &val)) {return;}
|
||||
set.push(val);
|
||||
}
|
||||
|
||||
let found = DVec();
|
||||
for vec::each(m) |br| {
|
||||
let mut found = ~[];
|
||||
for m.each |br| {
|
||||
let cur = br.pats[col];
|
||||
match /*bad*/copy cur.node {
|
||||
ast::pat_lit(l) => {
|
||||
add_to_set(ccx.tcx, &found, lit(ExprLit(l)));
|
||||
add_to_set(ccx.tcx, &mut found, lit(ExprLit(l)));
|
||||
}
|
||||
ast::pat_ident(*) => {
|
||||
// This is one of: an enum variant, a unit-like struct, or a
|
||||
// variable binding.
|
||||
match ccx.tcx.def_map.find(&cur.id) {
|
||||
Some(ast::def_variant(*)) => {
|
||||
add_to_set(ccx.tcx, &found,
|
||||
add_to_set(ccx.tcx, &mut found,
|
||||
variant_opt(bcx, cur.id));
|
||||
}
|
||||
Some(ast::def_struct(*)) => {
|
||||
add_to_set(ccx.tcx, &found,
|
||||
add_to_set(ccx.tcx, &mut found,
|
||||
lit(UnitLikeStructLit(cur.id)));
|
||||
}
|
||||
Some(ast::def_const(const_did)) => {
|
||||
add_to_set(ccx.tcx, &found,
|
||||
add_to_set(ccx.tcx, &mut found,
|
||||
lit(ConstLit(const_did)));
|
||||
}
|
||||
_ => {}
|
||||
@ -800,26 +798,26 @@ pub fn get_options(bcx: block, m: &[@Match], col: uint) -> ~[Opt] {
|
||||
// struct-like enum variant, or a struct.
|
||||
match ccx.tcx.def_map.find(&cur.id) {
|
||||
Some(ast::def_variant(*)) => {
|
||||
add_to_set(ccx.tcx, &found,
|
||||
add_to_set(ccx.tcx, &mut found,
|
||||
variant_opt(bcx, cur.id));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
ast::pat_range(l1, l2) => {
|
||||
add_to_set(ccx.tcx, &found, range(l1, l2));
|
||||
add_to_set(ccx.tcx, &mut found, range(l1, l2));
|
||||
}
|
||||
ast::pat_vec(elems, tail) => {
|
||||
let opt = match tail {
|
||||
None => vec_len_eq(elems.len()),
|
||||
Some(_) => vec_len_ge(elems.len())
|
||||
};
|
||||
add_to_set(ccx.tcx, &found, opt);
|
||||
add_to_set(ccx.tcx, &mut found, opt);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
return dvec::unwrap(found);
|
||||
return found;
|
||||
}
|
||||
|
||||
pub struct ExtractedBlock {
|
||||
@ -1074,7 +1072,7 @@ pub fn compare_values(cx: block,
|
||||
|
||||
pub fn store_non_ref_bindings(bcx: block,
|
||||
data: &ArmData,
|
||||
opt_temp_cleanups: Option<&DVec<ValueRef>>)
|
||||
opt_temp_cleanups: Option<&mut ~[ValueRef]>)
|
||||
-> block {
|
||||
/*!
|
||||
*
|
||||
@ -1166,8 +1164,8 @@ pub fn compile_guard(bcx: block,
|
||||
let _indenter = indenter();
|
||||
|
||||
let mut bcx = bcx;
|
||||
let temp_cleanups = DVec();
|
||||
bcx = store_non_ref_bindings(bcx, data, Some(&temp_cleanups));
|
||||
let mut temp_cleanups = ~[];
|
||||
bcx = store_non_ref_bindings(bcx, data, Some(&mut temp_cleanups));
|
||||
bcx = insert_lllocals(bcx, data, false);
|
||||
|
||||
let val = unpack_result!(bcx, {
|
||||
@ -1627,7 +1625,7 @@ pub fn trans_match_inner(scope_cx: block,
|
||||
let lldiscr = discr_datum.to_ref_llval(bcx);
|
||||
compile_submatch(bcx, matches, ~[lldiscr], chk);
|
||||
|
||||
let arm_cxs = DVec();
|
||||
let mut arm_cxs = ~[];
|
||||
for arm_datas.each |arm_data| {
|
||||
let mut bcx = arm_data.bodycx;
|
||||
|
||||
@ -1647,7 +1645,7 @@ pub fn trans_match_inner(scope_cx: block,
|
||||
arm_cxs.push(bcx);
|
||||
}
|
||||
|
||||
bcx = controlflow::join_blocks(scope_cx, dvec::unwrap(arm_cxs));
|
||||
bcx = controlflow::join_blocks(scope_cx, arm_cxs);
|
||||
return bcx;
|
||||
|
||||
fn mk_fail(bcx: block, sp: span, msg: @~str,
|
||||
|
@ -29,8 +29,6 @@ use util::common::{indenter};
|
||||
|
||||
use core::cast;
|
||||
use core::cmp;
|
||||
use core::dvec::DVec;
|
||||
use core::dvec;
|
||||
use core::ops;
|
||||
use core::option;
|
||||
use core::ptr::to_unsafe_ptr;
|
||||
@ -213,7 +211,7 @@ pub enum AutoRefKind {
|
||||
// This is a map from ID of each implementation to the method info and trait
|
||||
// method ID of each of the default methods belonging to the trait that that
|
||||
// implementation implements.
|
||||
pub type ProvidedMethodsMap = HashMap<def_id,@DVec<@ProvidedMethodInfo>>;
|
||||
pub type ProvidedMethodsMap = HashMap<def_id,@mut ~[@ProvidedMethodInfo]>;
|
||||
|
||||
// Stores the method info and definition ID of the associated trait method for
|
||||
// each instantiation of each provided method.
|
||||
@ -3522,7 +3520,7 @@ pub fn trait_supertraits(cx: ctxt,
|
||||
|
||||
// Get the supertraits out of the metadata and create the
|
||||
// InstantiatedTraitRef for each.
|
||||
let result = dvec::DVec();
|
||||
let mut result = ~[];
|
||||
for csearch::get_supertraits(cx, id).each |trait_type| {
|
||||
match get(*trait_type).sty {
|
||||
ty_trait(def_id, ref substs, _) => {
|
||||
@ -3539,7 +3537,7 @@ pub fn trait_supertraits(cx: ctxt,
|
||||
}
|
||||
|
||||
// Unwrap and return the result.
|
||||
return @dvec::unwrap(result);
|
||||
return @result;
|
||||
}
|
||||
|
||||
pub fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] {
|
||||
|
@ -95,7 +95,6 @@ use middle::typeck::{method_self, method_static, method_trait, method_super};
|
||||
use util::common::indenter;
|
||||
use util::ppaux::expr_repr;
|
||||
|
||||
use core::dvec::DVec;
|
||||
use core::result;
|
||||
use core::uint;
|
||||
use core::vec;
|
||||
@ -127,8 +126,8 @@ pub fn lookup(
|
||||
m_name: m_name,
|
||||
supplied_tps: supplied_tps,
|
||||
impl_dups: HashMap(),
|
||||
inherent_candidates: DVec(),
|
||||
extension_candidates: DVec(),
|
||||
inherent_candidates: @mut ~[],
|
||||
extension_candidates: @mut ~[],
|
||||
deref_args: deref_args,
|
||||
};
|
||||
let mme = lcx.do_lookup(self_ty);
|
||||
@ -145,8 +144,8 @@ pub struct LookupContext {
|
||||
m_name: ast::ident,
|
||||
supplied_tps: &self/[ty::t],
|
||||
impl_dups: HashMap<def_id, ()>,
|
||||
inherent_candidates: DVec<Candidate>,
|
||||
extension_candidates: DVec<Candidate>,
|
||||
inherent_candidates: @mut ~[Candidate],
|
||||
extension_candidates: @mut ~[Candidate],
|
||||
deref_args: check::DerefArgs,
|
||||
}
|
||||
|
||||
@ -188,7 +187,7 @@ pub impl LookupContext/&self {
|
||||
self.push_inherent_candidates(self_ty);
|
||||
self.push_extension_candidates(self_ty);
|
||||
|
||||
let enum_dids = DVec();
|
||||
let mut enum_dids = ~[];
|
||||
let mut self_ty = self_ty;
|
||||
let mut autoderefs = 0;
|
||||
loop {
|
||||
@ -224,7 +223,7 @@ pub impl LookupContext/&self {
|
||||
}
|
||||
}
|
||||
|
||||
match self.deref(self_ty, &enum_dids) {
|
||||
match self.deref(self_ty, &mut enum_dids) {
|
||||
None => { break; }
|
||||
Some(ty) => {
|
||||
self_ty = ty;
|
||||
@ -236,7 +235,7 @@ pub impl LookupContext/&self {
|
||||
self.search_for_autosliced_method(self_ty, autoderefs)
|
||||
}
|
||||
|
||||
fn deref(ty: ty::t, enum_dids: &DVec<ast::def_id>) -> Option<ty::t> {
|
||||
fn deref(ty: ty::t, enum_dids: &mut ~[ast::def_id]) -> Option<ty::t> {
|
||||
match ty::get(ty).sty {
|
||||
ty_enum(did, _) => {
|
||||
// Watch out for newtype'd enums like "enum t = @T".
|
||||
@ -272,7 +271,7 @@ pub impl LookupContext/&self {
|
||||
* example, if the receiver is @@C where `C` is a struct type,
|
||||
* we'll want to find the inherent impls for `C`. */
|
||||
|
||||
let enum_dids = DVec();
|
||||
let mut enum_dids = ~[];
|
||||
let mut self_ty = self_ty;
|
||||
loop {
|
||||
match get(self_ty).sty {
|
||||
@ -307,7 +306,7 @@ pub impl LookupContext/&self {
|
||||
// n.b.: Generally speaking, we only loop if we hit the
|
||||
// fallthrough case in the match above. The exception
|
||||
// would be newtype enums.
|
||||
self_ty = match self.deref(self_ty, &enum_dids) {
|
||||
self_ty = match self.deref(self_ty, &mut enum_dids) {
|
||||
None => { return; }
|
||||
Some(ty) => { ty }
|
||||
}
|
||||
@ -330,7 +329,7 @@ pub impl LookupContext/&self {
|
||||
for opt_impl_infos.each |impl_infos| {
|
||||
for impl_infos.each |impl_info| {
|
||||
self.push_candidates_from_impl(
|
||||
&self.extension_candidates, *impl_info);
|
||||
self.extension_candidates, *impl_info);
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,7 +337,7 @@ pub impl LookupContext/&self {
|
||||
match self.tcx().provided_methods.find(trait_did) {
|
||||
Some(methods) => {
|
||||
self.push_candidates_from_provided_methods(
|
||||
&self.extension_candidates, self_ty, *trait_did,
|
||||
self.extension_candidates, self_ty, *trait_did,
|
||||
methods);
|
||||
}
|
||||
None => {}
|
||||
@ -606,12 +605,12 @@ pub impl LookupContext/&self {
|
||||
for opt_impl_infos.each |impl_infos| {
|
||||
for impl_infos.each |impl_info| {
|
||||
self.push_candidates_from_impl(
|
||||
&self.inherent_candidates, *impl_info);
|
||||
self.inherent_candidates, *impl_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn push_candidates_from_impl(&self, candidates: &DVec<Candidate>,
|
||||
fn push_candidates_from_impl(&self, candidates: &mut ~[Candidate],
|
||||
impl_info: &resolve::Impl) {
|
||||
if !self.impl_dups.insert(impl_info.did, ()) {
|
||||
return; // already visited
|
||||
@ -657,10 +656,10 @@ pub impl LookupContext/&self {
|
||||
|
||||
fn push_candidates_from_provided_methods(
|
||||
&self,
|
||||
candidates: &DVec<Candidate>,
|
||||
candidates: &mut ~[Candidate],
|
||||
self_ty: ty::t,
|
||||
trait_def_id: def_id,
|
||||
methods: @DVec<@ProvidedMethodInfo>) {
|
||||
methods: &mut ~[@ProvidedMethodInfo]) {
|
||||
debug!("(pushing candidates from provided methods) considering trait \
|
||||
id %d:%d",
|
||||
trait_def_id.crate,
|
||||
@ -970,7 +969,7 @@ pub impl LookupContext/&self {
|
||||
// existing code.
|
||||
|
||||
debug!("searching inherent candidates");
|
||||
match self.consider_candidates(self_ty, &self.inherent_candidates) {
|
||||
match self.consider_candidates(self_ty, self.inherent_candidates) {
|
||||
None => {}
|
||||
Some(mme) => {
|
||||
return Some(mme);
|
||||
@ -978,7 +977,7 @@ pub impl LookupContext/&self {
|
||||
}
|
||||
|
||||
debug!("searching extension candidates");
|
||||
match self.consider_candidates(self_ty, &self.extension_candidates) {
|
||||
match self.consider_candidates(self_ty, self.extension_candidates) {
|
||||
None => {
|
||||
return None;
|
||||
}
|
||||
@ -990,7 +989,7 @@ pub impl LookupContext/&self {
|
||||
|
||||
fn consider_candidates(&self,
|
||||
self_ty: ty::t,
|
||||
candidates: &DVec<Candidate>)
|
||||
candidates: &mut ~[Candidate])
|
||||
-> Option<method_map_entry>
|
||||
{
|
||||
let relevant_candidates =
|
||||
|
@ -55,7 +55,6 @@ use syntax::visit::{Visitor, SimpleVisitor};
|
||||
use syntax::visit::{visit_mod};
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use core::dvec::DVec;
|
||||
use core::result::Ok;
|
||||
use core::hashmap::linear::LinearSet;
|
||||
use core::uint;
|
||||
@ -151,11 +150,11 @@ pub fn method_to_MethodInfo(ast_method: @method) -> @MethodInfo {
|
||||
pub struct CoherenceInfo {
|
||||
// Contains implementations of methods that are inherent to a type.
|
||||
// Methods in these implementations don't need to be exported.
|
||||
inherent_methods: HashMap<def_id,@DVec<@Impl>>,
|
||||
inherent_methods: HashMap<def_id,@mut ~[@Impl]>,
|
||||
|
||||
// Contains implementations of methods associated with a trait. For these,
|
||||
// the associated trait must be imported at the call site.
|
||||
extension_methods: HashMap<def_id,@DVec<@Impl>>,
|
||||
extension_methods: HashMap<def_id,@mut ~[@Impl]>,
|
||||
|
||||
}
|
||||
|
||||
@ -372,9 +371,8 @@ pub impl CoherenceChecker {
|
||||
for method `%s`",
|
||||
*self.crate_context.tcx.sess.str_of(
|
||||
provided_method_info.method_info.ident));
|
||||
let method_infos = @DVec();
|
||||
method_infos.push(provided_method_info);
|
||||
pmm.insert(local_def(impl_id), method_infos);
|
||||
pmm.insert(local_def(impl_id),
|
||||
@mut ~[provided_method_info]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -386,7 +384,7 @@ pub impl CoherenceChecker {
|
||||
match self.crate_context.coherence_info.inherent_methods
|
||||
.find(&base_def_id) {
|
||||
None => {
|
||||
implementation_list = @DVec();
|
||||
implementation_list = @mut ~[];
|
||||
self.crate_context.coherence_info.inherent_methods
|
||||
.insert(base_def_id, implementation_list);
|
||||
}
|
||||
@ -403,7 +401,7 @@ pub impl CoherenceChecker {
|
||||
match self.crate_context.coherence_info.extension_methods
|
||||
.find(&trait_id) {
|
||||
None => {
|
||||
implementation_list = @DVec();
|
||||
implementation_list = @mut ~[];
|
||||
self.crate_context.coherence_info.extension_methods
|
||||
.insert(trait_id, implementation_list);
|
||||
}
|
||||
@ -741,13 +739,13 @@ pub impl CoherenceChecker {
|
||||
// Converts an implementation in the AST to an Impl structure.
|
||||
fn create_impl_from_item(&self, item: @item) -> @Impl {
|
||||
fn add_provided_methods(all_methods: &mut ~[@MethodInfo],
|
||||
all_provided_methods: ~[@ProvidedMethodInfo],
|
||||
sess: driver::session::Session) {
|
||||
all_provided_methods: &mut ~[@ProvidedMethodInfo],
|
||||
sess: driver::session::Session) {
|
||||
for all_provided_methods.each |provided_method| {
|
||||
debug!(
|
||||
"(creating impl) adding provided method `%s` to impl",
|
||||
*sess.str_of(provided_method.method_info.ident));
|
||||
vec::push(&mut *all_methods, provided_method.method_info);
|
||||
vec::push(all_methods, provided_method.method_info);
|
||||
}
|
||||
}
|
||||
|
||||
@ -790,7 +788,7 @@ pub impl CoherenceChecker {
|
||||
// Add all provided methods.
|
||||
add_provided_methods(
|
||||
&mut methods,
|
||||
all_provided.get(),
|
||||
all_provided,
|
||||
self.crate_context.tcx.sess);
|
||||
}
|
||||
}
|
||||
@ -943,9 +941,7 @@ pub impl CoherenceChecker {
|
||||
trait_method_def_id: trait_method_info.def_id
|
||||
};
|
||||
|
||||
let method_infos = @DVec();
|
||||
method_infos.push(provided_method_info);
|
||||
pmm.insert(trait_def_id, method_infos);
|
||||
pmm.insert(trait_def_id, @mut ~[provided_method_info]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,6 @@ use middle::typeck::{CrateCtxt, lookup_def_tcx, no_params, write_ty_to_tcx};
|
||||
use util::common::{indenter, pluralize};
|
||||
use util::ppaux;
|
||||
|
||||
use core::dvec;
|
||||
use core::vec;
|
||||
use syntax::ast::{RegionTyParamBound, TraitTyParamBound};
|
||||
use syntax::ast;
|
||||
@ -321,7 +320,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt,
|
||||
let tcx = ccx.tcx;
|
||||
if tcx.supertraits.contains_key(&local_def(id)) { return; }
|
||||
|
||||
let instantiated = dvec::DVec();
|
||||
let mut instantiated = ~[];
|
||||
for trait_refs.each |trait_ref| {
|
||||
let (did, tpt) = instantiate_trait_ref(ccx, *trait_ref, rp);
|
||||
if instantiated.any(|other_trait: &InstantiatedTraitRef|
|
||||
@ -334,8 +333,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt,
|
||||
}
|
||||
instantiated.push(InstantiatedTraitRef { def_id: did, tpt: tpt });
|
||||
}
|
||||
tcx.supertraits.insert(local_def(id),
|
||||
@dvec::unwrap(instantiated));
|
||||
tcx.supertraits.insert(local_def(id), @instantiated);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -549,7 +549,6 @@ use util::ppaux::note_and_explain_region;
|
||||
|
||||
use core::cell::{Cell, empty_cell};
|
||||
use core::cmp;
|
||||
use core::dvec::DVec;
|
||||
use core::result::{Err, Ok, Result};
|
||||
use core::to_bytes;
|
||||
use core::uint;
|
||||
@ -627,7 +626,7 @@ type CombineMap = HashMap<TwoRegions, RegionVid>;
|
||||
|
||||
pub struct RegionVarBindings {
|
||||
tcx: ty::ctxt,
|
||||
var_spans: DVec<span>,
|
||||
var_spans: ~[span],
|
||||
constraints: HashMap<Constraint, span>,
|
||||
lubs: CombineMap,
|
||||
glbs: CombineMap,
|
||||
@ -653,7 +652,7 @@ pub struct RegionVarBindings {
|
||||
pub fn RegionVarBindings(tcx: ty::ctxt) -> RegionVarBindings {
|
||||
RegionVarBindings {
|
||||
tcx: tcx,
|
||||
var_spans: DVec(),
|
||||
var_spans: ~[],
|
||||
values: empty_cell(),
|
||||
constraints: HashMap(),
|
||||
lubs: CombineMap(),
|
||||
|
Loading…
Reference in New Issue
Block a user