Skip to content

Commit 9bbdc40

Browse files
authored
Rollup merge of #61605 - GuillaumeGomez:const-generic-display, r=varkor
Fix slice const generic length display Fixes #61487. r? @varkor
2 parents 06a1df4 + 8f37537 commit 9bbdc40

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/librustdoc/clean/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2768,7 +2768,10 @@ impl Clean<Type> for hir::Ty {
27682768
};
27692769
let length = match cx.tcx.const_eval(param_env.and(cid)) {
27702770
Ok(length) => print_const(cx, length),
2771-
Err(_) => "_".to_string(),
2771+
Err(_) => cx.sess()
2772+
.source_map()
2773+
.span_to_snippet(cx.tcx.def_span(def_id))
2774+
.unwrap_or_else(|_| "_".to_string()),
27722775
};
27732776
Array(box ty.clean(cx), length)
27742777
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![crate_name = "foo"]
2+
#![feature(const_generics)]
3+
4+
pub trait Array {
5+
type Item;
6+
}
7+
8+
// @has foo/trait.Array.html
9+
// @has - '//h3[@class="impl"]' 'impl<T, const N: usize> Array for [T; N]'
10+
impl <T, const N: usize> Array for [T; N] {
11+
type Item = T;
12+
}

0 commit comments

Comments
 (0)