Skip to content

Replace syntax::opt_vec with syntax::owned_slice #13016

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

Merged
merged 3 commits into from
Mar 22, 2014
Merged
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
6 changes: 3 additions & 3 deletions src/librustc/front/std_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use syntax::codemap::DUMMY_SP;
use syntax::codemap;
use syntax::fold::Folder;
use syntax::fold;
use syntax::opt_vec;
use syntax::owned_slice::OwnedSlice;
use syntax::parse::token::InternedString;
use syntax::parse::token;
use syntax::util::small_vector::SmallVector;
Expand Down Expand Up @@ -164,12 +164,12 @@ impl<'a> fold::Folder for PreludeInjector<'a> {
ast::PathSegment {
identifier: token::str_to_ident("std"),
lifetimes: Vec::new(),
types: opt_vec::Empty,
types: OwnedSlice::empty(),
},
ast::PathSegment {
identifier: token::str_to_ident("prelude"),
lifetimes: Vec::new(),
types: opt_vec::Empty,
types: OwnedSlice::empty(),
}),
};

Expand Down
6 changes: 3 additions & 3 deletions src/librustc/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use syntax::ext::base::ExtCtxt;
use syntax::ext::expand::ExpansionConfig;
use syntax::fold::Folder;
use syntax::fold;
use syntax::opt_vec;
use syntax::owned_slice::OwnedSlice;
use syntax::parse::token::InternedString;
use syntax::parse::token;
use syntax::print::pprust;
Expand Down Expand Up @@ -377,7 +377,7 @@ fn path_node(ids: Vec<ast::Ident> ) -> ast::Path {
segments: ids.move_iter().map(|identifier| ast::PathSegment {
identifier: identifier,
lifetimes: Vec::new(),
types: opt_vec::Empty,
types: OwnedSlice::empty(),
}).collect()
}
}
Expand All @@ -389,7 +389,7 @@ fn path_node_global(ids: Vec<ast::Ident> ) -> ast::Path {
segments: ids.move_iter().map(|identifier| ast::PathSegment {
identifier: identifier,
lifetimes: Vec::new(),
types: opt_vec::Empty,
types: OwnedSlice::empty(),
}).collect()
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use syntax::abi::AbiSet;
use syntax::abi;
use syntax::ast;
use syntax::ast::*;
use syntax::opt_vec;
use syntax::owned_slice::OwnedSlice;
use syntax::parse::token;

// Compact string representation for ty::t values. API ty_str &
Expand Down Expand Up @@ -192,13 +192,13 @@ 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!();
while peek(st) != '.' {
let r = parse_region(st, |x,y| conv(x,y));
regions.push(r);
}
assert_eq!(next(st), '.');
ty::NonerasedRegions(regions)
ty::NonerasedRegions(OwnedSlice::from_vec(regions))
}
_ => fail!("parse_bound_region: bad input")
}
Expand Down
8 changes: 3 additions & 5 deletions src/librustc/middle/borrowck/move_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,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 @@ -316,15 +314,15 @@ impl MoveData {

fn existing_base_paths(&self,
lp: @LoanPath)
-> OptVec<MovePathIndex> {
let mut result = opt_vec::Empty;
-> Vec<MovePathIndex> {
let mut result = vec!();
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
6 changes: 3 additions & 3 deletions src/librustc/middle/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use middle::typeck;
use middle::ty;
use syntax::ast;
use syntax::ast_util;
use syntax::opt_vec;
use util::nodemap::NodeMap;

struct CFGBuilder<'a> {
Expand Down Expand Up @@ -470,7 +469,7 @@ impl<'a> CFGBuilder<'a> {
fn add_contained_edge(&mut self,
source: CFGIndex,
target: CFGIndex) {
let data = CFGEdgeData {exiting_scopes: opt_vec::Empty};
let data = CFGEdgeData {exiting_scopes: vec!() };
self.graph.add_edge(source, target, data);
}

Expand All @@ -479,9 +478,10 @@ impl<'a> CFGBuilder<'a> {
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!() };
let mut scope_id = from_expr.id;
while scope_id != to_loop.loop_id {

data.exiting_scopes.push(scope_id);
scope_id = self.tcx.region_maps.encl_scope(scope_id);
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/cfg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use middle::graph;
use middle::ty;
use middle::typeck;
use syntax::ast;
use syntax::opt_vec::OptVec;
use util::nodemap::NodeMap;

mod construct;
Expand All @@ -36,7 +35,7 @@ pub struct CFGNodeData {
}

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

pub type CFGIndex = graph::NodeIndex;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use util::ppaux::UserString;
use syntax::ast::*;
use syntax::attr;
use syntax::codemap::Span;
use syntax::opt_vec;
use syntax::owned_slice::OwnedSlice;
use syntax::print::pprust::expr_to_str;
use syntax::{visit,ast_util};
use syntax::visit::Visitor;
Expand Down Expand Up @@ -92,7 +92,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(OwnedSlice::empty()),
self_ty: None,
tps: Vec::new()
});
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ 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::owned_slice::OwnedSlice;
use syntax::visit;
use syntax::visit::Visitor;

Expand Down Expand Up @@ -842,7 +842,7 @@ impl<'a> Visitor<()> for PrivacyVisitor<'a> {
let seg = ast::PathSegment {
identifier: pid.node.name,
lifetimes: Vec::new(),
types: opt_vec::Empty,
types: OwnedSlice::empty(),
};
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 @@ -27,7 +27,7 @@ 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::owned_slice::OwnedSlice;
use syntax::visit;
use syntax::visit::Visitor;

Expand Down Expand Up @@ -3969,7 +3969,7 @@ impl<'a> Resolver<'a> {
}

fn resolve_type_parameters(&mut self,
type_parameters: &OptVec<TyParam>) {
type_parameters: &OwnedSlice<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
9 changes: 4 additions & 5 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ use driver::session::Session;
use util::nodemap::NodeMap;
use syntax::ast;
use syntax::codemap::Span;
use syntax::opt_vec;
use syntax::opt_vec::OptVec;
use syntax::owned_slice::OwnedSlice;
use syntax::parse::token::special_idents;
use syntax::parse::token;
use syntax::print::pprust::{lifetime_to_str};
Expand Down Expand Up @@ -413,22 +412,22 @@ pub fn early_bound_lifetimes<'a>(generics: &'a ast::Generics) -> Vec<ast::Lifeti
.collect()
}

pub fn free_lifetimes(ty_params: &OptVec<ast::TyParam>) -> OptVec<ast::Name> {
pub fn free_lifetimes(ty_params: &OwnedSlice<ast::TyParam>) -> Vec<ast::Name> {
/*!
* Gathers up and returns the names of any lifetimes that appear
* free in `ty_params`. Of course, right now, all lifetimes appear
* free, since we don't currently have any binders in type parameter
* declarations; just being forwards compatible with future extensions.
*/

let mut collector = FreeLifetimeCollector { names: opt_vec::Empty };
let mut collector = FreeLifetimeCollector { names: vec!() };
for ty_param in ty_params.iter() {
visit::walk_ty_param_bounds(&mut collector, &ty_param.bounds, ());
}
return collector.names;

struct FreeLifetimeCollector {
names: OptVec<ast::Name>,
names: Vec<ast::Name>,
}

impl Visitor<()> for FreeLifetimeCollector {
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 @@ -17,7 +17,7 @@ use util::ppaux::Repr;

use std::rc::Rc;
use syntax::codemap::Span;
use syntax::opt_vec::OptVec;
use syntax::owned_slice::OwnedSlice;

///////////////////////////////////////////////////////////////////////////
// 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 OwnedSlice<T> {
fn subst_spanned(&self, tcx: &ty::ctxt,
substs: &ty::substs,
span: Option<Span>) -> OptVec<T> {
span: Option<Span>) -> OwnedSlice<T> {
self.map(|t| t.subst_spanned(tcx, substs, span))
}
}
Expand Down
16 changes: 7 additions & 9 deletions src/librustc/middle/trans/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ 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;

pub struct CleanupScope<'a> {
Expand All @@ -37,9 +35,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 +377,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!();
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 +508,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!();

// First we pop off all the cleanup stacks that are
// traversed until the exit is reached, pushing them
Expand Down Expand Up @@ -708,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!(),
cached_early_exits: vec!(),
cached_landing_pad: None,
}
}

fn clear_cached_exits(&mut self) {
self.cached_early_exits = opt_vec::Empty;
self.cached_early_exits = vec!();
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 @@ -150,7 +150,8 @@ use std::ptr;
use std::sync::atomics;
use std::slice;
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::owned_slice::OwnedSlice;
use syntax::parse::token;
use syntax::parse::token::special_idents;

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

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

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

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use util::ppaux::Repr;
use middle::trans::type_::Type;

use syntax::ast;
use syntax::opt_vec;
use syntax::owned_slice::OwnedSlice;

pub fn arg_is_indirect(ccx: &CrateContext, arg_ty: ty::t) -> bool {
!type_is_immediate(ccx, arg_ty)
Expand Down Expand Up @@ -324,7 +324,7 @@ pub fn llvm_type_name(cx: &CrateContext,
an_enum => { "enum" }
};
let tstr = ppaux::parameterized(cx.tcx(), ty::item_path_str(cx.tcx(), did),
&ty::NonerasedRegions(opt_vec::Empty),
&ty::NonerasedRegions(OwnedSlice::empty()),
tps, did, false);
if did.krate == 0 {
format!("{}.{}", name, tstr)
Expand Down
Loading