Skip to content

Commit d6f80ad

Browse files
committed
Use ArrayVec instead of SmallVec
1 parent 30c2646 commit d6f80ad

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4386,6 +4386,7 @@ dependencies = [
43864386
name = "rustdoc"
43874387
version = "0.0.0"
43884388
dependencies = [
4389+
"arrayvec",
43894390
"expect-test",
43904391
"itertools 0.9.0",
43914392
"minifier",

src/librustdoc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ edition = "2018"
88
path = "lib.rs"
99

1010
[dependencies]
11+
arrayvec = { version = "0.5.1", default-features = false }
1112
pulldown-cmark = { version = "0.8", default-features = false }
1213
minifier = "0.0.33"
1314
rayon = { version = "0.3.0", package = "rustc-rayon" }

src/librustdoc/clean/types.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::rc::Rc;
88
use std::sync::Arc;
99
use std::{slice, vec};
1010

11+
use arrayvec::ArrayVec;
1112
use rustc_ast::attr;
1213
use rustc_ast::util::comments::beautify_doc_string;
1314
use rustc_ast::{self as ast, AttrStyle};
@@ -28,7 +29,6 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol, SymbolStr};
2829
use rustc_span::{self, FileName, Loc};
2930
use rustc_target::abi::VariantIdx;
3031
use rustc_target::spec::abi::Abi;
31-
use smallvec::{smallvec, SmallVec};
3232

3333
use crate::clean::cfg::Cfg;
3434
use crate::clean::external_path;
@@ -1539,12 +1539,12 @@ impl PrimitiveType {
15391539
}
15401540
}
15411541

1542-
crate fn impls(&self, tcx: TyCtxt<'_>) -> &'static SmallVec<[DefId; 4]> {
1542+
crate fn impls(&self, tcx: TyCtxt<'_>) -> &'static ArrayVec<[DefId; 4]> {
15431543
Self::all_impls(tcx).get(self).expect("missing impl for primitive type")
15441544
}
15451545

1546-
crate fn all_impls(tcx: TyCtxt<'_>) -> &'static FxHashMap<PrimitiveType, SmallVec<[DefId; 4]>> {
1547-
static CELL: OnceCell<FxHashMap<PrimitiveType, SmallVec<[DefId; 4]>>> = OnceCell::new();
1546+
crate fn all_impls(tcx: TyCtxt<'_>) -> &'static FxHashMap<PrimitiveType, ArrayVec<[DefId; 4]>> {
1547+
static CELL: OnceCell<FxHashMap<PrimitiveType, ArrayVec<[DefId; 4]>>> = OnceCell::new();
15481548

15491549
CELL.get_or_init(move || {
15501550
use self::PrimitiveType::*;
@@ -1568,7 +1568,7 @@ impl PrimitiveType {
15681568
}
15691569

15701570
let single = |a: Option<DefId>| a.into_iter().collect();
1571-
let both = |a: Option<DefId>, b: Option<DefId>| -> SmallVec<_> {
1571+
let both = |a: Option<DefId>, b: Option<DefId>| -> ArrayVec<_> {
15721572
a.into_iter().chain(b).collect()
15731573
};
15741574

@@ -1601,8 +1601,8 @@ impl PrimitiveType {
16011601
.collect()
16021602
},
16031603
Array => single(lang_items.array_impl()),
1604-
Tuple => smallvec![],
1605-
Unit => smallvec![],
1604+
Tuple => ArrayVec::new(),
1605+
Unit => ArrayVec::new(),
16061606
RawPointer => {
16071607
lang_items
16081608
.const_ptr_impl()
@@ -1612,9 +1612,9 @@ impl PrimitiveType {
16121612
.chain(lang_items.mut_slice_ptr_impl())
16131613
.collect()
16141614
},
1615-
Reference => smallvec![],
1616-
Fn => smallvec![],
1617-
Never => smallvec![],
1615+
Reference => ArrayVec::new(),
1616+
Fn => ArrayVec::new(),
1617+
Never => ArrayVec::new(),
16181618
}
16191619
})
16201620
}

0 commit comments

Comments
 (0)