Skip to content

Commit f1cda51

Browse files
committed
Merge pull request #20512 from bjz/rustdoc
Allow rustdoc to accept vector pattern arguments Reviewed-by: alexcrichton, alexcrichton
2 parents 0fd2c84 + afdddef commit f1cda51

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,8 +2243,12 @@ fn name_from_pat(p: &ast::Pat) -> String {
22432243
},
22442244
PatRange(..) => panic!("tried to get argument name from PatRange, \
22452245
which is not allowed in function arguments"),
2246-
PatVec(..) => panic!("tried to get argument name from pat_vec, \
2247-
which is not allowed in function arguments"),
2246+
PatVec(ref begin, ref mid, ref end) => {
2247+
let begin = begin.iter().map(|p| name_from_pat(&**p));
2248+
let mid = mid.as_ref().map(|p| format!("..{}", name_from_pat(&**p))).into_iter();
2249+
let end = end.iter().map(|p| name_from_pat(&**p));
2250+
format!("[{}]", begin.chain(mid).chain(end).collect::<Vec<_>>().connect(", "))
2251+
},
22482252
PatMac(..) => {
22492253
warn!("can't document the name of a function argument \
22502254
produced by a pattern macro");

0 commit comments

Comments
 (0)