diff --git a/src/Cargo.lock b/src/Cargo.lock index 9d5f3bbd9e3673408e49bf30f528976c7e2290a6..37a6f9130f595726369088a0d3f4b21f73266541 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -2354,6 +2354,7 @@ dependencies = [ "rustc_errors 0.0.0", "rustc_platform_intrinsics 0.0.0", "rustc_target 0.0.0", + "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "syntax 0.0.0", "syntax_pos 0.0.0", ] diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index f03ad98c7dee4e9bb454fda317521e819a9448d4..371f631737c9871001536c5f4e964f2f0a012736 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -34,8 +34,8 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult, ToStableHashKey}; -use rustc_data_structures::accumulate_vec::AccumulateVec; use rustc_data_structures::fx::{FxHashSet, FxHashMap}; +use smallvec::SmallVec; fn compute_ignored_attr_names() -> FxHashSet { debug_assert!(ich::IGNORED_ATTRIBUTES.len() > 0); @@ -405,7 +405,7 @@ pub fn hash_stable_trait_impls<'a, 'gcx, W, R>( R: std_hash::BuildHasher, { { - let mut blanket_impls: AccumulateVec<[_; 8]> = blanket_impls + let mut blanket_impls: SmallVec<[_; 8]> = blanket_impls .iter() .map(|&def_id| hcx.def_path_hash(def_id)) .collect(); @@ -418,7 +418,7 @@ pub fn hash_stable_trait_impls<'a, 'gcx, W, R>( } { - let mut keys: AccumulateVec<[_; 8]> = + let mut keys: SmallVec<[_; 8]> = non_blanket_impls.keys() .map(|k| (k, k.map_def(|d| hcx.def_path_hash(d)))) .collect(); @@ -426,7 +426,7 @@ pub fn hash_stable_trait_impls<'a, 'gcx, W, R>( keys.len().hash_stable(hcx, hasher); for (key, ref stable_key) in keys { stable_key.hash_stable(hcx, hasher); - let mut impls : AccumulateVec<[_; 8]> = non_blanket_impls[key] + let mut impls : SmallVec<[_; 8]> = non_blanket_impls[key] .iter() .map(|&impl_id| hcx.def_path_hash(impl_id)) .collect(); diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 4811f84635c7f9f20c0e59e5b0dddaa87232ffcc..ac5fdb2fe27971f980261a54b5d3cc11b8205379 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -25,9 +25,9 @@ use hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX}; +use smallvec::SmallVec; use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher, StableHasherResult}; -use rustc_data_structures::accumulate_vec::AccumulateVec; impl<'a> HashStable> for InternedString { #[inline] @@ -207,7 +207,7 @@ fn hash_stable(&self, } // Some attributes are always ignored during hashing. - let filtered: AccumulateVec<[&ast::Attribute; 8]> = self + let filtered: SmallVec<[&ast::Attribute; 8]> = self .iter() .filter(|attr| { !attr.is_sugared_doc && !hcx.is_ignored_attr(attr.name()) diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs index 87535a6ae8d1466d53f908d4b6e08f7ed26ee596..10e930d1c92d9a58b3f08632f86b97a27db9aa06 100644 --- a/src/librustc/traits/structural_impls.rs +++ b/src/librustc/traits/structural_impls.rs @@ -9,7 +9,7 @@ // except according to those terms. use chalk_engine; -use rustc_data_structures::accumulate_vec::AccumulateVec; +use smallvec::SmallVec; use traits; use traits::project::Normalized; use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; @@ -624,7 +624,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = self.iter() .map(|t| t.fold_with(folder)) - .collect::>(); + .collect::>(); folder.tcx().intern_goals(&v) } @@ -662,7 +662,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = self.iter() .map(|t| t.fold_with(folder)) - .collect::>(); + .collect::>(); folder.tcx().intern_clauses(&v) } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index b10e9f14158696be4707abefdd536e17c18aa1f6..de50598c42c9da5774b02538806ab483193cfe27 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -52,7 +52,7 @@ use ty::CanonicalTy; use util::nodemap::{DefIdSet, ItemLocalMap}; use util::nodemap::{FxHashMap, FxHashSet}; -use rustc_data_structures::accumulate_vec::AccumulateVec; +use smallvec::SmallVec; use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap, StableHasher, StableHasherResult, StableVec}; @@ -2840,7 +2840,7 @@ pub trait InternIteratorElement: Sized { impl InternIteratorElement for T { type Output = R; fn intern_with, F: FnOnce(&[T]) -> R>(iter: I, f: F) -> Self::Output { - f(&iter.collect::>()) + f(&iter.collect::>()) } } @@ -2849,14 +2849,14 @@ impl<'a, T, R> InternIteratorElement for &'a T { type Output = R; fn intern_with, F: FnOnce(&[T]) -> R>(iter: I, f: F) -> Self::Output { - f(&iter.cloned().collect::>()) + f(&iter.cloned().collect::>()) } } impl InternIteratorElement for Result { type Output = Result; fn intern_with, F: FnOnce(&[T]) -> R>(iter: I, f: F) -> Self::Output { - Ok(f(&iter.collect::, _>>()?)) + Ok(f(&iter.collect::, _>>()?)) } } diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index 1f3c31405043502312ac5182a313b6b0220e682a..e3ef74f44db7f6ecb1efc03d44c505fa34fdb1e0 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -16,8 +16,8 @@ use mir::interpret::{ConstValue, ConstEvalErr}; use ty::{self, Lift, Ty, TyCtxt}; use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; -use rustc_data_structures::accumulate_vec::AccumulateVec; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; +use smallvec::SmallVec; use mir::interpret; use std::rc::Rc; @@ -741,7 +741,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ParamEnv<'tcx> { reveal, caller_bounds } impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - let v = self.iter().map(|p| p.fold_with(folder)).collect::>(); + let v = self.iter().map(|p| p.fold_with(folder)).collect::>(); folder.tcx().intern_existential_predicates(&v) } @@ -760,7 +760,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ExistentialPredicate<'tcx> { impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - let v = self.iter().map(|t| t.fold_with(folder)).collect::>(); + let v = self.iter().map(|t| t.fold_with(folder)).collect::>(); folder.tcx().intern_type_list(&v) } @@ -1016,7 +1016,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::GenericPredicates<'tcx> { impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - let v = self.iter().map(|p| p.fold_with(folder)).collect::>(); + let v = self.iter().map(|p| p.fold_with(folder)).collect::>(); folder.tcx().intern_predicates(&v) } diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index 6dadc5070368b3c4eb77d64c20243b6318b1771e..b6ffcd55d9150c1ed824b5ccbc1c47f20707b8ee 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -17,9 +17,8 @@ use serialize::{self, Encodable, Encoder, Decodable, Decoder}; use syntax_pos::{Span, DUMMY_SP}; -use rustc_data_structures::accumulate_vec::AccumulateVec; -use rustc_data_structures::array_vec::ArrayVec; use rustc_data_structures::indexed_vec::Idx; +use smallvec::SmallVec; use core::intrinsics; use std::cmp::Ordering; @@ -203,11 +202,7 @@ pub fn for_item(tcx: TyCtxt<'a, 'gcx, 'tcx>, { let defs = tcx.generics_of(def_id); let count = defs.count(); - let mut substs = if count <= 8 { - AccumulateVec::Array(ArrayVec::new()) - } else { - AccumulateVec::Heap(Vec::with_capacity(count)) - }; + let mut substs = SmallVec::with_capacity(count); Substs::fill_item(&mut substs, tcx, defs, &mut mk_kind); tcx.intern_substs(&substs) } @@ -227,7 +222,7 @@ pub fn extend_to(&self, }) } - fn fill_item(substs: &mut AccumulateVec<[Kind<'tcx>; 8]>, + fn fill_item(substs: &mut SmallVec<[Kind<'tcx>; 8]>, tcx: TyCtxt<'a, 'gcx, 'tcx>, defs: &ty::Generics, mk_kind: &mut F) @@ -240,7 +235,7 @@ pub fn extend_to(&self, Substs::fill_single(substs, defs, mk_kind) } - fn fill_single(substs: &mut AccumulateVec<[Kind<'tcx>; 8]>, + fn fill_single(substs: &mut SmallVec<[Kind<'tcx>; 8]>, defs: &ty::Generics, mk_kind: &mut F) where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx> @@ -248,10 +243,7 @@ pub fn extend_to(&self, for param in &defs.params { let kind = mk_kind(param, substs); assert_eq!(param.index as usize, substs.len()); - match *substs { - AccumulateVec::Array(ref mut arr) => arr.push(kind), - AccumulateVec::Heap(ref mut vec) => vec.push(kind), - } + substs.push(kind); } } @@ -325,7 +317,7 @@ pub fn truncate_to(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, generics: &ty::Generics) impl<'tcx> TypeFoldable<'tcx> for &'tcx Substs<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - let params: AccumulateVec<[_; 8]> = self.iter().map(|k| k.fold_with(folder)).collect(); + let params: SmallVec<[_; 8]> = self.iter().map(|k| k.fold_with(folder)).collect(); // If folding doesn't change the substs, it's faster to avoid // calling `mk_substs` and instead reuse the existing substs. diff --git a/src/librustc_data_structures/accumulate_vec.rs b/src/librustc_data_structures/accumulate_vec.rs deleted file mode 100644 index 9423e6b3256c5d229aa7f0fc21834293529d1968..0000000000000000000000000000000000000000 --- a/src/librustc_data_structures/accumulate_vec.rs +++ /dev/null @@ -1,242 +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 collecting from iterators onto the stack. -//! -//! 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 std::ops::{Deref, DerefMut, RangeBounds}; -use std::iter::{self, IntoIterator, FromIterator}; -use std::slice; -use std::vec; - -use rustc_serialize::{Encodable, Encoder, Decodable, Decoder}; - -use array_vec::{self, Array, ArrayVec}; - -#[derive(Hash, Debug)] -pub enum AccumulateVec { - Array(ArrayVec), - Heap(Vec) -} - -impl Clone for AccumulateVec - where A: Array, - A::Element: Clone { - fn clone(&self) -> Self { - match *self { - AccumulateVec::Array(ref arr) => AccumulateVec::Array(arr.clone()), - AccumulateVec::Heap(ref vec) => AccumulateVec::Heap(vec.clone()), - } - } -} - -impl AccumulateVec { - pub fn new() -> AccumulateVec { - AccumulateVec::Array(ArrayVec::new()) - } - - pub fn is_array(&self) -> bool { - match self { - AccumulateVec::Array(..) => true, - AccumulateVec::Heap(..) => false, - } - } - - pub fn one(el: A::Element) -> Self { - iter::once(el).collect() - } - - pub fn many>(iter: I) -> Self { - iter.into_iter().collect() - } - - pub fn len(&self) -> usize { - match *self { - AccumulateVec::Array(ref arr) => arr.len(), - AccumulateVec::Heap(ref vec) => vec.len(), - } - } - - pub fn is_empty(&self) -> bool { - self.len() == 0 - } - - pub fn pop(&mut self) -> Option { - match *self { - AccumulateVec::Array(ref mut arr) => arr.pop(), - AccumulateVec::Heap(ref mut vec) => vec.pop(), - } - } - - pub fn drain(&mut self, range: R) -> Drain - where R: RangeBounds - { - match *self { - AccumulateVec::Array(ref mut v) => { - Drain::Array(v.drain(range)) - }, - AccumulateVec::Heap(ref mut v) => { - Drain::Heap(v.drain(range)) - }, - } - } -} - -impl Deref for AccumulateVec { - type Target = [A::Element]; - fn deref(&self) -> &Self::Target { - match *self { - AccumulateVec::Array(ref v) => v, - AccumulateVec::Heap(ref v) => v, - } - } -} - -impl DerefMut for AccumulateVec { - fn deref_mut(&mut self) -> &mut [A::Element] { - match *self { - AccumulateVec::Array(ref mut v) => v, - AccumulateVec::Heap(ref mut v) => v, - } - } -} - -impl FromIterator for AccumulateVec { - fn from_iter(iter: I) -> AccumulateVec where I: IntoIterator { - let iter = iter.into_iter(); - if iter.size_hint().1.map_or(false, |n| n <= A::LEN) { - let mut v = ArrayVec::new(); - v.extend(iter); - AccumulateVec::Array(v) - } else { - AccumulateVec::Heap(iter.collect()) - } - } -} - -pub struct IntoIter { - repr: IntoIterRepr, -} - -enum IntoIterRepr { - Array(array_vec::Iter), - Heap(vec::IntoIter), -} - -impl Iterator for IntoIter { - type Item = A::Element; - - fn next(&mut self) -> Option { - match self.repr { - IntoIterRepr::Array(ref mut arr) => arr.next(), - IntoIterRepr::Heap(ref mut iter) => iter.next(), - } - } - - fn size_hint(&self) -> (usize, Option) { - match self.repr { - IntoIterRepr::Array(ref iter) => iter.size_hint(), - IntoIterRepr::Heap(ref iter) => iter.size_hint(), - } - } -} - -pub enum Drain<'a, A: Array> - where A::Element: 'a -{ - Array(array_vec::Drain<'a, A>), - Heap(vec::Drain<'a, A::Element>), -} - -impl<'a, A: Array> Iterator for Drain<'a, A> { - type Item = A::Element; - - fn next(&mut self) -> Option { - match *self { - Drain::Array(ref mut drain) => drain.next(), - Drain::Heap(ref mut drain) => drain.next(), - } - } - - fn size_hint(&self) -> (usize, Option) { - match *self { - Drain::Array(ref drain) => drain.size_hint(), - Drain::Heap(ref drain) => drain.size_hint(), - } - } -} - -impl IntoIterator for AccumulateVec { - type Item = A::Element; - type IntoIter = IntoIter; - fn into_iter(self) -> Self::IntoIter { - IntoIter { - repr: match self { - AccumulateVec::Array(arr) => IntoIterRepr::Array(arr.into_iter()), - AccumulateVec::Heap(vec) => IntoIterRepr::Heap(vec.into_iter()), - } - } - } -} - -impl<'a, A: Array> IntoIterator for &'a AccumulateVec { - type Item = &'a A::Element; - type IntoIter = slice::Iter<'a, A::Element>; - fn into_iter(self) -> Self::IntoIter { - self.iter() - } -} - -impl<'a, A: Array> IntoIterator for &'a mut AccumulateVec { - type Item = &'a mut A::Element; - type IntoIter = slice::IterMut<'a, A::Element>; - fn into_iter(self) -> Self::IntoIter { - self.iter_mut() - } -} - -impl From> for AccumulateVec { - fn from(v: Vec) -> AccumulateVec { - AccumulateVec::many(v) - } -} - -impl Default for AccumulateVec { - fn default() -> AccumulateVec { - AccumulateVec::new() - } -} - -impl Encodable for AccumulateVec - where A: Array, - A::Element: Encodable { - fn encode(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_seq(self.len(), |s| { - for (i, e) in self.iter().enumerate() { - s.emit_seq_elt(i, |s| e.encode(s))?; - } - Ok(()) - }) - } -} - -impl Decodable for AccumulateVec - where A: Array, - A::Element: Decodable { - fn decode(d: &mut D) -> Result, D::Error> { - d.read_seq(|d, len| { - (0..len).map(|i| d.read_seq_elt(i, |d| Decodable::decode(d))).collect() - }) - } -} diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 936dec924090052af3f00a31b64e054765b668a2..7915650fd89f70401d79422f01aa15105168394a 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -61,7 +61,6 @@ pub use rustc_serialize::hex::ToHex; pub mod svh; -pub mod accumulate_vec; pub mod array_vec; pub mod base_n; pub mod bitslice; diff --git a/src/librustc_data_structures/small_vec.rs b/src/librustc_data_structures/small_vec.rs index e4e6a3d1a9c6735d722af2a3e2fcad1705c345d6..075b70c6426fb8407d4e00a3fd5835bf1a8bada7 100644 --- a/src/librustc_data_structures/small_vec.rs +++ b/src/librustc_data_structures/small_vec.rs @@ -8,11 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! A vector type intended to be used for collecting from iterators onto the stack. +//! 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. SmallVec is similar to AccumulateVec, but adds -//! the ability to push elements. +//! 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. diff --git a/src/librustc_typeck/Cargo.toml b/src/librustc_typeck/Cargo.toml index 184cb9826ba680a96152a87e7aee7b942b9a9536..881fa2604bc8b9dec1b1cc70870c3cf93be771c4 100644 --- a/src/librustc_typeck/Cargo.toml +++ b/src/librustc_typeck/Cargo.toml @@ -10,12 +10,13 @@ crate-type = ["dylib"] test = false [dependencies] -log = "0.4" -syntax = { path = "../libsyntax" } arena = { path = "../libarena" } +log = "0.4" rustc = { path = "../librustc" } rustc_data_structures = { path = "../librustc_data_structures" } +rustc_errors = { path = "../librustc_errors" } rustc_platform_intrinsics = { path = "../librustc_platform_intrinsics" } rustc_target = { path = "../librustc_target" } +smallvec = { version = "0.6.5", features = ["union"] } +syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } -rustc_errors = { path = "../librustc_errors" } diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 3c9452835fde93b079ced22befbdca70ef73424f..804aad3c0ecce29b86d51c9025ee1ce13ea96b48 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -12,8 +12,7 @@ //! representation. The main routine here is `ast_ty_to_ty()`: each use //! is parameterized by an instance of `AstConv`. -use rustc_data_structures::accumulate_vec::AccumulateVec; -use rustc_data_structures::array_vec::ArrayVec; +use smallvec::SmallVec; use hir::{self, GenericArg, GenericArgs}; use hir::def::Def; use hir::def_id::DefId; @@ -431,18 +430,7 @@ pub fn create_substs_for_generic_args<'a, 'b, A, P, I>( // We manually build up the substitution, rather than using convenience // methods in subst.rs so that we can iterate over the arguments and // parameters in lock-step linearly, rather than trying to match each pair. - let mut substs: AccumulateVec<[Kind<'tcx>; 8]> = if count <= 8 { - AccumulateVec::Array(ArrayVec::new()) - } else { - AccumulateVec::Heap(Vec::with_capacity(count)) - }; - - fn push_kind<'tcx>(substs: &mut AccumulateVec<[Kind<'tcx>; 8]>, kind: Kind<'tcx>) { - match substs { - AccumulateVec::Array(ref mut arr) => arr.push(kind), - AccumulateVec::Heap(ref mut vec) => vec.push(kind), - } - } + let mut substs: SmallVec<[Kind<'tcx>; 8]> = SmallVec::with_capacity(count); // Iterate over each segment of the path. while let Some((def_id, defs)) = stack.pop() { @@ -451,7 +439,7 @@ pub fn create_substs_for_generic_args<'a, 'b, A, P, I>( // If we have already computed substitutions for parents, we can use those directly. while let Some(¶m) = params.peek() { if let Some(&kind) = parent_substs.get(param.index as usize) { - push_kind(&mut substs, kind); + substs.push(kind); params.next(); } else { break; @@ -463,7 +451,7 @@ pub fn create_substs_for_generic_args<'a, 'b, A, P, I>( if let Some(¶m) = params.peek() { if param.index == 0 { if let GenericParamDefKind::Type { .. } = param.kind { - push_kind(&mut substs, self_ty.map(|ty| ty.into()) + substs.push(self_ty.map(|ty| ty.into()) .unwrap_or_else(|| inferred_kind(None, param, true))); params.next(); } @@ -487,7 +475,7 @@ pub fn create_substs_for_generic_args<'a, 'b, A, P, I>( match (arg, ¶m.kind) { (GenericArg::Lifetime(_), GenericParamDefKind::Lifetime) | (GenericArg::Type(_), GenericParamDefKind::Type { .. }) => { - push_kind(&mut substs, provided_kind(param, arg)); + substs.push(provided_kind(param, arg)); args.next(); params.next(); } @@ -501,7 +489,7 @@ pub fn create_substs_for_generic_args<'a, 'b, A, P, I>( (GenericArg::Type(_), GenericParamDefKind::Lifetime) => { // We expected a lifetime argument, but got a type // argument. That means we're inferring the lifetimes. - push_kind(&mut substs, inferred_kind(None, param, infer_types)); + substs.push(inferred_kind(None, param, infer_types)); params.next(); } } @@ -518,7 +506,7 @@ pub fn create_substs_for_generic_args<'a, 'b, A, P, I>( match param.kind { GenericParamDefKind::Lifetime | GenericParamDefKind::Type { .. } => { let kind = inferred_kind(Some(&substs), param, infer_types); - push_kind(&mut substs, kind); + substs.push(kind); } } args.next(); @@ -1041,7 +1029,7 @@ fn conv_object_ty_poly_trait_ref(&self, .chain(auto_traits.into_iter().map(ty::ExistentialPredicate::AutoTrait)) .chain(existential_projections .map(|x| ty::ExistentialPredicate::Projection(*x.skip_binder()))) - .collect::>(); + .collect::>(); v.sort_by(|a, b| a.stable_cmp(tcx, b)); let existential_predicates = ty::Binder::bind(tcx.mk_existential_predicates(v.into_iter())); diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index e31ae8eb8c7aecde6624fc02756c9e4cc32eef66..f465ff4d62163e63148d7bf39eae8376ad433156 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -96,6 +96,7 @@ extern crate rustc_data_structures; extern crate rustc_errors as errors; extern crate rustc_target; +extern crate smallvec; use rustc::hir; use rustc::lint;