Skip to content

Commit

Permalink
Rollup merge of rust-lang#61605 - GuillaumeGomez:const-generic-displa…
Browse files Browse the repository at this point in the history
…y, r=varkor

Fix slice const generic length display

Fixes rust-lang#61487.

r? @varkor
  • Loading branch information
Centril authored Jun 7, 2019
2 parents 06a1df4 + 8f37537 commit 9bbdc40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2768,7 +2768,10 @@ impl Clean<Type> for hir::Ty {
};
let length = match cx.tcx.const_eval(param_env.and(cid)) {
Ok(length) => print_const(cx, length),
Err(_) => "_".to_string(),
Err(_) => cx.sess()
.source_map()
.span_to_snippet(cx.tcx.def_span(def_id))
.unwrap_or_else(|_| "_".to_string()),
};
Array(box ty.clean(cx), length)
},
Expand Down
12 changes: 12 additions & 0 deletions src/test/rustdoc/const-generics/const-generic-slice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![crate_name = "foo"]
#![feature(const_generics)]

pub trait Array {
type Item;
}

// @has foo/trait.Array.html
// @has - '//h3[@class="impl"]' 'impl<T, const N: usize> Array for [T; N]'
impl <T, const N: usize> Array for [T; N] {
type Item = T;
}

0 comments on commit 9bbdc40

Please sign in to comment.