Skip to content

syntax: replace OptVec with plain Vec. #12675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/librustc/front/std_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use syntax::codemap::DUMMY_SP;
use syntax::codemap;
use syntax::fold::Folder;
use syntax::fold;
use syntax::opt_vec;
use syntax::parse::token::InternedString;
use syntax::parse::token;
use syntax::util::small_vector::SmallVector;
Expand Down Expand Up @@ -164,13 +163,13 @@ impl fold::Folder for PreludeInjector {
segments: vec!(
ast::PathSegment {
identifier: token::str_to_ident("std"),
lifetimes: opt_vec::Empty,
types: opt_vec::Empty,
lifetimes: Vec::new(),
types: Vec::new(),
},
ast::PathSegment {
identifier: token::str_to_ident("prelude"),
lifetimes: opt_vec::Empty,
types: opt_vec::Empty,
lifetimes: Vec::new(),
types: Vec::new(),
}),
};

Expand Down
9 changes: 4 additions & 5 deletions src/librustc/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use syntax::codemap;
use syntax::ext::base::ExtCtxt;
use syntax::fold::Folder;
use syntax::fold;
use syntax::opt_vec;
use syntax::parse::token::InternedString;
use syntax::parse::token;
use syntax::print::pprust;
Expand Down Expand Up @@ -370,8 +369,8 @@ fn path_node(ids: ~[ast::Ident]) -> ast::Path {
global: false,
segments: ids.move_iter().map(|identifier| ast::PathSegment {
identifier: identifier,
lifetimes: opt_vec::Empty,
types: opt_vec::Empty,
lifetimes: Vec::new(),
types: Vec::new(),
}).collect()
}
}
Expand All @@ -382,8 +381,8 @@ fn path_node_global(ids: ~[ast::Ident]) -> ast::Path {
global: true,
segments: ids.move_iter().map(|identifier| ast::PathSegment {
identifier: identifier,
lifetimes: opt_vec::Empty,
types: opt_vec::Empty,
lifetimes: Vec::new(),
types: Vec::new(),
}).collect()
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ use middle::ty;

use std::str;
use std::uint;
use std::vec_ng::Vec;
use syntax::abi::AbiSet;
use syntax::abi;
use syntax::ast;
use syntax::ast::*;
use syntax::opt_vec;
use syntax::parse::token;

// Compact string representation for ty::t values. API ty_str &
Expand Down Expand Up @@ -192,7 +192,7 @@ fn parse_region_substs(st: &mut PState, conv: conv_did) -> ty::RegionSubsts {
match next(st) {
'e' => ty::ErasedRegions,
'n' => {
let mut regions = opt_vec::Empty;
let mut regions = Vec::new();
while peek(st) != '.' {
let r = parse_region(st, |x,y| conv(x,y));
regions.push(r);
Expand Down
9 changes: 4 additions & 5 deletions src/librustc/middle/borrowck/move_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ comments in the section "Moves and initialization" and in `doc.rs`.

use std::cell::RefCell;
use std::uint;
use std::vec_ng::Vec;
use collections::{HashMap, HashSet};
use middle::borrowck::*;
use middle::dataflow::DataFlowContext;
Expand All @@ -26,8 +27,6 @@ use middle::typeck;
use syntax::ast;
use syntax::ast_util;
use syntax::codemap::Span;
use syntax::opt_vec::OptVec;
use syntax::opt_vec;
use util::ppaux::Repr;

pub struct MoveData {
Expand Down Expand Up @@ -314,15 +313,15 @@ impl MoveData {

fn existing_base_paths(&self,
lp: @LoanPath)
-> OptVec<MovePathIndex> {
let mut result = opt_vec::Empty;
-> Vec<MovePathIndex> {
let mut result = Vec::new();
self.add_existing_base_paths(lp, &mut result);
result
}

fn add_existing_base_paths(&self,
lp: @LoanPath,
result: &mut OptVec<MovePathIndex>) {
result: &mut Vec<MovePathIndex>) {
/*!
* Adds any existing move path indices for `lp` and any base
* paths of `lp` to `result`, but does not add new move paths
Expand Down
7 changes: 4 additions & 3 deletions src/librustc/middle/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use middle::ty;
use collections::HashMap;
use syntax::ast;
use syntax::ast_util;
use syntax::opt_vec;

use std::vec_ng::Vec;

struct CFGBuilder {
tcx: ty::ctxt,
Expand Down Expand Up @@ -471,7 +472,7 @@ impl CFGBuilder {
fn add_contained_edge(&mut self,
source: CFGIndex,
target: CFGIndex) {
let data = CFGEdgeData {exiting_scopes: opt_vec::Empty};
let data = CFGEdgeData {exiting_scopes: Vec::new()};
self.graph.add_edge(source, target, data);
}

Expand All @@ -480,7 +481,7 @@ impl CFGBuilder {
from_index: CFGIndex,
to_loop: LoopScope,
to_index: CFGIndex) {
let mut data = CFGEdgeData {exiting_scopes: opt_vec::Empty};
let mut data = CFGEdgeData {exiting_scopes: Vec::new()};
let mut scope_id = from_expr.id;
while scope_id != to_loop.loop_id {
data.exiting_scopes.push(scope_id);
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/middle/cfg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use middle::ty;
use middle::typeck;
use collections::HashMap;
use syntax::ast;
use syntax::opt_vec::OptVec;

use std::vec_ng::Vec;

mod construct;

Expand All @@ -36,7 +37,7 @@ pub struct CFGNodeData {
}

pub struct CFGEdgeData {
exiting_scopes: OptVec<ast::NodeId>
exiting_scopes: Vec<ast::NodeId>
}

pub type CFGIndex = graph::NodeIndex;
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/middle/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use util::ppaux::UserString;
use syntax::ast::*;
use syntax::attr;
use syntax::codemap::Span;
use syntax::opt_vec;
use syntax::print::pprust::expr_to_str;
use syntax::{visit,ast_util};
use syntax::visit::Visitor;
Expand Down Expand Up @@ -50,6 +49,8 @@ use syntax::visit::Visitor;
// primitives in the stdlib are explicitly annotated to only take sendable
// types.

use std::vec_ng::Vec;

#[deriving(Clone)]
pub struct Context {
tcx: ty::ctxt,
Expand Down Expand Up @@ -92,7 +93,7 @@ fn check_struct_safe_for_destructor(cx: &mut Context,
let struct_tpt = ty::lookup_item_type(cx.tcx, struct_did);
if !struct_tpt.generics.has_type_params() {
let struct_ty = ty::mk_struct(cx.tcx, struct_did, ty::substs {
regions: ty::NonerasedRegions(opt_vec::Empty),
regions: ty::NonerasedRegions(Vec::new()),
self_ty: None,
tps: ~[]
});
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//! which are available for use externally when compiled as a library.

use std::mem::replace;
use std::vec_ng::Vec;
use collections::{HashSet, HashMap};

use metadata::csearch;
Expand All @@ -28,7 +29,6 @@ use syntax::ast_util::{is_local, def_id_of_def, local_def};
use syntax::attr;
use syntax::codemap::Span;
use syntax::parse::token;
use syntax::opt_vec;
use syntax::visit;
use syntax::visit::Visitor;

Expand Down Expand Up @@ -855,8 +855,8 @@ impl<'a> Visitor<()> for PrivacyVisitor<'a> {
debug!("privacy - list {}", pid.node.id);
let seg = ast::PathSegment {
identifier: pid.node.name,
lifetimes: opt_vec::Empty,
types: opt_vec::Empty,
lifetimes: Vec::new(),
types: Vec::new(),
};
let segs = vec!(seg);
let path = ast::Path {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ use syntax::parse::token::special_idents;
use syntax::parse::token;
use syntax::print::pprust::path_to_str;
use syntax::codemap::{Span, DUMMY_SP, Pos};
use syntax::opt_vec::OptVec;
use syntax::visit;
use syntax::visit::Visitor;

use std::cell::{Cell, RefCell};
use std::uint;
use std::vec_ng::Vec;
use std::mem::replace;
use collections::{HashMap, HashSet};

Expand Down Expand Up @@ -3966,7 +3966,7 @@ impl Resolver {
}

fn resolve_type_parameters(&mut self,
type_parameters: &OptVec<TyParam>) {
type_parameters: &Vec<TyParam>) {
for type_parameter in type_parameters.iter() {
for bound in type_parameter.bounds.iter() {
self.resolve_type_parameter_bound(type_parameter.id, bound);
Expand Down
11 changes: 6 additions & 5 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@

use driver::session;
use std::cell::RefCell;
use std::vec_ng::Vec;

use collections::HashMap;
use syntax::ast;
use syntax::codemap::Span;
use syntax::opt_vec::OptVec;
use syntax::parse::token::special_idents;
use syntax::parse::token;
use syntax::print::pprust::{lifetime_to_str};
Expand All @@ -39,8 +40,8 @@ struct LifetimeContext {
}

enum ScopeChain<'a> {
ItemScope(&'a OptVec<ast::Lifetime>),
FnScope(ast::NodeId, &'a OptVec<ast::Lifetime>, &'a ScopeChain<'a>),
ItemScope(&'a Vec<ast::Lifetime>),
FnScope(ast::NodeId, &'a Vec<ast::Lifetime>, &'a ScopeChain<'a>),
BlockScope(ast::NodeId, &'a ScopeChain<'a>),
RootScope
}
Expand Down Expand Up @@ -265,7 +266,7 @@ impl LifetimeContext {
token::get_name(lifetime_ref.ident)));
}

fn check_lifetime_names(&self, lifetimes: &OptVec<ast::Lifetime>) {
fn check_lifetime_names(&self, lifetimes: &Vec<ast::Lifetime>) {
for i in range(0, lifetimes.len()) {
let lifetime_i = lifetimes.get(i);

Expand Down Expand Up @@ -311,7 +312,7 @@ impl LifetimeContext {
}
}

fn search_lifetimes(lifetimes: &OptVec<ast::Lifetime>,
fn search_lifetimes(lifetimes: &Vec<ast::Lifetime>,
lifetime_ref: &ast::Lifetime)
-> Option<(uint, ast::NodeId)> {
for (i, lifetime_decl) in lifetimes.iter().enumerate() {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/subst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use middle::ty_fold::TypeFolder;
use util::ppaux::Repr;

use std::rc::Rc;
use std::vec_ng::Vec;
use syntax::codemap::Span;
use syntax::opt_vec::OptVec;

///////////////////////////////////////////////////////////////////////////
// Public trait `Subst`
Expand Down Expand Up @@ -145,10 +145,10 @@ impl<T:Subst> Subst for Rc<T> {
}
}

impl<T:Subst> Subst for OptVec<T> {
impl<T:Subst> Subst for Vec<T> {
fn subst_spanned(&self, tcx: ty::ctxt,
substs: &ty::substs,
span: Option<Span>) -> OptVec<T> {
span: Option<Span>) -> Vec<T> {
self.map(|t| t.subst_spanned(tcx, substs, span))
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/librustc/middle/trans/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ use middle::trans::glue;
use middle::trans::type_::Type;
use middle::ty;
use syntax::ast;
use syntax::opt_vec;
use syntax::opt_vec::OptVec;
use util::ppaux::Repr;

use std::vec_ng::Vec;

pub struct CleanupScope<'a> {
// The id of this cleanup scope. If the id is None,
// this is a *temporary scope* that is pushed during trans to
Expand All @@ -37,9 +37,9 @@ pub struct CleanupScope<'a> {
kind: CleanupScopeKind<'a>,

// Cleanups to run upon scope exit.
cleanups: OptVec<~Cleanup>,
cleanups: Vec<~Cleanup>,

cached_early_exits: OptVec<CachedEarlyExit>,
cached_early_exits: Vec<CachedEarlyExit>,
cached_landing_pad: Option<BasicBlockRef>,
}

Expand Down Expand Up @@ -379,7 +379,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> {
assert!(orig_scopes_len > 0);

// Remove any scopes that do not have cleanups on failure:
let mut popped_scopes = opt_vec::Empty;
let mut popped_scopes = Vec::new();
while !self.top_scope(|s| s.needs_invoke()) {
debug!("top scope does not need invoke");
popped_scopes.push(self.pop_scope());
Expand Down Expand Up @@ -510,7 +510,7 @@ impl<'a> CleanupHelperMethods<'a> for FunctionContext<'a> {

let orig_scopes_len = self.scopes_len();
let mut prev_llbb;
let mut popped_scopes = opt_vec::Empty;
let mut popped_scopes = Vec::new();

// First we pop off all the cleanup stacks that are
// traversed until the exit is reached, pushing them
Expand Down Expand Up @@ -706,14 +706,14 @@ impl<'a> CleanupScope<'a> {
fn new(kind: CleanupScopeKind<'a>) -> CleanupScope<'a> {
CleanupScope {
kind: kind,
cleanups: opt_vec::Empty,
cached_early_exits: opt_vec::Empty,
cleanups: Vec::new(),
cached_early_exits: Vec::new(),
cached_landing_pad: None,
}
}

fn clear_cached_exits(&mut self) {
self.cached_early_exits = opt_vec::Empty;
self.cached_early_exits = Vec::new();
self.cached_landing_pad = None;
}

Expand Down
5 changes: 3 additions & 2 deletions src/librustc/middle/trans/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ use std::libc::{c_uint, c_ulonglong, c_longlong};
use std::ptr;
use std::sync::atomics;
use std::vec;
use std::vec_ng::Vec;
use syntax::codemap::{Span, Pos};
use syntax::{abi, ast, codemap, ast_util, ast_map, opt_vec};
use syntax::{abi, ast, codemap, ast_util, ast_map};
use syntax::parse::token;
use syntax::parse::token::special_idents;

Expand Down Expand Up @@ -538,7 +539,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
return FunctionWithoutDebugInfo;
}

let empty_generics = ast::Generics { lifetimes: opt_vec::Empty, ty_params: opt_vec::Empty };
let empty_generics = ast::Generics { lifetimes: Vec::new(), ty_params: Vec::new() };

let fnitem = cx.tcx.map.get(fn_ast_id);

Expand Down
Loading