Skip to content

Remove OneVector type alias #53824

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 1 commit into from
Sep 26, 2018
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
1 change: 1 addition & 0 deletions src/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,7 @@ dependencies = [
"rustc_typeck 0.0.0",
"scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serialize 0.0.0",
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"syntax 0.0.0",
"syntax_ext 0.0.0",
"syntax_pos 0.0.0",
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ use lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
use middle::cstore::CrateStore;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_data_structures::small_vec::OneVector;
use rustc_data_structures::thin_vec::ThinVec;
use session::Session;
use util::common::FN_OUTPUT_NAME;
Expand All @@ -62,6 +61,7 @@ use std::collections::BTreeMap;
use std::fmt::Debug;
use std::iter;
use std::mem;
use smallvec::SmallVec;
use syntax::attr;
use syntax::ast;
use syntax::ast::*;
Expand Down Expand Up @@ -307,7 +307,7 @@ enum AnonymousLifetimeMode {
PassThrough,
}

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

impl<'a, 'b> Visitor<'a> for ImplTraitTypeIdVisitor<'b> {
fn visit_ty(&mut self, ty: &'a Ty) {
Expand Down Expand Up @@ -1901,9 +1901,9 @@ impl<'a> LoweringContext<'a> {
)
}

fn lower_local(&mut self, l: &Local) -> (P<hir::Local>, OneVector<hir::ItemId>) {
fn lower_local(&mut self, l: &Local) -> (P<hir::Local>, SmallVec<[hir::ItemId; 1]>) {
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(l.id);
let mut ids = OneVector::<hir::ItemId>::new();
let mut ids = SmallVec::<[hir::ItemId; 1]>::new();
if self.sess.features_untracked().impl_trait_in_bindings {
if let Some(ref ty) = l.ty {
let mut visitor = ImplTraitTypeIdVisitor { ids: &mut ids };
Expand Down Expand Up @@ -3211,7 +3211,7 @@ impl<'a> LoweringContext<'a> {
&mut self,
decl: &FnDecl,
header: &FnHeader,
ids: &mut OneVector<hir::ItemId>,
ids: &mut SmallVec<[hir::ItemId; 1]>,
) {
if let Some(id) = header.asyncness.opt_return_id() {
ids.push(hir::ItemId { id });
Expand All @@ -3223,14 +3223,14 @@ impl<'a> LoweringContext<'a> {
}
}

fn lower_item_id(&mut self, i: &Item) -> OneVector<hir::ItemId> {
fn lower_item_id(&mut self, i: &Item) -> SmallVec<[hir::ItemId; 1]> {
match i.node {
ItemKind::Use(ref use_tree) => {
let mut vec = smallvec![hir::ItemId { id: i.id }];
self.lower_item_id_use_tree(use_tree, i.id, &mut vec);
vec
}
ItemKind::MacroDef(..) => OneVector::new(),
ItemKind::MacroDef(..) => SmallVec::new(),
ItemKind::Fn(ref decl, ref header, ..) => {
let mut ids = smallvec![hir::ItemId { id: i.id }];
self.lower_fn_impl_trait_ids(decl, header, &mut ids);
Expand Down Expand Up @@ -3268,7 +3268,7 @@ impl<'a> LoweringContext<'a> {
fn lower_item_id_use_tree(&mut self,
tree: &UseTree,
base_id: NodeId,
vec: &mut OneVector<hir::ItemId>)
vec: &mut SmallVec<[hir::ItemId; 1]>)
{
match tree.kind {
UseTreeKind::Nested(ref nested_vec) => for &(ref nested, id) in nested_vec {
Expand Down Expand Up @@ -4369,11 +4369,11 @@ impl<'a> LoweringContext<'a> {
}
}

fn lower_stmt(&mut self, s: &Stmt) -> OneVector<hir::Stmt> {
fn lower_stmt(&mut self, s: &Stmt) -> SmallVec<[hir::Stmt; 1]> {
smallvec![match s.node {
StmtKind::Local(ref l) => {
let (l, item_ids) = self.lower_local(l);
let mut ids: OneVector<hir::Stmt> = item_ids
let mut ids: SmallVec<[hir::Stmt; 1]> = item_ids
.into_iter()
.map(|item_id| Spanned {
node: hir::StmtKind::Decl(
Expand Down
10 changes: 3 additions & 7 deletions src/librustc_allocator/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// except according to those terms.

use rustc::middle::allocator::AllocatorKind;
use rustc_data_structures::small_vec::OneVector;
use rustc_errors;
use smallvec::SmallVec;
use syntax::{
ast::{
self, Arg, Attribute, Crate, Expr, FnHeader, Generics, Ident, Item, ItemKind,
Expand Down Expand Up @@ -65,7 +65,7 @@ struct ExpandAllocatorDirectives<'a> {
}

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

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

// Return the item and new submodule
let mut ret = OneVector::with_capacity(2);
ret.push(item);
ret.push(module);

return ret;
smallvec![item, module]
}

// If we enter a submodule, take note.
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ extern crate rustc_rayon as rayon;
extern crate rustc_rayon_core as rayon_core;
extern crate rustc_hash;
extern crate serialize;
#[cfg_attr(test, macro_use)]
extern crate smallvec;

// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
Expand All @@ -72,7 +71,6 @@ pub mod owning_ref;
pub mod ptr_key;
pub mod sip128;
pub mod small_c_str;
pub mod small_vec;
pub mod snapshot_map;
pub use ena::snapshot_vec;
pub mod sorted_map;
Expand Down
55 changes: 0 additions & 55 deletions src/librustc_data_structures/small_vec.rs

This file was deleted.

1 change: 1 addition & 0 deletions src/librustc_driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ rustc_codegen_utils = { path = "../librustc_codegen_utils" }
rustc_typeck = { path = "../librustc_typeck" }
serialize = { path = "../libserialize" }
syntax = { path = "../libsyntax" }
smallvec = { version = "0.6.5", features = ["union"] }
syntax_ext = { path = "../libsyntax_ext" }
syntax_pos = { path = "../libsyntax_pos" }
1 change: 1 addition & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ extern crate rustc_codegen_utils;
extern crate rustc_typeck;
extern crate scoped_tls;
extern crate serialize;
extern crate smallvec;
#[macro_use]
extern crate log;
extern crate syntax;
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_driver/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use rustc::session::Session;
use rustc::session::config::{Input, OutputFilenames};
use rustc_borrowck as borrowck;
use rustc_borrowck::graphviz as borrowck_dot;
use rustc_data_structures::small_vec::OneVector;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_metadata::cstore::CStore;

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

use graphviz as dot;
use smallvec::SmallVec;

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

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

fn fold_impl_item(&mut self, i: ast::ImplItem) -> OneVector<ast::ImplItem> {
fn fold_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> {
let is_const = match i.node {
ast::ImplItemKind::Const(..) => true,
ast::ImplItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_resolve/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ use errors::Applicability;
use std::cell::Cell;
use std::mem;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::small_vec::ExpectOne;

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

EliminateCrateVar(self, item.span).fold_item(item).expect_one("")
let ret = EliminateCrateVar(self, item.span).fold_item(item);
assert!(ret.len() == 1);
ret.into_iter().next().unwrap()
}

fn is_whitelisted_legacy_custom_derive(&self, name: Name) -> bool {
Expand Down
13 changes: 7 additions & 6 deletions src/libsyntax/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ast;
use source_map::Spanned;
use edition::Edition;
use parse::{token, ParseSess};
use OneVector;
use smallvec::SmallVec;
use errors::Applicability;

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

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

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

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

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

Expand Down
9 changes: 4 additions & 5 deletions src/libsyntax/diagnostics/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use ext::base::{ExtCtxt, MacEager, MacResult};
use ext::build::AstBuilder;
use parse::token;
use ptr::P;
use OneVector;
use symbol::{keywords, Symbol};
use tokenstream::{TokenTree};

Expand Down Expand Up @@ -131,15 +130,15 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
let sym = Ident::with_empty_ctxt(Symbol::gensym(&format!(
"__register_diagnostic_{}", code
)));
MacEager::items(OneVector::from_vec(vec![
MacEager::items(smallvec![
ecx.item_mod(
span,
span,
sym,
Vec::new(),
Vec::new()
)
]))
])
}

pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
Expand Down Expand Up @@ -214,7 +213,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
),
);

MacEager::items(OneVector::from_vec(vec![
MacEager::items(smallvec![
P(ast::Item {
ident: *name,
attrs: Vec::new(),
Expand All @@ -227,5 +226,5 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
span,
tokens: None,
})
]))
])
}
Loading