Skip to content

File tree

22 files changed

+134
-177
lines changed

22 files changed

+134
-177
lines changed
 

‎src/Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,7 @@ dependencies = [
21772177
"rustc_typeck 0.0.0",
21782178
"scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
21792179
"serialize 0.0.0",
2180+
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
21802181
"syntax 0.0.0",
21812182
"syntax_ext 0.0.0",
21822183
"syntax_pos 0.0.0",

‎src/librustc/hir/lowering.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ use lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
5252
use middle::cstore::CrateStore;
5353
use rustc_data_structures::fx::FxHashSet;
5454
use rustc_data_structures::indexed_vec::IndexVec;
55-
use rustc_data_structures::small_vec::OneVector;
5655
use rustc_data_structures::thin_vec::ThinVec;
5756
use session::Session;
5857
use util::common::FN_OUTPUT_NAME;
@@ -62,6 +61,7 @@ use std::collections::BTreeMap;
6261
use std::fmt::Debug;
6362
use std::iter;
6463
use std::mem;
64+
use smallvec::SmallVec;
6565
use syntax::attr;
6666
use syntax::ast;
6767
use syntax::ast::*;
@@ -307,7 +307,7 @@ enum AnonymousLifetimeMode {
307307
PassThrough,
308308
}
309309

310-
struct ImplTraitTypeIdVisitor<'a> { ids: &'a mut OneVector<hir::ItemId> }
310+
struct ImplTraitTypeIdVisitor<'a> { ids: &'a mut SmallVec<[hir::ItemId; 1]> }
311311

