Skip to content

Commit 5079744

Browse files
committed
Remove PrimitiveType::as_str
1 parent 132211b commit 5079744

File tree

4 files changed

+10
-41
lines changed

4 files changed

+10
-41
lines changed

src/librustdoc/clean/types.rs

-31
Original file line numberDiff line numberDiff line change
@@ -1767,37 +1767,6 @@ impl PrimitiveType {
17671767
}
17681768
}
17691769

1770-
crate fn as_str(&self) -> &'static str {
1771-
use self::PrimitiveType::*;
1772-
match *self {
1773-
Isize => "isize",
1774-
I8 => "i8",
1775-
I16 => "i16",
1776-
I32 => "i32",
1777-
I64 => "i64",
1778-
I128 => "i128",
1779-
Usize => "usize",
1780-
U8 => "u8",
1781-
U16 => "u16",
1782-
U32 => "u32",
1783-
U64 => "u64",
1784-
U128 => "u128",
1785-
F32 => "f32",
1786-
F64 => "f64",
1787-
Str => "str",
1788-
Bool => "bool",
1789-
Char => "char",
1790-
Array => "array",
1791-
Slice => "slice",
1792-
Tuple => "tuple",
1793-
Unit => "unit",
1794-
RawPointer => "pointer",
1795-
Reference => "reference",
1796-
Fn => "fn",
1797-
Never => "never",
1798-
}
1799-
}
1800-
18011770
crate fn impls(&self, tcx: TyCtxt<'_>) -> &'static ArrayVec<DefId, 4> {
18021771
Self::all_impls(tcx).get(self).expect("missing impl for primitive type")
18031772
}

src/librustdoc/html/format.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ fn primitive_link(
574574
f,
575575
"<a class=\"primitive\" href=\"{}primitive.{}.html\">",
576576
"../".repeat(len),
577-
prim.as_str()
577+
prim.as_sym()
578578
)?;
579579
needs_termination = true;
580580
}
@@ -603,7 +603,7 @@ fn primitive_link(
603603
f,
604604
"<a class=\"primitive\" href=\"{}/primitive.{}.html\">",
605605
loc.join("/"),
606-
prim.as_str()
606+
prim.as_sym()
607607
)?;
608608
needs_termination = true;
609609
}
@@ -677,7 +677,7 @@ fn fmt_type<'cx>(
677677
fmt::Display::fmt(&tybounds(param_names, cx), f)
678678
}
679679
clean::Infer => write!(f, "_"),
680-
clean::Primitive(prim) => primitive_link(f, prim, prim.as_str(), cx),
680+
clean::Primitive(prim) => primitive_link(f, prim, &*prim.as_sym().as_str(), cx),
681681
clean::BareFunction(ref decl) => {
682682
if f.alternate() {
683683
write!(

src/librustdoc/json/conversions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl FromWithTcx<clean::Type> for Type {
379379
.unwrap_or_default(),
380380
},
381381
Generic(s) => Type::Generic(s.to_string()),
382-
Primitive(p) => Type::Primitive(p.as_str().to_string()),
382+
Primitive(p) => Type::Primitive(p.as_sym().to_string()),
383383
BareFunction(f) => Type::FunctionPointer(Box::new((*f).into_tcx(tcx))),
384384
Tuple(t) => Type::Tuple(t.into_iter().map(|x| x.into_tcx(tcx)).collect()),
385385
Slice(t) => Type::Slice(Box::new((*t).into_tcx(tcx))),

src/librustdoc/passes/collect_intra_doc_links.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ impl Res {
9191
}
9292
}
9393

94-
fn name(self, tcx: TyCtxt<'_>) -> String {
94+
fn name(self, tcx: TyCtxt<'_>) -> Symbol {
9595
match self {
96-
Res::Def(_, id) => tcx.item_name(id).to_string(),
97-
Res::Primitive(prim) => prim.as_str().to_string(),
96+
Res::Def(_, id) => tcx.item_name(id),
97+
Res::Primitive(prim) => prim.as_sym(),
9898
}
9999
}
100100

@@ -388,7 +388,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
388388
ty::AssocKind::Const => "associatedconstant",
389389
ty::AssocKind::Type => "associatedtype",
390390
};
391-
let fragment = format!("{}#{}.{}", prim_ty.as_str(), out, item_name);
391+
let fragment = format!("{}#{}.{}", prim_ty.as_sym(), out, item_name);
392392
(Res::Primitive(prim_ty), fragment, Some((kind.as_def_kind(), item.def_id)))
393393
})
394394
})
@@ -481,7 +481,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
481481
AnchorFailure::RustdocAnchorConflict(res),
482482
));
483483
}
484-
return Ok((res, Some(ty.as_str().to_owned())));
484+
return Ok((res, Some(ty.as_sym().to_string())));
485485
}
486486
_ => return Ok((res, extra_fragment.clone())),
487487
}
@@ -1148,7 +1148,7 @@ impl LinkCollector<'_, '_> {
11481148
return None;
11491149
}
11501150
res = prim;
1151-
fragment = Some(prim.name(self.cx.tcx));
1151+
fragment = Some(prim.name(self.cx.tcx).to_string());
11521152
} else {
11531153
// `[char]` when a `char` module is in scope
11541154
let candidates = vec![res, prim];

0 commit comments

Comments
 (0)