diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-06-07 00:58:32 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-06-07 15:54:16 +0200 |
| commit | 8f3753703c9e4e587fcb9790a07aa18b310b8431 (patch) | |
| tree | 415bcb1f3dc437676b88672b500bf00af0312c6b | |
| parent | 8b36867093fb774bcbd9f787cbc470a5f44c1310 (diff) | |
| download | rust-8f3753703c9e4e587fcb9790a07aa18b310b8431.tar.gz rust-8f3753703c9e4e587fcb9790a07aa18b310b8431.zip | |
Fix slice const generic length display
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 5 | ||||
| -rw-r--r-- | src/test/rustdoc/const-generics/const-generic-slice.rs | 12 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 03d16feb483..a717ef20a84 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -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) }, diff --git a/src/test/rustdoc/const-generics/const-generic-slice.rs b/src/test/rustdoc/const-generics/const-generic-slice.rs new file mode 100644 index 00000000000..60d96770f7e --- /dev/null +++ b/src/test/rustdoc/const-generics/const-generic-slice.rs @@ -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; +} |
