diff options
author | Matthew Maurer <mmaurer@google.com> | 2023-04-04 16:44:35 +0000 |
---|---|---|
committer | Matthew Maurer <mmaurer@google.com> | 2023-04-04 16:44:35 +0000 |
commit | 971a9d6cf188b485af1dd1a03171f74e15fbf6cc (patch) | |
tree | 9fbee739478ab8ee4dc64d2187be48e387832841 | |
parent | c6d5e8bd97ec5c74df8022a6d67af0b20a34fd32 (diff) | |
download | syn-mid-971a9d6cf188b485af1dd1a03171f74e15fbf6cc.tar.gz |
Update to syn-2
This patch is unlikely to land upstream as is, since it requires that
the `full` feature be enabled on syn, and the primary purpose of
`syn-mid` is to avoid the `full` feature. Since we build with `full`
anyways, this is a non-issue for us.
Bug: 276463929
Test: m
Change-Id: I8a54139a5644c3cfd8e8989f4ed2e2e2242bf06b
-rw-r--r-- | patches/syn-2.patch | 50 | ||||
-rw-r--r-- | src/func.rs | 11 |
2 files changed, 56 insertions, 5 deletions
diff --git a/patches/syn-2.patch b/patches/syn-2.patch new file mode 100644 index 0000000..a25bd0c --- /dev/null +++ b/patches/syn-2.patch @@ -0,0 +1,50 @@ +diff --git a/src/func.rs b/src/func.rs +index a53e63b..384e80b 100644 +--- a/src/func.rs ++++ b/src/func.rs +@@ -85,11 +85,12 @@ mod parsing { + + impl Parse for Signature { + fn parse(input: ParseStream<'_>) -> Result<Self> { ++ #[allow(clippy::trivially_copy_pass_by_ref)] + fn get_variadic(input: &&FnArg) -> Option<Variadic> { + if let FnArg::Typed(PatType { ty, .. }) = input { + if let Type::Verbatim(tokens) = &**ty { + if let Ok(dots) = parse2(tokens.clone()) { +- return Some(Variadic { attrs: Vec::new(), dots }); ++ return Some(Variadic { attrs: Vec::new(), pat: None, comma: None, dots }); + } + } + } +@@ -106,7 +107,7 @@ mod parsing { + + let content; + let paren_token = parenthesized!(content in input); +- let inputs = content.parse_terminated(FnArg::parse)?; ++ let inputs = content.parse_terminated(FnArg::parse, Token![,])?; + let variadic = inputs.last().as_ref().and_then(get_variadic); + + let output: ReturnType = input.parse()?; +@@ -119,11 +120,11 @@ mod parsing { + abi, + fn_token, + ident, ++ generics, + paren_token, + inputs, +- output, + variadic, +- generics, ++ output, + }) + } + } +@@ -210,7 +211,7 @@ mod printing { + FnArg::Receiver(_) => return false, + }; + +- let tokens = match pat.ty.as_ref() { ++ let tokens = match &*pat.ty { + Type::Verbatim(tokens) => tokens, + _ => return false, + }; diff --git a/src/func.rs b/src/func.rs index a53e63b..384e80b 100644 --- a/src/func.rs +++ b/src/func.rs @@ -85,11 +85,12 @@ mod parsing { impl Parse for Signature { fn parse(input: ParseStream<'_>) -> Result<Self> { + #[allow(clippy::trivially_copy_pass_by_ref)] fn get_variadic(input: &&FnArg) -> Option<Variadic> { if let FnArg::Typed(PatType { ty, .. }) = input { if let Type::Verbatim(tokens) = &**ty { if let Ok(dots) = parse2(tokens.clone()) { - return Some(Variadic { attrs: Vec::new(), dots }); + return Some(Variadic { attrs: Vec::new(), pat: None, comma: None, dots }); } } } @@ -106,7 +107,7 @@ mod parsing { let content; let paren_token = parenthesized!(content in input); - let inputs = content.parse_terminated(FnArg::parse)?; + let inputs = content.parse_terminated(FnArg::parse, Token![,])?; let variadic = inputs.last().as_ref().and_then(get_variadic); let output: ReturnType = input.parse()?; @@ -119,11 +120,11 @@ mod parsing { abi, fn_token, ident, + generics, paren_token, inputs, - output, variadic, - generics, + output, }) } } @@ -210,7 +211,7 @@ mod printing { FnArg::Receiver(_) => return false, }; - let tokens = match pat.ty.as_ref() { + let tokens = match &*pat.ty { Type::Verbatim(tokens) => tokens, _ => return false, }; |