From 130a32fa7259d348dc3a684b38e688da398c30bb Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 30 Aug 2018 11:42:16 +0200 Subject: Remove OneVector --- src/librustc_data_structures/lib.rs | 2 -- src/librustc_data_structures/small_vec.rs | 55 ------------------------------- 2 files changed, 57 deletions(-) delete mode 100644 src/librustc_data_structures/small_vec.rs (limited to 'src/librustc_data_structures') diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 70b960ac351..43ab3869806 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -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. @@ -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; diff --git a/src/librustc_data_structures/small_vec.rs b/src/librustc_data_structures/small_vec.rs deleted file mode 100644 index 075b70c6426..00000000000 --- a/src/librustc_data_structures/small_vec.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! A vector type intended to be used for small vectors. -//! -//! Space for up to N elements is provided on the stack. If more elements are collected, Vec is -//! used to store the values on the heap. -//! -//! The N above is determined by Array's implementor, by way of an associated constant. - -use smallvec::{Array, SmallVec}; - -pub type OneVector = SmallVec<[T; 1]>; - -pub trait ExpectOne { - fn expect_one(self, err: &'static str) -> A::Item; -} - -impl ExpectOne for SmallVec { - fn expect_one(self, err: &'static str) -> A::Item { - assert!(self.len() == 1, err); - self.into_iter().next().unwrap() - } -} - -#[cfg(test)] -mod tests { - extern crate test; - use super::*; - - #[test] - #[should_panic] - fn test_expect_one_zero() { - let _: isize = OneVector::new().expect_one(""); - } - - #[test] - #[should_panic] - fn test_expect_one_many() { - OneVector::from_vec(vec![1, 2]).expect_one(""); - } - - #[test] - fn test_expect_one_one() { - assert_eq!(1, (smallvec![1] as OneVector<_>).expect_one("")); - assert_eq!(1, OneVector::from_vec(vec![1]).expect_one("")); - } -} -- cgit 1.4.1-3-g733a5