Skip to content
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

rustdoc-json: Document and Test that args can be patterns. #103065

Merged
merged 1 commit into from
Dec 1, 2022
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
4 changes: 4 additions & 0 deletions src/rustdoc-json-types/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,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) {}