]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/clean/utils.rs
Rollup merge of #104372 - Ayush1325:compiler-builtins, r=JohnTitor
[rust.git] / src / librustdoc / clean / utils.rs
index 824d98113c8f3a18ae8aa3ffbb4197a74df499d9..21f8fbe36f173fdf318079caa785f9d4116f9dca 100644 (file)
@@ -21,7 +21,7 @@
 use rustc_span::symbol::{kw, sym, Symbol};
 use std::fmt::Write as _;
 use std::mem;
-use thin_vec::ThinVec;
+use thin_vec::{thin_vec, ThinVec};
 
 #[cfg(test)]
 mod tests;
@@ -136,7 +136,7 @@ pub(super) fn external_path<'tcx>(
     let name = cx.tcx.item_name(did);
     Path {
         res: Res::Def(def_kind, did),
-        segments: vec![PathSegment {
+        segments: thin_vec![PathSegment {
             name,
             args: external_generic_args(cx, did, has_self, bindings, substs),
         }],
@@ -242,19 +242,13 @@ pub(crate) fn print_const(cx: &DocContext<'_>, n: ty::Const<'_>) -> String {
 
             s
         }
-        _ => {
-            let mut s = n.to_string();
-            // array lengths are obviously usize
-            if s.ends_with("_usize") {
-                let n = s.len() - "_usize".len();
-                s.truncate(n);
-                if s.ends_with(": ") {
-                    let n = s.len() - ": ".len();
-                    s.truncate(n);
-                }
-            }
-            s
+        // array lengths are obviously usize
+        ty::ConstKind::Value(ty::ValTree::Leaf(scalar))
+            if *n.ty().kind() == ty::Uint(ty::UintTy::Usize) =>
+        {
+            scalar.to_string()
         }
+        _ => n.to_string(),
     }
 }