312312
impl<'a, 'b> Visitor<'a> for ImplTraitTypeIdVisitor<'b> {
313313
fn visit_ty(&mut self, ty: &'a Ty) {
@@ -1901,9 +1901,9 @@ impl<'a> LoweringContext<'a> {
19011901
)
19021902
}
19031903

1904-
fn lower_local(&mut self, l: &Local) -> (P<hir::Local>, OneVector<hir::ItemId>) {
1904+
fn lower_local(&mut self, l: &Local) -> (P<hir::Local>, SmallVec<[hir::ItemId; 1]>) {
19051905
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(l.id);
1906-
let mut ids = OneVector::<hir::ItemId>::new();
1906+
let mut ids = SmallVec::<[hir::ItemId; 1]>::new();
19071907
if self.sess.features_untracked().impl_trait_in_bindings {
19081908
if let Some(ref ty) = l.ty {
19091909
let mut visitor = ImplTraitTypeIdVisitor { ids: &mut ids };
@@ -3211,7 +3211,7 @@ impl<'a> LoweringContext<'a> {
32113211
&mut self,
32123212
decl: &FnDecl,
32133213
header: &FnHeader,
3214-
ids: &mut OneVector<hir::ItemId>,
3214+
ids: &mut SmallVec<[hir::ItemId; 1]>,
32153215
) {
32163216
if let Some(id) = header.asyncness.opt_return_id() {
32173217
ids.push(hir::ItemId { id });
@@ -3223,14 +3223,14 @@ impl<'a> LoweringContext<'a> {
32233223
}
32243224
}
32253225

3226-
fn lower_item_id(&mut self, i: &Item) -> OneVector<hir::ItemId> {
3226+
fn lower_item_id(&mut self, i: &Item) -> SmallVec<[hir::ItemId; 1]> {
32273227
match i.node {
32283228
ItemKind::Use(ref use_tree) => {
32293229
let mut vec = smallvec![hir::ItemId { id: i.id }];
32303230
self.lower_item_id_use_tree(use_tree, i.id, &mut vec);
32313231
vec
32323232
}
3233-
ItemKind::MacroDef(..) => OneVector::new(),
3233+
ItemKind::MacroDef(..) => SmallVec::new(),
32343234
ItemKind::Fn(ref decl, ref header, ..) => {
32353235
let mut ids = smallvec![hir::ItemId { id: i.id }];
32363236
self.lower_fn_impl_trait_ids(decl, header, &mut ids);
@@ -3268,7 +3268,7 @@ impl<'a> LoweringContext<'a> {
32683268
fn lower_item_id_use_tree(&mut self,
32693269
tree: &UseTree,
32703270
base_id: NodeId,
3271-
vec: &mut OneVector<hir::ItemId>)
3271+
vec: &mut SmallVec<[hir::ItemId; 1]>)
32723272
{
32733273
match tree.kind {
32743274
UseTreeKind::Nested(ref nested_vec) => for &(ref nested, id) in nested_vec {
@@ -4369,11 +4369,11 @@ impl<'a> LoweringContext<'a> {
43694369
}
43704370
}
43714371

4372-
fn lower_stmt(&mut self, s: &Stmt) -> OneVector<hir::Stmt> {
4372+
fn lower_stmt(&mut self, s: &Stmt) -> SmallVec<[hir::Stmt; 1]> {
43734373
smallvec![match s.node {
43744374
StmtKind::Local(ref l) => {
43754375
let (l, item_ids) = self.lower_local(l);
4376-
let mut ids: OneVector<hir::Stmt> = item_ids
4376+
let mut ids: SmallVec<[hir::Stmt; 1]> = item_ids
43774377
.into_iter()
43784378
.map(|item_id| Spanned {
43794379
node: hir::StmtKind::Decl(

‎src/librustc_allocator/expand.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
use rustc::middle::allocator::AllocatorKind;
12-
use rustc_data_structures::small_vec::OneVector;
1312
use rustc_errors;
13+
use smallvec::SmallVec;
1414
use syntax::{
1515
ast::{
1616
self, Arg, Attribute, Crate, Expr, FnHeader, Generics, Ident, Item, ItemKind,
@@ -65,7 +65,7 @@ struct ExpandAllocatorDirectives<'a> {
6565
}
6666

6767
impl<'a> Folder for ExpandAllocatorDirectives<'a> {
68-
fn fold_item(&mut self, item: P<Item>) -> OneVector<P<Item>> {
68+
fn fold_item(&mut self, item: P<Item>) -> SmallVec<[P<Item>; 1]> {
6969
debug!("in submodule {}", self.in_submod);
7070

7171
let name = if attr::contains_name(&item.attrs, "global_allocator") {
@@ -152,11 +152,7 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> {
152152
let module = f.cx.monotonic_expander().fold_item(module).pop().unwrap();
153153

154154
// Return the item and new submodule
155-
let mut ret = OneVector::with_capacity(2);
156-
ret.push(item);
157-
ret.push(module);
158-
159-
return ret;
155+
smallvec![item, module]
160156
}
161157

162158
// If we enter a submodule, take note.

‎src/librustc_data_structures/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ extern crate rustc_rayon as rayon;
5050
extern crate rustc_rayon_core as rayon_core;
5151
extern crate rustc_hash;
5252
extern crate serialize;
53-
#[cfg_attr(test, macro_use)]
5453
extern crate smallvec;
5554

5655
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
@@ -72,7 +71,6 @@ pub mod owning_ref;
7271
pub mod ptr_key;
7372
pub mod sip128;
7473
pub mod small_c_str;
75-
pub mod small_vec;
7674
pub mod snapshot_map;
7775
pub use ena::snapshot_vec;
7876
pub mod sorted_map;

‎src/librustc_data_structures/small_vec.rs

-55
This file was deleted.

‎src/librustc_driver/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ rustc_codegen_utils = { path = "../librustc_codegen_utils" }
3535
rustc_typeck = { path = "../librustc_typeck" }
3636
serialize = { path = "../libserialize" }
3737
syntax = { path = "../libsyntax" }
38+
smallvec = { version = "0.6.5", features = ["union"] }
3839
syntax_ext = { path = "../libsyntax_ext" }
3940
syntax_pos = { path = "../libsyntax_pos" }

‎src/librustc_driver/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ extern crate rustc_codegen_utils;
5858
extern crate rustc_typeck;
5959
extern crate scoped_tls;
6060
extern crate serialize;
61+
extern crate smallvec;
6162
#[macro_use]
6263
extern crate log;
6364
extern crate syntax;

‎src/librustc_driver/pretty.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use rustc::session::Session;
2424
use rustc::session::config::{Input, OutputFilenames};
2525
use rustc_borrowck as borrowck;
2626
use rustc_borrowck::graphviz as borrowck_dot;
27-
use rustc_data_structures::small_vec::OneVector;
2827
use rustc_data_structures::thin_vec::ThinVec;
2928
use rustc_metadata::cstore::CStore;
3029

@@ -38,6 +37,7 @@ use syntax::ptr::P;
3837
use syntax_pos::{self, FileName};
3938

4039
use graphviz as dot;
40+
use smallvec::SmallVec;
4141

4242
use std::cell::Cell;
4343
use std::fs::File;
@@ -727,7 +727,7 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
727727
self.run(is_const, |s| fold::noop_fold_item_kind(i, s))
728728
}
729729

730-
fn fold_trait_item(&mut self, i: ast::TraitItem) -> OneVector<ast::TraitItem> {
730+
fn fold_trait_item(&mut self, i: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> {
731731
let is_const = match i.node {
732732
ast::TraitItemKind::Const(..) => true,
733733
ast::TraitItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
@@ -737,7 +737,7 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
737737
self.run(is_const, |s| fold::noop_fold_trait_item(i, s))
738738
}
739739

740-
fn fold_impl_item(&mut self, i: ast::ImplItem) -> OneVector<ast::ImplItem> {
740+
fn fold_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> {
741741
let is_const = match i.node {
742742
ast::ImplItemKind::Const(..) => true,
743743
ast::ImplItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>

‎src/librustc_resolve/macros.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use errors::Applicability;
4242
use std::cell::Cell;
4343
use std::mem;
4444
use rustc_data_structures::sync::Lrc;
45-
use rustc_data_structures::small_vec::ExpectOne;
4645

4746
#[derive(Clone, Copy)]
4847
crate struct FromPrelude(bool);
@@ -190,7 +189,9 @@ impl<'a, 'crateloader: 'a> base::Resolver for Resolver<'a, 'crateloader> {
190189
}
191190
}
192191

193-
EliminateCrateVar(self, item.span).fold_item(item).expect_one("")
192+
let ret = EliminateCrateVar(self, item.span).fold_item(item);
193+
assert!(ret.len() == 1);
194+
ret.into_iter().next().unwrap()
194195
}
195196

196197
fn is_whitelisted_legacy_custom_derive(&self, name: Name) -> bool {

‎src/libsyntax/config.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use ast;
1515
use source_map::Spanned;
1616
use edition::Edition;
1717
use parse::{token, ParseSess};
18-
use OneVector;
18+
use smallvec::SmallVec;
1919
use errors::Applicability;
2020

2121
use ptr::P;
@@ -338,22 +338,23 @@ impl<'a> fold::Folder for StripUnconfigured<'a> {
338338
Some(P(fold::noop_fold_expr(expr, self)))
339339
}
340340

341-
fn fold_stmt(&mut self, stmt: ast::Stmt) -> OneVector<ast::Stmt> {
341+
fn fold_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
342342
match self.configure_stmt(stmt) {
343343
Some(stmt) => fold::noop_fold_stmt(stmt, self),
344-
None => return OneVector::new(),
344+
None => return SmallVec::new(),
345345
}
346346
}
347347

348-
fn fold_item(&mut self, item: P<ast::Item>) -> OneVector<P<ast::Item>> {
348+
fn fold_item(&mut self, item: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> {
349349
fold::noop_fold_item(configure!(self, item), self)
350350
}
351351

352-
fn fold_impl_item(&mut self, item: ast::ImplItem) -> OneVector<ast::ImplItem> {
352+
fn fold_impl_item(&mut self, item: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]>
353+
{
353354
fold::noop_fold_impl_item(configure!(self, item), self)
354355
}
355356

356-
fn fold_trait_item(&mut self, item: ast::TraitItem) -> OneVector<ast::TraitItem> {
357+
fn fold_trait_item(&mut self, item: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> {
357358
fold::noop_fold_trait_item(configure!(self, item), self)
358359
}
359360

‎src/libsyntax/diagnostics/plugin.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use ext::base::{ExtCtxt, MacEager, MacResult};
1919
use ext::build::AstBuilder;
2020
use parse::token;
2121
use ptr::P;
22-
use OneVector;
2322
use symbol::{keywords, Symbol};
2423
use tokenstream::{TokenTree};
2524

@@ -131,15 +130,15 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
131130
let sym = Ident::with_empty_ctxt(Symbol::gensym(&format!(
132131
"__register_diagnostic_{}", code
133132
)));
134-
MacEager::items(OneVector::from_vec(vec![
133+
MacEager::items(smallvec![
135134
ecx.item_mod(
136135
span,
137136
span,
138137
sym,
139138
Vec::new(),
140139
Vec::new()
141140
)
142-
]))
141+
])
143142
}
144143

145144
pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
@@ -214,7 +213,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
214213
),
215214
);
216215

217-
MacEager::items(OneVector::from_vec(vec![
216+
MacEager::items(smallvec![
218217
P(ast::Item {
219218
ident: *name,
220219
attrs: Vec::new(),
@@ -227,5 +226,5 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
227226
span,
228227
tokens: None,
229228
})
230-
]))
229+
])
231230
}

0 commit comments

Comments
 (0)
Please sign in to comment.