Skip to content

Commit

Permalink
Rollup merge of rust-lang#103065 - aDotInTheVoid:rdj-arg-pattern, r=G…
Browse files Browse the repository at this point in the history
…uillaumeGomez

rustdoc-json: Document and Test that args can be patterns.
  • Loading branch information
matthiaskrgr authored Nov 30, 2022
2 parents 90711a8 + bb04e7e commit ddd980a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/rustdoc-json-types/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,10 @@ pub struct FunctionPointer {

#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct FnDecl {
/// List of argument names and their type.
///
/// Note that not all names will be valid identifiers, as some of
/// them may be patterns.
pub inputs: Vec<(String, Type)>,
pub output: Option<Type>,
pub c_variadic: bool,
Expand Down
7 changes: 7 additions & 0 deletions src/test/rustdoc-json/fns/pattern_arg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @is "$.index[*][?(@.name=='fst')].inner.decl.inputs[0][0]" '"(x, _)"'
pub fn fst<X, Y>((x, _): (X, Y)) -> X {
x
}

// @is "$.index[*][?(@.name=='drop_int')].inner.decl.inputs[0][0]" '"_"'
pub fn drop_int(_: i32) {}

0 comments on commit ddd980a

Please sign in to comment.