Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print const generics properly in rustdoc #61293

Merged
merged 3 commits into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3145,10 +3145,7 @@ impl<'tcx> Clean<Constant> for ty::Const<'tcx> {
fn clean(&self, cx: &DocContext<'_>) -> Constant {
Constant {
type_: self.ty.clean(cx),
expr: match self.val {
ConstValue::Param(ty::ParamConst { name, .. }) => format!("{}", name),
e => format!("{:?}", e), // FIXME generic consts with expressions
},
expr: format!("{}", self),
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/test/rustdoc/const-generics/add-impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ignore-tidy-linelength

#![feature(const_generics)]

#![crate_name = "foo"]

use std::ops::Add;

// @has foo/struct.Simd.html '//pre[@class="rust struct"]' 'pub struct Simd<T, const WIDTH: usize>'
pub struct Simd<T, const WIDTH: usize> {
inner: T,
}

// @has foo/struct.Simd.html '//div[@id="implementations-list"]/h3/code' 'impl Add<Simd<u8, 16>> for Simd<u8, 16>'
impl Add for Simd<u8, 16> {
type Output = Self;

fn add(self, rhs: Self) -> Self::Output {
Self { inner: 0 }
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// ignore-tidy-linelength

#![feature(const_generics)]
#![crate_name = "foo"]

// ignore-tidy-linelength
#![crate_name = "foo"]

pub enum Order {
Sorted,
Expand Down