]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #15613 : cmr/rust/rustdoc-arg-patterns, r=alexcrichton
authorbors <bors@rust-lang.org>
Sat, 12 Jul 2014 19:51:35 +0000 (19:51 +0000)
committerbors <bors@rust-lang.org>
Sat, 12 Jul 2014 19:51:35 +0000 (19:51 +0000)
src/librustdoc/clean/mod.rs
src/test/run-make/rustdoc-smoke/foo.rs

index 24f23761286f024f295809942c6d00321fa1e580..a5c6725bd819c484cded2d9707d243662c8847e6 100644 (file)
@@ -1951,9 +1951,16 @@ fn name_from_pat(p: &ast::Pat) -> String {
         PatWildMulti => "..".to_string(),
         PatIdent(_, ref p, _) => token::get_ident(p.node).get().to_string(),
         PatEnum(ref p, _) => path_to_string(p),
-        PatStruct(..) => fail!("tried to get argument name from pat_struct, \
-                                which is not allowed in function arguments"),
-        PatTup(..) => "(tuple arg NYI)".to_string(),
+        PatStruct(ref name, ref fields, etc) => {
+            format!("{} {{ {}{} }}", path_to_string(name),
+                fields.iter().map(|fp|
+                                  format!("{}: {}", fp.ident.as_str(), name_from_pat(&*fp.pat)))
+                             .collect::<Vec<String>>().connect(", "),
+                if etc { ", ..." } else { "" }
+            )
+        },
+        PatTup(ref elts) => format!("({})", elts.iter().map(|p| name_from_pat(&**p))
+                                            .collect::<Vec<String>>().connect(", ")),
         PatBox(p) => name_from_pat(&*p),
         PatRegion(p) => name_from_pat(&*p),
         PatLit(..) => {
index dda66f051bc8e5f829c2d93ace664476755e29f2..b783dd39a061a52724b639ba4569ae7c956aa443 100644 (file)
@@ -22,4 +22,8 @@ pub fn baz() { }
 
     /// *wow*
     pub trait Doge { }
+
+    pub struct Foo { x: int, y: uint }
+
+    pub fn prawns((a, b): (int, uint), Foo { x, y }: Foo) { }
 }