Update syn, transitively, to 2.0.

This commit is contained in:
Sergio Benitez 2023-03-22 19:30:26 -07:00
parent bbbb927ac2
commit 322f88e61a
14 changed files with 79 additions and 72 deletions

View File

@ -14,7 +14,7 @@ rust-version = "1.56"
proc-macro = true
[dependencies]
devise = "0.3"
devise = "0.4"
quote = "1"
[dev-dependencies]

View File

@ -15,7 +15,7 @@ proc-macro = true
[dependencies]
quote = "1.0"
devise = "0.3"
devise = "0.4"
[dev-dependencies]
version_check = "0.9"

View File

@ -18,9 +18,9 @@ proc-macro = true
[dependencies]
indexmap = "1.0"
quote = "1.0"
syn = { version = "1.0.72", features = ["full", "visit", "visit-mut", "extra-traits"] }
syn = { version = "2.0", features = ["full", "visit", "visit-mut", "extra-traits"] }
proc-macro2 = "1.0.27"
devise = "0.3.1"
devise = "0.4"
rocket_http = { version = "0.5.0-rc.2", path = "../http/" }
unicode-xid = "0.2"
glob = "0.3"

View File

@ -23,7 +23,7 @@ pub fn _catch(
// Determine the number of parameters that will be passed in.
if catch.function.sig.inputs.len() > 2 {
return Err(catch.function.sig.paren_token.span
return Err(catch.function.sig.paren_token.span.join()
.error("invalid number of arguments: must be zero, one, or two")
.help("catchers optionally take `&Request` or `Status, &Request`"));
}

View File

@ -137,7 +137,7 @@ impl Route {
}
// Check the validity of function arguments.
let span = handler.sig.paren_token.span;
let span = handler.sig.paren_token.span.join();
let mut arguments = Arguments { map: ArgumentMap::new(), span };
for arg in &handler.sig.inputs {
if let Some((ident, ty)) = arg.typed() {

View File

@ -1,11 +1,13 @@
use proc_macro2::TokenStream;
use syn::parse::{Parse, ParseStream, discouraged::Speculative};
#[derive(Debug)]
pub enum Input {
Type(syn::Type, Option<(syn::Token![+], syn::Lifetime)>),
Tokens(TokenStream)
}
#[derive(Debug)]
struct Invocation {
ty_stream_ty: syn::Path,
stream_mac: syn::Path,
@ -38,11 +40,9 @@ impl Parse for Input {
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
let fork = input.fork();
if let Ok(mut ty) = fork.parse() {
input.advance_to(&fork);
// If there's an extra + '_, use it in the reinterpretation.
let mut bound = match input.parse() {
Ok(plus) => Some((plus, input.parse()?)),
let mut bound = match fork.parse() {
Ok(plus) => Some((plus, fork.parse()?)),
_ => None,
};
@ -52,7 +52,13 @@ impl Parse for Input {
bound = Some((plus, lt));
}
Ok(Input::Type(ty, bound))
// If we have nothing else to parse, this must have been a type.
if fork.is_empty() {
input.advance_to(&fork);
Ok(Input::Type(ty, bound))
} else {
Ok(Input::Tokens(input.parse()?))
}
} else {
Ok(Input::Tokens(input.parse()?))
}
@ -75,7 +81,8 @@ impl Parse for Invocation {
/// eagerly on a single token, so something like `foo!(for x in 0..10 {})` will
/// match a `($ty)` branch as will anything that starts with a path.
pub fn _macro(input: proc_macro::TokenStream) -> devise::Result<TokenStream> {
let i: Invocation = syn::parse(input)?;
let tokens = proc_macro2::TokenStream::from(input);
let i: Invocation = syn::parse2(tokens)?;
let (s_ty, mac, s_trait) = (i.ty_stream_ty, i.stream_mac, i.stream_trait);
let tokens = match i.input {
Input::Tokens(tt) => quote!(#s_ty::from(#mac!(#tt))),

View File

@ -163,7 +163,7 @@ impl Parse for Args {
}
// Parse arguments. Ensure both types of args were not used at once.
let args: Punctuated<Arg, Token![,]> = input.parse_terminated(Arg::parse)?;
let args = input.parse_terminated(Arg::parse, Token![,])?;
let mut first_is_named = None;
for arg in &args {
if let Some(first_is_named) = first_is_named {
@ -314,7 +314,7 @@ impl Parse for InternalUriParams {
let content;
syn::parenthesized!(content in input);
let fn_args: Punctuated<FnArg, Token![,]> = content.parse_terminated(FnArg::parse)?;
let fn_args = content.parse_terminated(FnArg::parse, Token![,])?;
let fn_args = fn_args.into_iter().collect();
input.parse::<Token![,]>()?;

View File

@ -73,7 +73,7 @@ fn context_type(input: Input<'_>) -> Result<(TokenStream, syn::Generics)> {
let lifetime = syn::parse_quote!('r);
if !gen.replace_lifetime(0, &lifetime) {
gen.insert_lifetime(syn::LifetimeDef::new(lifetime.clone()));
gen.insert_lifetime(syn::LifetimeParam::new(lifetime.clone()));
}
gen.add_where_predicates(generic_bounds(input)?);

View File

@ -39,7 +39,7 @@ pub fn derive_uri_display_query(input: proc_macro::TokenStream) -> TokenStream {
.validator(ValidatorBuild::new()
.enum_validate(|_, data| {
if data.variants().count() == 0 {
Err(data.brace_token.span.error(NO_EMPTY_ENUMS))
Err(data.brace_token.span.join().error(NO_EMPTY_ENUMS))
} else {
Ok(())
}

View File

@ -1,4 +1,4 @@
error: expected identifier
error: expected identifier, found keyword `_`
--> tests/ui-fail-nightly/typed-uris-bad-params.rs:63:18
|
63 | uri!(ignored(_ = 10));

View File

@ -1,8 +1,8 @@
error: expected identifier
--> tests/ui-fail-nightly/typed-uris-invalid-syntax.rs:10:28
error: unexpected token
--> tests/ui-fail-nightly/typed-uris-invalid-syntax.rs:10:16
|
10 | uri!(simple: id = 100, "Hello");
| ^^^^^^^
| ^
error: named and unnamed parameters cannot be mixed
--> tests/ui-fail-nightly/typed-uris-invalid-syntax.rs:11:17

View File

@ -1,11 +1,11 @@
error: tuple structs are not supported
--> $DIR/from_form_field.rs:4:1
--> tests/ui-fail-stable/from_form_field.rs:4:1
|
4 | struct Foo1;
| ^^^^^^
error: [note] error occurred while deriving `FromFormField`
--> $DIR/from_form_field.rs:3:10
--> tests/ui-fail-stable/from_form_field.rs:3:10
|
3 | #[derive(FromFormField)]
| ^^^^^^^^^^^^^
@ -13,13 +13,13 @@ error: [note] error occurred while deriving `FromFormField`
= note: this error originates in the derive macro `FromFormField` (in Nightly builds, run with -Z macro-backtrace for more info)
error: tuple structs are not supported
--> $DIR/from_form_field.rs:7:1
--> tests/ui-fail-stable/from_form_field.rs:7:1
|
7 | struct Foo2(usize);
| ^^^^^^
error: [note] error occurred while deriving `FromFormField`
--> $DIR/from_form_field.rs:6:10
--> tests/ui-fail-stable/from_form_field.rs:6:10
|
6 | #[derive(FromFormField)]
| ^^^^^^^^^^^^^
@ -27,13 +27,13 @@ error: [note] error occurred while deriving `FromFormField`
= note: this error originates in the derive macro `FromFormField` (in Nightly builds, run with -Z macro-backtrace for more info)
error: named structs are not supported
--> $DIR/from_form_field.rs:10:1
--> tests/ui-fail-stable/from_form_field.rs:10:1
|
10 | struct Foo3 {
| ^^^^^^
error: [note] error occurred while deriving `FromFormField`
--> $DIR/from_form_field.rs:9:10
--> tests/ui-fail-stable/from_form_field.rs:9:10
|
9 | #[derive(FromFormField)]
| ^^^^^^^^^^^^^
@ -41,13 +41,13 @@ error: [note] error occurred while deriving `FromFormField`
= note: this error originates in the derive macro `FromFormField` (in Nightly builds, run with -Z macro-backtrace for more info)
error: variants cannot have fields
--> $DIR/from_form_field.rs:16:6
--> tests/ui-fail-stable/from_form_field.rs:16:6
|
16 | A(usize),
| ^^^^^^^
error: [note] error occurred while deriving `FromFormField`
--> $DIR/from_form_field.rs:14:10
--> tests/ui-fail-stable/from_form_field.rs:14:10
|
14 | #[derive(FromFormField)]
| ^^^^^^^^^^^^^
@ -55,13 +55,13 @@ error: [note] error occurred while deriving `FromFormField`
= note: this error originates in the derive macro `FromFormField` (in Nightly builds, run with -Z macro-backtrace for more info)
error: enum must have at least one variant
--> $DIR/from_form_field.rs:20:1
--> tests/ui-fail-stable/from_form_field.rs:20:1
|
20 | enum Foo5 { }
| ^^^^
error: [note] error occurred while deriving `FromFormField`
--> $DIR/from_form_field.rs:19:10
--> tests/ui-fail-stable/from_form_field.rs:19:10
|
19 | #[derive(FromFormField)]
| ^^^^^^^^^^^^^
@ -69,13 +69,13 @@ error: [note] error occurred while deriving `FromFormField`
= note: this error originates in the derive macro `FromFormField` (in Nightly builds, run with -Z macro-backtrace for more info)
error: type generics are not supported
--> $DIR/from_form_field.rs:23:11
--> tests/ui-fail-stable/from_form_field.rs:23:11
|
23 | enum Foo6<T> {
| ^
error: [note] error occurred while deriving `FromFormField`
--> $DIR/from_form_field.rs:22:10
--> tests/ui-fail-stable/from_form_field.rs:22:10
|
22 | #[derive(FromFormField)]
| ^^^^^^^^^^^^^
@ -83,13 +83,13 @@ error: [note] error occurred while deriving `FromFormField`
= note: this error originates in the derive macro `FromFormField` (in Nightly builds, run with -Z macro-backtrace for more info)
error: invalid value: expected string literal
--> $DIR/from_form_field.rs:29:21
--> tests/ui-fail-stable/from_form_field.rs:29:21
|
29 | #[field(value = 123)]
| ^^^
error: [note] error occurred while deriving `FromFormField`
--> $DIR/from_form_field.rs:27:10
--> tests/ui-fail-stable/from_form_field.rs:27:10
|
27 | #[derive(FromFormField)]
| ^^^^^^^^^^^^^
@ -97,13 +97,13 @@ error: [note] error occurred while deriving `FromFormField`
= note: this error originates in the derive macro `FromFormField` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected literal, found bare path "value"
--> $DIR/from_form_field.rs:35:13
--> tests/ui-fail-stable/from_form_field.rs:35:13
|
35 | #[field(value)]
| ^^^^^
error: [note] error occurred while deriving `FromFormField`
--> $DIR/from_form_field.rs:33:10
--> tests/ui-fail-stable/from_form_field.rs:33:10
|
33 | #[derive(FromFormField)]
| ^^^^^^^^^^^^^
@ -111,25 +111,25 @@ error: [note] error occurred while deriving `FromFormField`
= note: this error originates in the derive macro `FromFormField` (in Nightly builds, run with -Z macro-backtrace for more info)
error: variant has conflicting values
--> $DIR/from_form_field.rs:41:5
--> tests/ui-fail-stable/from_form_field.rs:41:5
|
41 | #[field(value = "bar")]
| ^
error: [note] this value...
--> $DIR/from_form_field.rs:41:21
--> tests/ui-fail-stable/from_form_field.rs:41:21
|
41 | #[field(value = "bar")]
| ^^^^^
error: [note] ...conflicts with this value
--> $DIR/from_form_field.rs:42:21
--> tests/ui-fail-stable/from_form_field.rs:42:21
|
42 | #[field(value = "bar")]
| ^^^^^
error: [note] error occurred while deriving `FromFormField`
--> $DIR/from_form_field.rs:39:10
--> tests/ui-fail-stable/from_form_field.rs:39:10
|
39 | #[derive(FromFormField)]
| ^^^^^^^^^^^^^
@ -137,25 +137,25 @@ error: [note] error occurred while deriving `FromFormField`
= note: this error originates in the derive macro `FromFormField` (in Nightly builds, run with -Z macro-backtrace for more info)
error: field value conflicts with previous value
--> $DIR/from_form_field.rs:50:21
--> tests/ui-fail-stable/from_form_field.rs:50:21
|
50 | #[field(value = "BAr")]
| ^^^^^
error: [help] ...declared in this variant
--> $DIR/from_form_field.rs:50:5
--> tests/ui-fail-stable/from_form_field.rs:50:5
|
50 | #[field(value = "BAr")]
| ^
error: [note] previous field with conflicting name
--> $DIR/from_form_field.rs:48:5
--> tests/ui-fail-stable/from_form_field.rs:48:5
|
48 | #[field(value = "bar")]
| ^
error: [note] error occurred while deriving `FromFormField`
--> $DIR/from_form_field.rs:46:10
--> tests/ui-fail-stable/from_form_field.rs:46:10
|
46 | #[derive(FromFormField)]
| ^^^^^^^^^^^^^
@ -163,25 +163,25 @@ error: [note] error occurred while deriving `FromFormField`
= note: this error originates in the derive macro `FromFormField` (in Nightly builds, run with -Z macro-backtrace for more info)
error: field value conflicts with previous value
--> $DIR/from_form_field.rs:57:21
--> tests/ui-fail-stable/from_form_field.rs:57:21
|
57 | #[field(value = "a")]
| ^^^
error: [help] ...declared in this variant
--> $DIR/from_form_field.rs:57:5
--> tests/ui-fail-stable/from_form_field.rs:57:5
|
57 | #[field(value = "a")]
| ^
error: [note] previous field with conflicting name
--> $DIR/from_form_field.rs:56:5
--> tests/ui-fail-stable/from_form_field.rs:56:5
|
56 | A,
| ^
error: [note] error occurred while deriving `FromFormField`
--> $DIR/from_form_field.rs:54:10
--> tests/ui-fail-stable/from_form_field.rs:54:10
|
54 | #[derive(FromFormField)]
| ^^^^^^^^^^^^^
@ -189,25 +189,25 @@ error: [note] error occurred while deriving `FromFormField`
= note: this error originates in the derive macro `FromFormField` (in Nightly builds, run with -Z macro-backtrace for more info)
error: variant has conflicting values
--> $DIR/from_form_field.rs:80:5
--> tests/ui-fail-stable/from_form_field.rs:80:5
|
80 | #[field(value = "FoO")]
| ^
error: [note] this value...
--> $DIR/from_form_field.rs:80:21
--> tests/ui-fail-stable/from_form_field.rs:80:21
|
80 | #[field(value = "FoO")]
| ^^^^^
error: [note] ...conflicts with this value
--> $DIR/from_form_field.rs:81:21
--> tests/ui-fail-stable/from_form_field.rs:81:21
|
81 | #[field(value = "foo")]
| ^^^^^
error: [note] error occurred while deriving `FromFormField`
--> $DIR/from_form_field.rs:78:10
--> tests/ui-fail-stable/from_form_field.rs:78:10
|
78 | #[derive(FromFormField)]
| ^^^^^^^^^^^^^
@ -215,25 +215,25 @@ error: [note] error occurred while deriving `FromFormField`
= note: this error originates in the derive macro `FromFormField` (in Nightly builds, run with -Z macro-backtrace for more info)
error: field has conflicting names
--> $DIR/from_form_field.rs:87:5
--> tests/ui-fail-stable/from_form_field.rs:87:5
|
87 | #[field(name = "foo")]
| ^
error: [note] this field name...
--> $DIR/from_form_field.rs:87:20
--> tests/ui-fail-stable/from_form_field.rs:87:20
|
87 | #[field(name = "foo")]
| ^^^^^
error: [note] ...conflicts with this field name
--> $DIR/from_form_field.rs:88:28
--> tests/ui-fail-stable/from_form_field.rs:88:28
|
88 | #[field(name = uncased("FOO"))]
| ^^^^^
error: [note] error occurred while deriving `FromForm`
--> $DIR/from_form_field.rs:85:10
--> tests/ui-fail-stable/from_form_field.rs:85:10
|
85 | #[derive(FromForm)]
| ^^^^^^^^
@ -241,25 +241,25 @@ error: [note] error occurred while deriving `FromForm`
= note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info)
error: field name conflicts with previous name
--> $DIR/from_form_field.rs:96:20
--> tests/ui-fail-stable/from_form_field.rs:96:20
|
96 | #[field(name = "foo")]
| ^^^^^
error: [help] declared in this field
--> $DIR/from_form_field.rs:96:5
--> tests/ui-fail-stable/from_form_field.rs:96:5
|
96 | #[field(name = "foo")]
| ^
error: [note] previous field with conflicting name
--> $DIR/from_form_field.rs:94:5
--> tests/ui-fail-stable/from_form_field.rs:94:5
|
94 | #[field(name = "foo")]
| ^
error: [note] error occurred while deriving `FromForm`
--> $DIR/from_form_field.rs:92:10
--> tests/ui-fail-stable/from_form_field.rs:92:10
|
92 | #[derive(FromForm)]
| ^^^^^^^^
@ -267,25 +267,25 @@ error: [note] error occurred while deriving `FromForm`
= note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info)
error: field name conflicts with previous name
--> $DIR/from_form_field.rs:104:5
--> tests/ui-fail-stable/from_form_field.rs:104:5
|
104 | hello_there: usize,
| ^^^^^^^^^^^
error: [help] declared in this field
--> $DIR/from_form_field.rs:104:5
--> tests/ui-fail-stable/from_form_field.rs:104:5
|
104 | hello_there: usize,
| ^^^^^^^^^^^
error: [note] previous field with conflicting name
--> $DIR/from_form_field.rs:102:5
--> tests/ui-fail-stable/from_form_field.rs:102:5
|
102 | #[field(name = uncased("HELLO_THERE"))]
| ^
error: [note] error occurred while deriving `FromForm`
--> $DIR/from_form_field.rs:100:10
--> tests/ui-fail-stable/from_form_field.rs:100:10
|
100 | #[derive(FromForm)]
| ^^^^^^^^
@ -293,25 +293,25 @@ error: [note] error occurred while deriving `FromForm`
= note: this error originates in the derive macro `FromForm` (in Nightly builds, run with -Z macro-backtrace for more info)
error: field name conflicts with previous name
--> $DIR/from_form_field.rs:111:5
--> tests/ui-fail-stable/from_form_field.rs:111:5
|
111 | hello_there: usize,
| ^^^^^^^^^^^
error: [help] declared in this field
--> $DIR/from_form_field.rs:111:5
--> tests/ui-fail-stable/from_form_field.rs:111:5
|
111 | hello_there: usize,
| ^^^^^^^^^^^
error: [note] previous field with conflicting name
--> $DIR/from_form_field.rs:109:5
--> tests/ui-fail-stable/from_form_field.rs:109:5
|
109 | #[field(name = "hello_there")]
| ^
error: [note] error occurred while deriving `FromForm`
--> $DIR/from_form_field.rs:107:10
--> tests/ui-fail-stable/from_form_field.rs:107:10
|
107 | #[derive(FromForm)]
| ^^^^^^^^

View File

@ -1,4 +1,4 @@
error: expected identifier
error: expected identifier, found keyword `_`
--> tests/ui-fail-stable/typed-uris-bad-params.rs:63:18
|
63 | uri!(ignored(_ = 10));

View File

@ -1,8 +1,8 @@
error: expected identifier
--> tests/ui-fail-stable/typed-uris-invalid-syntax.rs:10:28
error: unexpected token
--> tests/ui-fail-stable/typed-uris-invalid-syntax.rs:10:16
|
10 | uri!(simple: id = 100, "Hello");
| ^^^^^^^
| ^
error: named and unnamed parameters cannot be mixed
--> tests/ui-fail-stable/typed-uris-invalid-syntax.rs:11:17