Skip to content

Show variadic args in rustdoc output. #27919

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

Merged
merged 1 commit into from Aug 23, 2015
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: 5 additions & 0 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ impl Clean<Method> for ast::MethodSig {
values: inputs.clean(cx),
},
output: self.decl.output.clean(cx),
variadic: false,
attrs: Vec::new()
};
Method {
Expand Down Expand Up @@ -1032,6 +1033,7 @@ impl Clean<TyMethod> for ast::MethodSig {
values: inputs.clean(cx),
},
output: self.decl.output.clean(cx),
variadic: false,
attrs: Vec::new()
};
TyMethod {
Expand Down Expand Up @@ -1098,6 +1100,7 @@ impl Clean<Item> for doctree::Function {
pub struct FnDecl {
pub inputs: Arguments,
pub output: FunctionRetTy,
pub variadic: bool,
pub attrs: Vec<Attribute>,
}

Expand All @@ -1113,6 +1116,7 @@ impl Clean<FnDecl> for ast::FnDecl {
values: self.inputs.clean(cx),
},
output: self.output.clean(cx),
variadic: self.variadic,
attrs: Vec::new()
}
}
Expand Down Expand Up @@ -1141,6 +1145,7 @@ impl<'a, 'tcx> Clean<FnDecl> for (ast::DefId, &'a ty::PolyFnSig<'tcx>) {
FnDecl {
output: Return(sig.0.output.clean(cx)),
attrs: Vec::new(),
variadic: sig.0.variadic,
inputs: Arguments {
values: sig.0.inputs.iter().map(|t| {
Argument {
Expand Down
6 changes: 5 additions & 1 deletion src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,11 @@ impl fmt::Display for clean::FunctionRetTy {

impl fmt::Display for clean::FnDecl {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
if self.variadic {
write!(f, "({args}, ...){arrow}", args = self.inputs, arrow = self.output)
} else {
write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
}
}
}

Expand Down
14 changes: 14 additions & 0 deletions src/test/rustdoc/variadic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern "C" {
// @has variadic/fn.foo.html //pre 'pub unsafe extern fn foo(x: i32, ...)'
pub fn foo(x: i32, ...);
}