Skip to content

rustdoc: Rename Vector and FixedVector to Slice and Array #42360

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
Jun 3, 2017
Merged
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
19 changes: 8 additions & 11 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
@@ -1506,8 +1506,8 @@ pub enum Type {
/// extern "ABI" fn
BareFunction(Box<BareFunctionDecl>),
Tuple(Vec<Type>),
Vector(Box<Type>),
FixedVector(Box<Type>, String),
Slice(Box<Type>),
Array(Box<Type>, usize),
Never,
Unique(Box<Type>),
RawPointer(Mutability, Box<Type>),
@@ -1573,10 +1573,8 @@ impl Type {
pub fn primitive_type(&self) -> Option<PrimitiveType> {
match *self {
Primitive(p) | BorrowedRef { type_: box Primitive(p), ..} => Some(p),
Vector(..) | BorrowedRef{ type_: box Vector(..), .. } => Some(PrimitiveType::Slice),
FixedVector(..) | BorrowedRef { type_: box FixedVector(..), .. } => {
Some(PrimitiveType::Array)
}
Slice(..) | BorrowedRef { type_: box Slice(..), .. } => Some(PrimitiveType::Slice),
Array(..) | BorrowedRef { type_: box Array(..), .. } => Some(PrimitiveType::Array),
Tuple(..) => Some(PrimitiveType::Tuple),
RawPointer(..) => Some(PrimitiveType::RawPointer),
_ => None,
@@ -1717,11 +1715,11 @@ impl Clean<Type> for hir::Ty {
BorrowedRef {lifetime: lifetime, mutability: m.mutbl.clean(cx),
type_: box m.ty.clean(cx)}
}
TySlice(ref ty) => Vector(box ty.clean(cx)),
TySlice(ref ty) => Slice(box ty.clean(cx)),
TyArray(ref ty, length) => {
use rustc::middle::const_val::eval_length;
let n = eval_length(cx.tcx, length, "array length").unwrap();
FixedVector(box ty.clean(cx), n.to_string())
Array(box ty.clean(cx), n)
},
TyTup(ref tys) => Tuple(tys.clean(cx)),
TyPath(hir::QPath::Resolved(None, ref path)) => {
@@ -1832,9 +1830,8 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
ty::TyUint(uint_ty) => Primitive(uint_ty.into()),
ty::TyFloat(float_ty) => Primitive(float_ty.into()),
ty::TyStr => Primitive(PrimitiveType::Str),
ty::TySlice(ty) => Vector(box ty.clean(cx)),
ty::TyArray(ty, i) => FixedVector(box ty.clean(cx),
format!("{}", i)),
ty::TySlice(ty) => Slice(box ty.clean(cx)),
ty::TyArray(ty, n) => Array(box ty.clean(cx), n),
ty::TyRawPtr(mt) => RawPointer(mt.mutbl.clean(cx), box mt.ty.clean(cx)),
ty::TyRef(r, mt) => BorrowedRef {
lifetime: r.clean(cx),
15 changes: 4 additions & 11 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
@@ -25,7 +25,6 @@ use rustc::hir;
use clean::{self, PrimitiveType};
use core::DocAccessLevels;
use html::item_type::ItemType;
use html::escape::Escape;
use html::render;
use html::render::{cache, CURRENT_LOCATION_KEY};

@@ -643,21 +642,15 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
}
}
}
clean::Vector(ref t) => {
clean::Slice(ref t) => {
primitive_link(f, PrimitiveType::Slice, "[")?;
fmt::Display::fmt(t, f)?;
primitive_link(f, PrimitiveType::Slice, "]")
}
clean::FixedVector(ref t, ref s) => {
clean::Array(ref t, n) => {
primitive_link(f, PrimitiveType::Array, "[")?;
fmt::Display::fmt(t, f)?;
if f.alternate() {
primitive_link(f, PrimitiveType::Array,
&format!("; {}]", s))
} else {
primitive_link(f, PrimitiveType::Array,
&format!("; {}]", Escape(s)))
}
primitive_link(f, PrimitiveType::Array, &format!("; {}]", n))
}
clean::Never => f.write_str("!"),
clean::RawPointer(m, ref t) => {
@@ -685,7 +678,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
};
let m = MutableSpace(mutability);
match **ty {
clean::Vector(ref bt) => { // BorrowedRef{ ... Vector(T) } is &[T]
clean::Slice(ref bt) => { // BorrowedRef{ ... Slice(T) } is &[T]
match **bt {
clean::Generic(_) => {
if f.alternate() {