Skip to content

Commit e617a17

Browse files
committed
Auto merge of #27919 - Eljay:doc-varargs, r=alexcrichton
Fixes #27876.
2 parents 054b7b7 + 90ed188 commit e617a17

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ impl Clean<Method> for ast::MethodSig {
999999
values: inputs.clean(cx),
10001000
},
10011001
output: self.decl.output.clean(cx),
1002+
variadic: false,
10021003
attrs: Vec::new()
10031004
};
10041005
Method {
@@ -1032,6 +1033,7 @@ impl Clean<TyMethod> for ast::MethodSig {
10321033
values: inputs.clean(cx),
10331034
},
10341035
output: self.decl.output.clean(cx),
1036+
variadic: false,
10351037
attrs: Vec::new()
10361038
};
10371039
TyMethod {
@@ -1098,6 +1100,7 @@ impl Clean<Item> for doctree::Function {
10981100
pub struct FnDecl {
10991101
pub inputs: Arguments,
11001102
pub output: FunctionRetTy,
1103+
pub variadic: bool,
11011104
pub attrs: Vec<Attribute>,
11021105
}
11031106

@@ -1113,6 +1116,7 @@ impl Clean<FnDecl> for ast::FnDecl {
11131116
values: self.inputs.clean(cx),
11141117
},
11151118
output: self.output.clean(cx),
1119+
variadic: self.variadic,
11161120
attrs: Vec::new()
11171121
}
11181122
}
@@ -1141,6 +1145,7 @@ impl<'a, 'tcx> Clean<FnDecl> for (ast::DefId, &'a ty::PolyFnSig<'tcx>) {
11411145
FnDecl {
11421146
output: Return(sig.0.output.clean(cx)),
11431147
attrs: Vec::new(),
1148+
variadic: sig.0.variadic,
11441149
inputs: Arguments {
11451150
values: sig.0.inputs.iter().map(|t| {
11461151
Argument {

src/librustdoc/html/format.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,11 @@ impl fmt::Display for clean::FunctionRetTy {
579579

580580
impl fmt::Display for clean::FnDecl {
581581
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
582-
write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
582+
if self.variadic {
583+
write!(f, "({args}, ...){arrow}", args = self.inputs, arrow = self.output)
584+
} else {
585+
write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
586+
}
583587
}
584588
}
585589

src/test/rustdoc/variadic.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern "C" {
12+
// @has variadic/fn.foo.html //pre 'pub unsafe extern fn foo(x: i32, ...)'
13+
pub fn foo(x: i32, ...);
14+
}

0 commit comments

Comments
 (0)