diff --git a/third_party/rust/darling/.cargo-checksum.json b/third_party/rust/darling/.cargo-checksum.json index 25b465bc5b82..8090e3fc3eb4 100644 --- a/third_party/rust/darling/.cargo-checksum.json +++ b/third_party/rust/darling/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CHANGELOG.md":"06091817afa317ff86efb9aee3fa8d165358150a92c6369e4ab2958765c14af8","Cargo.toml":"3ec79fcbc682939731504a261f9f7a10afecdbbf298af8a10a9748abcb79172a","LICENSE":"8ea93490d74a5a1b1af3ff71d786271b3f1e5f0bea79ac16e02ec533cef040d6","README.md":"f70d772dd28cd14fc817c71d343b07ec8bfbe02dfe8d3e999a0185c6ef8731ec","examples/automatic_bounds.rs":"2716da31a5beed954da77866779ef77600686688a8890fefa7e23db628358104","examples/consume_fields.rs":"abcdd6a919a95a5c295e8d362db0367ab171fe3c8a80b23d83701765cd902d2d","examples/fallible_read.rs":"e06d5c045d3a47c0e00d3c77ed3aa1a1d5173d2c3f462dc1967379db3094af4c","examples/supports_struct.rs":"f2d84a4377e555ed7535e563c9593bd6a398a63b42f7da72381eea2fccec229f","publish.sh":"42795a155247c69402f8c4c917c9874a06dfde5a7606c8b59fc4e9ccd34233dd","src/lib.rs":"07da20edb52c4aba30f2b680b28ca96cf995859566b0db3b1d2e0ee967249a18","src/macros_public.rs":"3ed7eb99f309d9cd600d3a09ff4dcf5cc5d787fb49e8e5ead6bb00e31e5e6793","tests/accrue_errors.rs":"f873acf2a13dba88f508c3eb118d14e36515bf94b7ee914ddec2ae1eb55e381f","tests/computed_bound.rs":"2313da96a250b5948ca06bf86cb7158b55a59eba75334aa8ba27a46b28ede6b5","tests/custom_bound.rs":"4dd3e8fd76734d8f262e857773f53a820229ad6e10fe6fbbbe1f636c7da9eab0","tests/defaults.rs":"b544be90d18be26305a757e8468bf8735356889b59c167294d118e32ee7f82ea","tests/enums_newtype.rs":"723c761eab356f577e804a5e07f5efa244f70fb7525d20fceb1bc3852c8d742e","tests/enums_struct.rs":"e0097d7f947cf9e4612c9450c55ea5075c7f6fcbbf8cac7176449d92eebc9343","tests/enums_unit.rs":"8c075d5897b60b58cb71d6306e7fdd80851f5a147ae3010ba70ea100007364a3","tests/error.rs":"f989a43fad47d61d75da2bc78af6c51bac549f39f14f87a804eea226308ece32","tests/from_generics.rs":"79230ad21e8482cf6e6ceb0c74303bc0cdf77fbb951f46a6ba1006ecf1248fd5","tests/from_type_param.rs":"4369737a9d4c21cfa8595a9159cd5d98d02af3445d8b4085654ad4ce8e8bba3f","tests/from_type_param_default.rs":"a5ee72f22540004e755445c37dd4c425ef12beef496896d608695bae964afe7f","tests/from_variant.rs":"2e804326302a62b979eae963e88f0a2cdb6a21ee9667407c361d178f8c0aadba","tests/generics.rs":"3c0f43b39a8f319b8318e409d3836c7235892ae4f50f5986ea80f69b80a4080b","tests/happy_path.rs":"13cf6cd5f87920d90762fd08e45d9f0bb378563e1c92cf5ffb3ba78decdc4969","tests/multiple.rs":"b76172c396a89414b1669eec2bf854c79a7215fd3b6977123b81591ac6761670","tests/newtype.rs":"c45842fd764174a6a8177851e15445d344ab93bf2124b5f77213780d1306adea","tests/skip.rs":"fd936a5eff92c0a49b0a900e6fcda6b7a10a83dd4096ae2000201ccb3f66a738","tests/split_declaration.rs":"b191ed446bf7b8fdf1d41059354adb4b155523507f37b0d36aed3347617a2492","tests/supports.rs":"acb53d4d810dcd3e46763db13234e4fb42e425cfde2516d9bf5d7b690be72dcc"},"package":"f593353cad5af2df6d54810de2b61aa8acba5b5fbc70b0d75e7cc5bdd80aca73"} \ No newline at end of file +{"files":{"CHANGELOG.md":"111bee96e6baf82f8898ada5f5395888253832ed641fc6013ad803ac6afaeaf0","Cargo.toml":"66f4111240094e9fed78c1989fc56b30fb94a58f2465eb0eacbaf050cc027b81","LICENSE":"8ea93490d74a5a1b1af3ff71d786271b3f1e5f0bea79ac16e02ec533cef040d6","README.md":"05357355cb87aea0b5bda29ce9f6ef03331717cf351c6cf7554855f5d825756e","examples/automatic_bounds.rs":"dcac3391ed568475cea17ec64c324283f9771dce61adb0a0dd7b8a9ee0bf954d","examples/consume_fields.rs":"ebf4bd8baf4e54ccaa926f910957183d6a5b1decaa87ab5ebcca6c8d38b6c6b3","examples/fallible_read.rs":"aa9d1e0aaba8f3eb4580e94e133839f7eb77fca61beed254f3d5e0f6d6981f00","examples/supports_struct.rs":"d69124e09d3d6b8e04a3af07a6af96c5df7cbd3d6953a51657b39088cc2c2de7","src/lib.rs":"07da20edb52c4aba30f2b680b28ca96cf995859566b0db3b1d2e0ee967249a18","src/macros_public.rs":"3ed7eb99f309d9cd600d3a09ff4dcf5cc5d787fb49e8e5ead6bb00e31e5e6793","tests/accrue_errors.rs":"f5ac2d8cb0a12284a845d25b9472c4605aa5e8c1cd66a6dd6ad64f1c749b2caf","tests/computed_bound.rs":"2313da96a250b5948ca06bf86cb7158b55a59eba75334aa8ba27a46b28ede6b5","tests/custom_bound.rs":"4dd3e8fd76734d8f262e857773f53a820229ad6e10fe6fbbbe1f636c7da9eab0","tests/defaults.rs":"b544be90d18be26305a757e8468bf8735356889b59c167294d118e32ee7f82ea","tests/enums_newtype.rs":"a09af70072e566bee1f6cad91675f3553c47333e51a0e389ebb47ae82de776a8","tests/enums_struct.rs":"e0097d7f947cf9e4612c9450c55ea5075c7f6fcbbf8cac7176449d92eebc9343","tests/enums_unit.rs":"8c075d5897b60b58cb71d6306e7fdd80851f5a147ae3010ba70ea100007364a3","tests/error.rs":"465f7634fa23f0076c93a9c5fc16ccde16119b874d64c8dabaf275b6b7ae61f2","tests/from_generics.rs":"79230ad21e8482cf6e6ceb0c74303bc0cdf77fbb951f46a6ba1006ecf1248fd5","tests/from_type_param.rs":"7c97745cdcea18a2d6f51e4da7426055a078287bf9f2c93d487057195efa2b30","tests/from_type_param_default.rs":"80787ef6527e7f76c2aac93b1f35a006a9c5e0df8deed61698eaac1127278021","tests/from_variant.rs":"2e804326302a62b979eae963e88f0a2cdb6a21ee9667407c361d178f8c0aadba","tests/generics.rs":"e08aea8a8de8f03e3c243bde650e250defbe340cef3e4c06935b2b3e46d2a376","tests/happy_path.rs":"c32daa68e2becdc2d6204985a19b437cfb49d7f1680e890578f0760dc9749b77","tests/multiple.rs":"0391be49bab07771d7e37d35fe17f6d9bf1aa6dc57e2c0e5c0912ab8e043128f","tests/newtype.rs":"3f029724467abc7a33aaf7b6a1feb7b6898eba578576afff338e73deb9fd2b3b","tests/skip.rs":"604861aa4d1dfdc4e5f38f8261be19b7240c650eb493b64ce0178f54c24a8d2d","tests/split_declaration.rs":"f509390f88549164af9218f1e5b07564b169a4481a20b738432ffb03c517b599","tests/suggestions.rs":"0afb756949be876aaae76974f119be811c783fb134a54978ff0453c537ff3174","tests/supports.rs":"3b096c3d893bf8e76f70219bc276cbfe04529091e9e8652af140f0f1b3a91270"},"package":"9158d690bc62a3a57c3e45b85e4d50de2008b39345592c64efd79345c7e24be0"} \ No newline at end of file diff --git a/third_party/rust/darling/CHANGELOG.md b/third_party/rust/darling/CHANGELOG.md index 2ec5d8675b2b..7f91819becf9 100644 --- a/third_party/rust/darling/CHANGELOG.md +++ b/third_party/rust/darling/CHANGELOG.md @@ -1,5 +1,31 @@ # Changelog +## v0.8.6 (March 18, 2019) +- Added "did you mean" suggestions for unknown fields behind the `suggestions` flag [#60](https://github.com/TedDriggs/issues/60) +- Added `Error::unknown_field_with_alts` to support the suggestion use-case. +- Added `ast::Fields::len` and `ast::Fields::is_empty` methods. + +## v0.8.5 (February 4, 2019) +- Accept unquoted positive numeric literals [#52](https://github.com/TedDriggs/issues/52) +- Add `FromMeta` to the `syn::Lit` enum and its variants +- Improve error message for unexpected literal formats to not say "other" + +## v0.8.4 (February 4, 2019) +- Use `syn::Error` to provide precise errors before `proc_macro::Diagnostic` is available +- Add `diagnostics` feature flag to toggle between stable and unstable error backends +- Attach error information in more contexts +- Add `allow_unknown_fields` to support parsing the same attribute multiple times for different macros [#51](https://github.com/darling/issues/51) +- Proc-macro authors will now see better errors in `darling` attributes + +## v0.8.3 (January 21, 2019) +- Attach spans to errors in generated trait impls [#37](https://github.com/darling/issues/37) +- Attach spans to errors for types with provided bespoke implementations +- Deprecate `set_span` from 0.8.2, as spans should never be broadened after being initially set + +## v0.8.2 (January 17, 2019) +- Add spans to errors to make quality warnings and errors easy in darling. This is blocked on diagnostics stabilizing. +- Add `darling::util::SpannedValue` so proc-macro authors can remember position information alongside parsed values. + ## v0.8.0 - Update dependency on `syn` to 0.15 [#44](https://github.com/darling/pull/44). Thanks to @hcpl diff --git a/third_party/rust/darling/Cargo.toml b/third_party/rust/darling/Cargo.toml index 9a88e2393b49..0d9a0c2613ad 100644 --- a/third_party/rust/darling/Cargo.toml +++ b/third_party/rust/darling/Cargo.toml @@ -12,18 +12,19 @@ [package] name = "darling" -version = "0.8.1" +version = "0.8.6" authors = ["Ted Driggs "] +exclude = ["/.travis.yml", "/publish.sh"] description = "A proc-macro library for reading attributes into structs when\nimplementing custom derives.\n" -documentation = "https://docs.rs/darling/0.8.1" +documentation = "https://docs.rs/darling/0.8.6" readme = "README.md" license = "MIT" repository = "https://github.com/TedDriggs/darling" [dependencies.darling_core] -version = "=0.8.1" +version = "=0.8.6" [dependencies.darling_macro] -version = "=0.8.1" +version = "=0.8.6" [dev-dependencies.proc-macro2] version = "0.4" @@ -31,6 +32,10 @@ version = "0.4" version = "0.6" [dev-dependencies.syn] -version = "0.15" +version = "0.15.26" + +[features] +diagnostics = ["darling_core/diagnostics"] +suggestions = ["darling_core/suggestions"] [badges.travis-ci] repository = "TedDriggs/darling" diff --git a/third_party/rust/darling/README.md b/third_party/rust/darling/README.md index 9919e722236b..28d07cf43914 100644 --- a/third_party/rust/darling/README.md +++ b/third_party/rust/darling/README.md @@ -10,8 +10,9 @@ Darling `darling` provides a set of traits which can be derived or manually implemented. 1. `FromMeta` is used to extract values from a meta-item in an attribute. Implementations are likely reusable for many libraries, much like `FromStr` or `serde::Deserialize`. Trait implementations are provided for primitives, some std types, and some `syn` types. -1. `FromDeriveInput` is implemented or derived by each proc-macro crate which depends on `darling`. This is the root for input parsing; it gets access to the identity, generics, and visibility of the target type, and can specify which attribute names should be parsed or forwarded from the input AST. -1. `FromField` is implemented or derived by each proc-macro crate which depends on `darling`. Structs deriving this trait will get access to the identity (if it exists), type, and visibility of the field. +2. `FromDeriveInput` is implemented or derived by each proc-macro crate which depends on `darling`. This is the root for input parsing; it gets access to the identity, generics, and visibility of the target type, and can specify which attribute names should be parsed or forwarded from the input AST. +3. `FromField` is implemented or derived by each proc-macro crate which depends on `darling`. Structs deriving this trait will get access to the identity (if it exists), type, and visibility of the field. +4. `FromVariant` is implemented or derived by each proc-macro crate which depends on `darling`. Structs deriving this trait will get access to the identity and contents of the variant, which can be transformed the same as any other `darling` input. # Example @@ -46,6 +47,49 @@ The above code will then be able to parse this input: pub struct ConsumingType; ``` +# Attribute Macros +Non-derive attribute macros are supported. +To parse arguments for attribute macros, derive `FromMeta` on the argument receiver type, then pass `&syn::AttributeArgs` to the `from_list` method. +This will produce a normal `darling::Result` that can be used the same as a result from parsing a `DeriveInput`. + +## Macro Code +```rust,ignore +use darling::FromMeta; +use syn::{AttributeArgs, ItemFn}; +use proc_macro::TokenStream; + +#[derive(Debug, FromMeta)] +pub struct MacroArgs { + #[darling(default)] + timeout_ms: Option, + path: String, +} + +#[proc_macro_attribute] +fn your_attr(args: TokenStream, input: TokenStream) -> TokenStream { + let attr_args = parse_macro_input!(args as AttributeArgs); + let _input = parse_macro_input!(input as ItemFn); + + let _args = match MacroArgs::from_list(&attr_args) { + Ok(v) => v, + Err(e) => { return e.write_errors(); } + }; + + // do things with `args` + unimplemented!() +} +``` + +## Consuming Code +```rust,ignore +use your_crate::your_attr; + +#[your_attr(path = "hello", timeout_ms = 15)] +fn do_stuff() { + println!("Hello"); +} +``` + # Features Darling's features are built to work well for real-world projects. @@ -55,3 +99,4 @@ Darling's features are built to work well for real-world projects. * **Mapping function**: Use `#[darling(map="path")]` to specify a function that runs on the result of parsing a meta-item field. This can change the return type, which enables you to parse to an intermediate form and convert that to the type you need in your struct. * **Skip fields**: Use `#[darling(skip)]` to mark a field that shouldn't be read from attribute meta-items. * **Multiple-occurrence fields**: Use `#[darling(multiple)]` on a `Vec` field to allow that field to appear multiple times in the meta-item. Each occurrence will be pushed into the `Vec`. +* **Span access**: Use `darling::util::SpannedValue` in a struct to get access to that meta item's source code span. This can be used to emit warnings that point at a specific field from your proc macro. In addition, you can use `darling::Error::write_errors` to automatically get precise error location details in most cases. diff --git a/third_party/rust/darling/examples/automatic_bounds.rs b/third_party/rust/darling/examples/automatic_bounds.rs index 06263f147f71..0b9aec484f46 100644 --- a/third_party/rust/darling/examples/automatic_bounds.rs +++ b/third_party/rust/darling/examples/automatic_bounds.rs @@ -68,7 +68,8 @@ fn main() { Div(String) } "#, - ).unwrap(); + ) + .unwrap(); let parsed: SpeakingOptions = FromDeriveInput::from_derive_input(&derive_input).unwrap(); diff --git a/third_party/rust/darling/examples/consume_fields.rs b/third_party/rust/darling/examples/consume_fields.rs index d5602f303fec..4b0703f50764 100644 --- a/third_party/rust/darling/examples/consume_fields.rs +++ b/third_party/rust/darling/examples/consume_fields.rs @@ -64,7 +64,8 @@ impl ToTokens for MyInputReceiver { } = *self; let (imp, ty, wher) = generics.split_for_impl(); - let fields = data.as_ref() + let fields = data + .as_ref() .take_struct() .expect("Should never be enum") .fields; diff --git a/third_party/rust/darling/examples/fallible_read.rs b/third_party/rust/darling/examples/fallible_read.rs index 04d573cefa2f..c487854336ed 100644 --- a/third_party/rust/darling/examples/fallible_read.rs +++ b/third_party/rust/darling/examples/fallible_read.rs @@ -4,7 +4,6 @@ //! 1. Using `darling::Result` as a carrier to preserve the error for later display //! 1. Using `Result` to attempt a recovery in imperative code //! 1. Using the `map` darling meta-item to post-process the receiver before returning. - #[macro_use] extern crate darling; @@ -58,8 +57,8 @@ impl MyInputReceiver { }; Self { - name: name, - frequency: frequency, + name, + frequency, amplitude: Ok(amplitude), } } diff --git a/third_party/rust/darling/examples/supports_struct.rs b/third_party/rust/darling/examples/supports_struct.rs index b76b4b707dab..dbf8238a9db9 100644 --- a/third_party/rust/darling/examples/supports_struct.rs +++ b/third_party/rust/darling/examples/supports_struct.rs @@ -37,8 +37,7 @@ pub struct Foo { let parsed = syn::parse_str(good_input).unwrap(); let receiver = Lorem::from_derive_input(&parsed).unwrap(); let wrong_shape_parsed = syn::parse_str(bad_input).unwrap(); - let wrong_shape = Lorem::from_derive_input(&wrong_shape_parsed) - .expect_err("Shape was wrong"); + let wrong_shape = Lorem::from_derive_input(&wrong_shape_parsed).expect_err("Shape was wrong"); println!( r#" diff --git a/third_party/rust/darling/publish.sh b/third_party/rust/darling/publish.sh deleted file mode 100755 index 6531b7039287..000000000000 --- a/third_party/rust/darling/publish.sh +++ /dev/null @@ -1,3 +0,0 @@ -cargo publish --manifest-path core/Cargo.toml; -cargo publish --manifest-path macro/Cargo.toml; -cargo publish; \ No newline at end of file diff --git a/third_party/rust/darling/tests/accrue_errors.rs b/third_party/rust/darling/tests/accrue_errors.rs index 44ba7d908ddb..9ae8212765b8 100644 --- a/third_party/rust/darling/tests/accrue_errors.rs +++ b/third_party/rust/darling/tests/accrue_errors.rs @@ -3,7 +3,10 @@ #[macro_use] extern crate darling; +#[macro_use] extern crate syn; +#[macro_use] +extern crate quote; use darling::ast; use darling::FromDeriveInput; @@ -30,17 +33,14 @@ struct LoremField { #[test] fn bad_type_and_missing_fields() { - let input = syn::parse_str( - r#" - #[accrue(ipsum = true, dolor(amet = "Hi"))] - pub struct NonConforming { - foo: () - } - "#, - ).unwrap(); + let input = parse_quote! { + #[accrue(ipsum = true, dolor(amet = "Hi"))] + pub struct NonConforming { + foo: () + } + }; let s_result: ::darling::Error = Lorem::from_derive_input(&input).unwrap_err(); - //assert_eq!(3, s_result.len()); let err = s_result.flatten(); println!("{}", err); assert_eq!(3, err.len()); @@ -48,17 +48,15 @@ fn bad_type_and_missing_fields() { #[test] fn body_only_issues() { - let input = syn::parse_str( - r#" - #[accrue(ipsum = "Hello", dolor(sit))] - pub struct NonConforming { - foo: (), - bar: bool, - } - "#, - ).unwrap(); + let input = parse_quote! { + #[accrue(ipsum = "Hello", dolor(sit))] + pub struct NonConforming { + foo: (), + bar: bool, + } + }; - let s_err: ::darling::Error = Lorem::from_derive_input(&input).unwrap_err(); + let s_err = Lorem::from_derive_input(&input).unwrap_err(); println!("{:?}", s_err); assert_eq!(2, s_err.len()); } @@ -78,17 +76,15 @@ struct Month { #[test] fn error_in_enum_fields() { - let input = syn::parse_str( - r#" - #[accrue(schedule(tuesday(morning = "yes")))] - pub struct NonConforming { - foo: (), - bar: bool, - } - "#, - ).unwrap(); + let input = parse_quote! { + #[accrue(schedule(tuesday(morning = "yes")))] + pub struct NonConforming { + foo: (), + bar: bool, + } + }; - let s_err: ::darling::Error = Month::from_derive_input(&input).unwrap_err(); + let s_err = Month::from_derive_input(&input).unwrap_err(); assert_eq!(2, s_err.len()); let err = s_err.flatten(); // TODO add tests to check location path is correct @@ -97,17 +93,15 @@ fn error_in_enum_fields() { #[test] fn error_in_newtype_variant() { - let input = syn::parse_str( - r#" - #[accrue(schedule(wednesday(sit = "yes")))] - pub struct NonConforming { - foo: (), - bar: bool, - } - "#, - ).unwrap(); + let input = parse_quote! { + #[accrue(schedule(wednesday(sit = "yes")))] + pub struct NonConforming { + foo: (), + bar: bool, + } + }; - let s_err: ::darling::Error = Month::from_derive_input(&input).unwrap_err(); + let s_err = Month::from_derive_input(&input).unwrap_err(); assert_eq!(1, s_err.len()); println!("{}", s_err); println!("{}", s_err.flatten()); diff --git a/third_party/rust/darling/tests/enums_newtype.rs b/third_party/rust/darling/tests/enums_newtype.rs index f17d33e5654b..0fd12f03fc77 100644 --- a/third_party/rust/darling/tests/enums_newtype.rs +++ b/third_party/rust/darling/tests/enums_newtype.rs @@ -1,10 +1,12 @@ #[macro_use] extern crate darling; +#[macro_use] +extern crate syn; +#[macro_use] +extern crate quote; use darling::FromDeriveInput; -extern crate syn; - #[derive(Debug, Default, PartialEq, Eq, FromMeta)] #[darling(default)] pub struct Amet { @@ -34,12 +36,10 @@ impl PartialEq for Holder { #[test] fn bool_word() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[hello(lorem(ipsum))] pub struct Bar; - "#, - ).unwrap(); + }; let pr = Holder::from_derive_input(&di).unwrap(); assert_eq!(pr, Lorem::Ipsum(true)); @@ -47,12 +47,10 @@ fn bool_word() { #[test] fn bool_literal() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[hello(lorem(ipsum = false))] pub struct Bar; - "#, - ).unwrap(); + }; let pr = Holder::from_derive_input(&di).unwrap(); assert_eq!(pr, Lorem::Ipsum(false)); @@ -60,12 +58,10 @@ fn bool_literal() { #[test] fn string_literal() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[hello(lorem(dolor = "Hello"))] pub struct Bar; - "#, - ).unwrap(); + }; let pr = Holder::from_derive_input(&di).unwrap(); assert_eq!(pr, Lorem::Dolor("Hello".to_string())); @@ -73,12 +69,10 @@ fn string_literal() { #[test] fn struct_nested() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[hello(lorem(sit(world = "Hello", hello = false)))] pub struct Bar; - "#, - ).unwrap(); + }; let pr = Holder::from_derive_input(&di).unwrap(); assert_eq!( @@ -93,12 +87,10 @@ fn struct_nested() { #[test] #[should_panic] fn format_mismatch() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[hello(lorem(dolor(world = "Hello", hello = false)))] pub struct Bar; - "#, - ).unwrap(); + }; Holder::from_derive_input(&di).unwrap(); } diff --git a/third_party/rust/darling/tests/error.rs b/third_party/rust/darling/tests/error.rs index 6da666951fb7..edd72eb1dd97 100644 --- a/third_party/rust/darling/tests/error.rs +++ b/third_party/rust/darling/tests/error.rs @@ -1,7 +1,10 @@ //! In case of bad input, parsing should fail. The error should have locations set in derived implementations. #[macro_use] extern crate darling; +#[macro_use] extern crate syn; +#[macro_use] +extern crate quote; use darling::FromDeriveInput; @@ -33,24 +36,20 @@ impl From for Lorem { #[test] fn parsing_fail() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[hello(ipsum(amet = "yes", world = false))] pub struct Foo; - "#, - ).unwrap(); + }; println!("{}", Lorem::from_derive_input(&di).unwrap_err()); } #[test] fn missing_field() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[hello(ipsum(amet = true))] pub struct Foo; - "#, - ).unwrap(); + }; println!("{}", Lorem::from_derive_input(&di).unwrap_err()); } diff --git a/third_party/rust/darling/tests/from_type_param.rs b/third_party/rust/darling/tests/from_type_param.rs index ebd7e3e269ba..adaf34dd3868 100644 --- a/third_party/rust/darling/tests/from_type_param.rs +++ b/third_party/rust/darling/tests/from_type_param.rs @@ -1,6 +1,9 @@ #[macro_use] extern crate darling; +#[macro_use] extern crate syn; +#[macro_use] +extern crate quote; use darling::FromTypeParam; use syn::{DeriveInput, GenericParam, Ident, TypeParam}; @@ -34,14 +37,13 @@ fn extract_type(param: &GenericParam) -> &TypeParam { #[test] fn expand_many() { - let di: DeriveInput = syn::parse_str( - r#" + let di: DeriveInput = parse_quote! { struct Baz< #[lorem(foo)] T, #[lorem(bar = "x")] U: Eq + ?Sized >(T, U); - "#, - ).unwrap(); + }; + let params = di.generics.params; { diff --git a/third_party/rust/darling/tests/from_type_param_default.rs b/third_party/rust/darling/tests/from_type_param_default.rs index df24de08892a..eb0ecc766cca 100644 --- a/third_party/rust/darling/tests/from_type_param_default.rs +++ b/third_party/rust/darling/tests/from_type_param_default.rs @@ -1,6 +1,9 @@ #[macro_use] extern crate darling; +#[macro_use] extern crate syn; +#[macro_use] +extern crate quote; use darling::FromTypeParam; use syn::{DeriveInput, GenericParam, TypeParam}; @@ -22,15 +25,13 @@ fn extract_type(param: &GenericParam) -> &TypeParam { #[test] fn expand_many() { - let di: DeriveInput = syn::parse_str( - r#" + let di: DeriveInput = parse_quote! { struct Baz< #[lorem(foo)] T, #[lorem(bar = "x")] U: Eq + ?Sized, #[lorem(foo = false)] V = (), >(T, U, V); - "#, - ).unwrap(); + }; let params = di.generics.params; { diff --git a/third_party/rust/darling/tests/generics.rs b/third_party/rust/darling/tests/generics.rs index c268f56c0f6b..a83d03e284b7 100644 --- a/third_party/rust/darling/tests/generics.rs +++ b/third_party/rust/darling/tests/generics.rs @@ -1,6 +1,9 @@ #[macro_use] extern crate darling; +#[macro_use] extern crate syn; +#[macro_use] +extern crate quote; use darling::FromDeriveInput; @@ -15,12 +18,10 @@ struct Foo { #[test] fn expansion() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[hello(lorem = "Hello")] pub struct Foo; - "#, - ).unwrap(); + }; - let _parsed = Foo::::from_derive_input(&di).unwrap(); + Foo::::from_derive_input(&di).unwrap(); } diff --git a/third_party/rust/darling/tests/happy_path.rs b/third_party/rust/darling/tests/happy_path.rs index d5d7b54fb9fa..df1bfadd754f 100644 --- a/third_party/rust/darling/tests/happy_path.rs +++ b/third_party/rust/darling/tests/happy_path.rs @@ -1,6 +1,5 @@ #[macro_use] extern crate darling; - #[macro_use] extern crate syn; #[macro_use] @@ -34,13 +33,11 @@ struct TraitCore { #[test] fn simple() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[derive(Foo)] #[darling_demo(lorem(ipsum))] pub struct Bar; - "#, - ).unwrap(); + }; assert_eq!( Core::from_derive_input(&di).unwrap(), @@ -58,13 +55,11 @@ fn simple() { #[test] fn trait_type() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[derive(Foo)] #[darling_demo(lorem(dolor = "hello"))] pub struct Bar; - "#, - ).unwrap(); + }; assert_eq!( TraitCore::from_derive_input(&di).unwrap(), diff --git a/third_party/rust/darling/tests/multiple.rs b/third_party/rust/darling/tests/multiple.rs index 111c1f402a6b..e70528063352 100644 --- a/third_party/rust/darling/tests/multiple.rs +++ b/third_party/rust/darling/tests/multiple.rs @@ -1,6 +1,9 @@ #[macro_use] extern crate darling; +#[macro_use] extern crate syn; +#[macro_use] +extern crate quote; use darling::FromDeriveInput; @@ -20,12 +23,10 @@ struct Ipsum { #[test] fn expand_many() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[hello(ipsum(dolor = "Hello", dolor = "World"))] pub struct Baz; - "#, - ).unwrap(); + }; let lorem: Lorem = Lorem::from_derive_input(&di).unwrap(); assert_eq!( diff --git a/third_party/rust/darling/tests/newtype.rs b/third_party/rust/darling/tests/newtype.rs index 16cb95994b0f..5219d9ad93e0 100644 --- a/third_party/rust/darling/tests/newtype.rs +++ b/third_party/rust/darling/tests/newtype.rs @@ -2,8 +2,10 @@ #[macro_use] extern crate darling; - +#[macro_use] extern crate syn; +#[macro_use] +extern crate quote; use darling::FromDeriveInput; @@ -18,13 +20,11 @@ struct DemoContainer { #[test] fn generated() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[derive(Baz)] #[newtype(lorem = false)] pub struct Foo; - "#, - ).unwrap(); + }; let c = DemoContainer::from_derive_input(&di).unwrap(); diff --git a/third_party/rust/darling/tests/skip.rs b/third_party/rust/darling/tests/skip.rs index a46dbfdda21b..b4e0f64dc13a 100644 --- a/third_party/rust/darling/tests/skip.rs +++ b/third_party/rust/darling/tests/skip.rs @@ -2,7 +2,10 @@ #[macro_use] extern crate darling; +#[macro_use] extern crate syn; +#[macro_use] +extern crate quote; use darling::FromDeriveInput; @@ -34,12 +37,10 @@ pub enum Sit { #[test] fn verify_skipped_field_not_required() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[skip_test(ipsum = "Hello")] struct Baz; - "#, - ).unwrap(); + }; assert_eq!( Lorem::from_derive_input(&di).unwrap(), diff --git a/third_party/rust/darling/tests/split_declaration.rs b/third_party/rust/darling/tests/split_declaration.rs index 5eb492a34aae..23d458d17371 100644 --- a/third_party/rust/darling/tests/split_declaration.rs +++ b/third_party/rust/darling/tests/split_declaration.rs @@ -3,7 +3,10 @@ #[macro_use] extern crate darling; +#[macro_use] extern crate syn; +#[macro_use] +extern crate quote; use std::string::ToString; @@ -18,13 +21,11 @@ struct Lorem { #[test] fn split_attributes_accrue_to_instance() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[split(foo = "Hello")] #[split(bar)] pub struct Foo; - "#, - ).unwrap(); + }; let parsed = Lorem::from_derive_input(&di).unwrap(); assert_eq!( @@ -38,39 +39,37 @@ fn split_attributes_accrue_to_instance() { #[test] fn duplicates_across_split_attrs_error() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[split(foo = "Hello")] #[split(foo = "World", bar)] pub struct Foo; - "#, - ).unwrap(); + }; - let pr = Lorem::from_derive_input(&di); + let pr = Lorem::from_derive_input(&di).unwrap_err(); + assert!(pr.has_span()); assert_eq!( - pr.unwrap_err().to_string(), + pr.to_string(), Error::duplicate_field("foo").to_string() ); } #[test] fn multiple_errors_accrue_to_instance() { - let di = syn::parse_str( - r#" + let di = parse_quote! { #[split(foo = "Hello")] #[split(foo = "World")] pub struct Foo; - "#, - ).unwrap(); + }; let pr = Lorem::from_derive_input(&di); let err: Error = pr.unwrap_err(); assert_eq!(2, err.len()); - let mut errs = err.into_iter(); + let mut errs = err.into_iter().peekable(); assert_eq!( - errs.next().unwrap().to_string(), + errs.peek().unwrap().to_string(), Error::duplicate_field("foo").to_string() ); + assert!(errs.next().unwrap().has_span()); assert_eq!( errs.next().unwrap().to_string(), Error::missing_field("bar").to_string() diff --git a/third_party/rust/darling/tests/suggestions.rs b/third_party/rust/darling/tests/suggestions.rs new file mode 100644 index 000000000000..3499e9ed9ad6 --- /dev/null +++ b/third_party/rust/darling/tests/suggestions.rs @@ -0,0 +1,34 @@ +#![cfg(feature = "suggestions")] + +#[macro_use] +extern crate darling; +#[macro_use] +extern crate syn; +#[macro_use] +extern crate quote; + +use darling::FromDeriveInput; + +#[derive(Debug, FromDeriveInput)] +#[darling(attributes(suggest))] +struct Lorem { + ipsum: String, + dolor: Dolor, +} + +#[derive(Debug, FromMeta)] +struct Dolor { + sit: bool, +} + +#[test] +fn suggest_dolor() { + let input: syn::DeriveInput = parse_quote! { + #[suggest(ipsum = "Hello", dolorr(sit))] + pub struct Foo; + }; + + let result = Lorem::from_derive_input(&input).unwrap_err(); + assert_eq!(2, result.len()); + assert!(format!("{}", result).contains("Did you mean")); +} diff --git a/third_party/rust/darling/tests/supports.rs b/third_party/rust/darling/tests/supports.rs index 0681a5f7b42a..9408a49da8dc 100644 --- a/third_party/rust/darling/tests/supports.rs +++ b/third_party/rust/darling/tests/supports.rs @@ -1,6 +1,9 @@ #[macro_use] extern crate darling; +#[macro_use] extern crate syn; +#[macro_use] +extern crate quote; use darling::ast; use darling::FromDeriveInput; @@ -28,41 +31,35 @@ mod source { use syn::{self, DeriveInput}; pub fn newtype_enum() -> DeriveInput { - syn::parse_str( - r#" - enum Hello { - World(bool), - String(String), + parse_quote!{ + enum Hello { + World(bool), + String(String), + } } - "#, - ).unwrap() } pub fn named_field_enum() -> DeriveInput { - syn::parse_str( - r#" - enum Hello { - Foo(u16), - World { - name: String - }, + parse_quote! { + enum Hello { + Foo(u16), + World { + name: String + }, + } } - "#, - ).unwrap() } pub fn named_struct() -> DeriveInput { - syn::parse_str( - r#" - struct Hello { - world: bool, + parse_quote! { + struct Hello { + world: bool, + } } - "#, - ).unwrap() } pub fn tuple_struct() -> DeriveInput { - syn::parse_str("struct Hello(String, bool);").unwrap() + parse_quote! { struct Hello(String, bool); } } } diff --git a/third_party/rust/darling_core/.cargo-checksum.json b/third_party/rust/darling_core/.cargo-checksum.json index bb0f5aa9cd8c..dd18c0525ced 100644 --- a/third_party/rust/darling_core/.cargo-checksum.json +++ b/third_party/rust/darling_core/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"b24c1abec4095a1afce8e302bc39f9de6027b55b0c308fb6b8bc4d684f6c2577","src/ast/data.rs":"c95e469d870f7918e77707da0e9e5e945e205e640bf34637355ef863b6efb28f","src/ast/generics.rs":"3bdfe1abdbee64f5aaa9b189dc5c58e222568f196ed206e9d6d91ea5f29673e7","src/ast/mod.rs":"58a58eeb1db7682e5994732cc8eb04088f6ca662805460ef443cf089e5c24e2c","src/codegen/attr_extractor.rs":"d13a3ba16f3a93f4a540421bb9df54a8f74cc6ee0e9e769b78b6c8045f285408","src/codegen/default_expr.rs":"60f23b77ddf80da70ec92fd0d8cb5a97143535df85eafa0e47943ac797ec46d2","src/codegen/error.rs":"50d0a1a2a392560ca10d3eb622ba745612761bf18846404742bd30caf2436228","src/codegen/field.rs":"d8b20dd1dda2c5591f5dcd4a2e5b8442ffae3daa23378323a81a682637080ea1","src/codegen/from_derive_impl.rs":"2a1e331d205db9334218b800760afcb64539fa2b25b0b2b014586b49b5b25882","src/codegen/from_field.rs":"af6f848ed7c6d2274e15d6307b011a1b8bcba66172ef68b0e665c9b4ae85157d","src/codegen/from_meta_impl.rs":"a937808b081e5d8bd16020fea8da0461e7e45872516cc0ee9e8a8cc957858a76","src/codegen/from_type_param.rs":"48493227f4a81fe1a533bd958b89207d56b1c70f754a2a28fb0e9eb9114a9aeb","src/codegen/from_variant_impl.rs":"3d9b10d60e3eb969946bbd210ce93a43375b9c8d3ffa827c7e87ab9235e2c3f3","src/codegen/mod.rs":"2dc3ee7f18177b2ef9c27c4f0cabc5bbd49f970abdba28a0539d81c70d81b6e2","src/codegen/outer_from_impl.rs":"059c3c05e4d6c7ba3876d23855ccbffa9e6158e7af7f6dc619b4d9770587f161","src/codegen/trait_impl.rs":"0e479f9e5b7253a3da2f77fd0bd63ea44a08a27dba2bd7dd992f05dc40b1d2a2","src/codegen/variant.rs":"3bc37ceb0e3dbf7eb02d7b66178adb3b165a24e92afa3295c012cf2f091d7328","src/codegen/variant_data.rs":"2467651663bfbb0ab35370b421d456948b053c26d0a23581a6c91ae7789b2db3","src/error.rs":"77436dc9a30172e94c434bdb61e3620ce37b2d64848a4fa19daba6e9c9329c95","src/from_derive_input.rs":"b2a04fefa4e14684061c819387ea0384297c67c7f50d5d0959aa69ab19075e76","src/from_field.rs":"f667924422ab4ab8d8b16ebfd42f61e74864cfaa80e96b49de5d1e1287e3d1d3","src/from_generic_param.rs":"49c5a8335eb0a9010998c5600c95c89440f7febe03265afb625d818dbc883d92","src/from_generics.rs":"7285b0fd213507e87c1da413cd1bc9eeada485d4a8f9d19630848d02a4d41c4a","src/from_meta.rs":"daa3d9a82b2f659147572f7d0e7fdef38139583e61e8319986098a4a73106453","src/from_type_param.rs":"9b611f276871002ade78146266fde3b6f9101b360082681a2fa2dafc16431f84","src/from_variant.rs":"70a23b5b4cb93c7e5a498fe9d16420b9b93bd69c1376d7703bc7cefd9417d159","src/lib.rs":"ea8f2d28793e4c0e367c4905e55e405417fbee9eb7ef0577f883b91aee1b5a57","src/macros_private.rs":"ef249cd9ca593aac423b4242df1c39c31610438da094c21562d74a7e5823c700","src/macros_public.rs":"3ed7eb99f309d9cd600d3a09ff4dcf5cc5d787fb49e8e5ead6bb00e31e5e6793","src/options/core.rs":"2dfb29a85a68d5ed6dccc46fe521c46ea8483bcd5d73cf21dbf21a7163ec318a","src/options/forward_attrs.rs":"89d8294a2204d6c32e5f58b797c23f4b035a8ff424bcf1b1c7db973ada89a4bc","src/options/from_derive.rs":"c8e41d2779e570dadd76c28b9cc9dd9cee57d8ef027766b4b5f39460a29df5d1","src/options/from_field.rs":"0b06590092a5c13d5c8eedf4e2d0518d869206813f828a06c65605d6cb8decc4","src/options/from_meta.rs":"ef268f78480f1d3df4e56cbc630aa4013ab5128cbb4471c4e85e9ff5a3980e7b","src/options/from_type_param.rs":"80d1fa60bac5bb31d0895e321faf1b8af99e407d9594028a01704b424be1dd4c","src/options/from_variant.rs":"99d4b60e48f8feef9c1fc2414ac0a420e66551c14e40c4a718668cca8e1f8cb5","src/options/input_field.rs":"f5e2529cfef4255710b9596c10422d7e7161978de93693cd25966eaebd7b5aee","src/options/input_variant.rs":"e0878260b04260a982f1de2de25159a38a338e67285f47da5e3eb8de2f60b68e","src/options/mod.rs":"30aefb531716954bad2b484c321baa333ef1d7d07ca55a0430df26bf4c1afb15","src/options/outer_from.rs":"e60196f2b9ea3ae014eaf3444607c6cf2a227c8d8aa4a5d64f59454602a0a5e6","src/options/shape.rs":"841e5cacfc40df74cd34c1dfc6895a99a21df79f48375de539d06bc15aec2248","src/usage/generics_ext.rs":"340774fe43033680e6b494c76dd4f558ada7ca4f09e91f9e4d076f125a729fc2","src/usage/ident_set.rs":"30edb2f0a599284967e3c6b579da31e5f9b15f3dd67bc9a82d6335eb44133df0","src/usage/lifetimes.rs":"19a63490660eb416bbccd4be9c060079a630dd15d5fd23c39e3c6c8c5498e369","src/usage/mod.rs":"bcf0ffb2257aed3b7b2cdad91c0136743384f39ff8f61f25c195c73b8fcdf144","src/usage/options.rs":"0491c995aad0d55783b24cce8a4e40f0f4435988c54ce2ded34763ac9b199fcf","src/usage/type_params.rs":"5aecf7f89c4b0623010e4717f5b32388b06d15e8511fde7b72f1d72e88fd3cb0","src/util/ident_list.rs":"fb6314436435547c111539213b209abd8d2593c28331560b84468a03b52d7c44","src/util/ident_string.rs":"06441e502d3bad342e292e42d083aff9070735a93d45f204aee5ef5f0144fdd0","src/util/ignored.rs":"7c979fbef880498ff64efda7396e759d80bf77fb1c7df0313bed8e533a16c0e0","src/util/mod.rs":"027793775e7079ea425f45b9bdad8b8fa309defcee02bf8ee6b6c556ec016342","src/util/over_ride.rs":"e90b3aeb41dd3364753f3ee6f8c6bbd85bf51d51569bf048396ec6e7735c569f","src/util/with_original.rs":"a545b38ba9d624fdc939eb844f001b7fc4102717b1d3683b4cbd0aae00fa7ef2"},"package":"168c246e87e727d58575d9b4595491010627f0cdc910e3e6ea3b36db2b9a9d9a"} \ No newline at end of file +{"files":{"Cargo.toml":"1b000960f407d3a318f55d3dd742f2ca5ddb7f7b3b1cb370023970bdc3072e64","LICENSE":"8ea93490d74a5a1b1af3ff71d786271b3f1e5f0bea79ac16e02ec533cef040d6","src/ast/data.rs":"560a0b89a93b7839317abb2e7e3bc0af93f40ce476c4a8a706ae0ad0fd240bb8","src/ast/generics.rs":"3bdfe1abdbee64f5aaa9b189dc5c58e222568f196ed206e9d6d91ea5f29673e7","src/ast/mod.rs":"58a58eeb1db7682e5994732cc8eb04088f6ca662805460ef443cf089e5c24e2c","src/codegen/attr_extractor.rs":"439950febbf04b139b578eb75ad70e1529a2bd6e5480f936e08770e9e354d9ac","src/codegen/default_expr.rs":"60f23b77ddf80da70ec92fd0d8cb5a97143535df85eafa0e47943ac797ec46d2","src/codegen/error.rs":"1a415136f93adde7458e39cab91413adc9a64243b718c7b74fdeba748959b5af","src/codegen/field.rs":"82104df8f3e733b23764fd6683e60d24ce62912b8b29a22dadbbc55d6a42f158","src/codegen/from_derive_impl.rs":"2a1e331d205db9334218b800760afcb64539fa2b25b0b2b014586b49b5b25882","src/codegen/from_field.rs":"af6f848ed7c6d2274e15d6307b011a1b8bcba66172ef68b0e665c9b4ae85157d","src/codegen/from_meta_impl.rs":"f769e1288aaa218303c987a2fba9286b93a104106fba63277e134ce19cd1047c","src/codegen/from_type_param.rs":"48493227f4a81fe1a533bd958b89207d56b1c70f754a2a28fb0e9eb9114a9aeb","src/codegen/from_variant_impl.rs":"3d9b10d60e3eb969946bbd210ce93a43375b9c8d3ffa827c7e87ab9235e2c3f3","src/codegen/mod.rs":"2dc3ee7f18177b2ef9c27c4f0cabc5bbd49f970abdba28a0539d81c70d81b6e2","src/codegen/outer_from_impl.rs":"9a91e67986787df1e0249559dd287e87b6fbfd757bd5f2632f43777b14a7d690","src/codegen/trait_impl.rs":"48080df3d025be7782604e883c46d53bcd62ea301dac379a36b27ce7e270e56c","src/codegen/variant.rs":"69ee861a63e31feb158611e93d0a355fdd94d6c8f3adc6c550864b7f5906d0ba","src/codegen/variant_data.rs":"2baa4328f01f6cdff008538a1492eb9fb5af2a88883a816ae6da7db3dc67b39e","src/derive.rs":"89180c13798b61510a6d266781e065114b75ca0be27e172a24656347b9baf1d3","src/error/kind.rs":"877f025ff72839ede46b8c7460331dac32ec56a7539816820179110381f8d0fb","src/error/mod.rs":"9908925c5798d81f34961c17aef8838d0730d825105bb9a8fa95e3958f25eda5","src/from_derive_input.rs":"b2a04fefa4e14684061c819387ea0384297c67c7f50d5d0959aa69ab19075e76","src/from_field.rs":"f667924422ab4ab8d8b16ebfd42f61e74864cfaa80e96b49de5d1e1287e3d1d3","src/from_generic_param.rs":"49c5a8335eb0a9010998c5600c95c89440f7febe03265afb625d818dbc883d92","src/from_generics.rs":"7285b0fd213507e87c1da413cd1bc9eeada485d4a8f9d19630848d02a4d41c4a","src/from_meta.rs":"d3847786280239d5e4260e2b88cb9986cb6feaaa1d3a2e2fb0678956eb936363","src/from_type_param.rs":"9b611f276871002ade78146266fde3b6f9101b360082681a2fa2dafc16431f84","src/from_variant.rs":"70a23b5b4cb93c7e5a498fe9d16420b9b93bd69c1376d7703bc7cefd9417d159","src/lib.rs":"ff9d4957c48641e9a63f18fe83d1153ea01994ebad93d1d905cc76d5fa58d3c9","src/macros_private.rs":"ef249cd9ca593aac423b4242df1c39c31610438da094c21562d74a7e5823c700","src/macros_public.rs":"3ed7eb99f309d9cd600d3a09ff4dcf5cc5d787fb49e8e5ead6bb00e31e5e6793","src/options/core.rs":"925a95513f7a6b9121f63998b1195f52f3bb9d76341ffa7544520443c77d9fe4","src/options/forward_attrs.rs":"89d8294a2204d6c32e5f58b797c23f4b035a8ff424bcf1b1c7db973ada89a4bc","src/options/from_derive.rs":"a53c5c991b5e25fdff47e9cb3f3f5aa48020e931546e7851bbd0711f98e9084c","src/options/from_field.rs":"67f338df3ffc270b3baf08b35cbe985802a65c1360c4e540cc5b937f6f08f915","src/options/from_meta.rs":"81a2ae765d390f64fbcbb1d30d40e895d77f8cd4f4c5f7167b1eacb48e066195","src/options/from_type_param.rs":"d3c8add6c8f5f7ee3d4a487c53e1f85002a2da43b943c03d4ce856fa6e7c8453","src/options/from_variant.rs":"84bd6294ebefe128c755f4cce1ef10117535435d4a2f631125b8d59170677cb4","src/options/input_field.rs":"094ef2865bbfba00e6894463f3440f523c3d1c53f938a414b23f9c78f7b1e01d","src/options/input_variant.rs":"6760a47a1d415b29c54202255a3937dd743e9e247cd8fe31767124b8b01d06db","src/options/mod.rs":"8fe5c94c3999d210cb024c6f6b181da92a0cc1a4a862e5d46ec49904c6692e11","src/options/outer_from.rs":"e60196f2b9ea3ae014eaf3444607c6cf2a227c8d8aa4a5d64f59454602a0a5e6","src/options/shape.rs":"c177cabcbee698351af6f7f3f9e848381197e041ed1628f0324e5cf52fd218f5","src/usage/generics_ext.rs":"340774fe43033680e6b494c76dd4f558ada7ca4f09e91f9e4d076f125a729fc2","src/usage/ident_set.rs":"30edb2f0a599284967e3c6b579da31e5f9b15f3dd67bc9a82d6335eb44133df0","src/usage/lifetimes.rs":"6ac25eb43b291414c274785d26912b0213e0b1d0d29d722cd4ffd915d4a58709","src/usage/mod.rs":"bcf0ffb2257aed3b7b2cdad91c0136743384f39ff8f61f25c195c73b8fcdf144","src/usage/options.rs":"0491c995aad0d55783b24cce8a4e40f0f4435988c54ce2ded34763ac9b199fcf","src/usage/type_params.rs":"0f4376ee9322d2c319ae15f41223595c72cb8a453a097879c2a0ee7f602c2f8c","src/util/ident_list.rs":"ea5f0419d7cb7fe6eb517ed2d3d2e0b00e1c7203be690157641f451a772355f1","src/util/ident_string.rs":"2b7fdbe9664c2e306114ffa830fde9710d849a0240029636cbb244457795b13f","src/util/ignored.rs":"7c979fbef880498ff64efda7396e759d80bf77fb1c7df0313bed8e533a16c0e0","src/util/mod.rs":"32b6df88e22444e44662ad745bb199df22964795194d2860c67c8b91a9a61a06","src/util/over_ride.rs":"e90b3aeb41dd3364753f3ee6f8c6bbd85bf51d51569bf048396ec6e7735c569f","src/util/spanned_value.rs":"3938cfc5169237cde1f19d65b653e1da8699663d1abfcf005359d48bbcee7d0b","src/util/with_original.rs":"a545b38ba9d624fdc939eb844f001b7fc4102717b1d3683b4cbd0aae00fa7ef2"},"package":"d2a368589465391e127e10c9e3a08efc8df66fd49b87dc8524c764bbe7f2ef82"} \ No newline at end of file diff --git a/third_party/rust/darling_core/Cargo.toml b/third_party/rust/darling_core/Cargo.toml index af5a8dfd2b0c..713366c1ace8 100644 --- a/third_party/rust/darling_core/Cargo.toml +++ b/third_party/rust/darling_core/Cargo.toml @@ -12,7 +12,7 @@ [package] name = "darling_core" -version = "0.8.1" +version = "0.8.6" authors = ["Ted Driggs "] description = "Helper crate for proc-macro library for reading attributes into structs when\nimplementing custom derives. Use https://crates.io/crates/darling in your code.\n" license = "MIT" @@ -24,14 +24,20 @@ version = "1.0.6" version = "1.0.0" [dependencies.proc-macro2] -version = "0.4.2" +version = "0.4.26" [dependencies.quote] version = "0.6" +[dependencies.strsim] +version = "0.8.0" +optional = true + [dependencies.syn] -version = "0.15" +version = "0.15.26" features = ["extra-traits"] [features] default = ["syn/full"] +diagnostics = [] +suggestions = ["strsim"] diff --git a/third_party/rust/darling_core/LICENSE b/third_party/rust/darling_core/LICENSE new file mode 100644 index 000000000000..0b48eadc9d03 --- /dev/null +++ b/third_party/rust/darling_core/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Ted Driggs + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/rust/darling_core/src/ast/data.rs b/third_party/rust/darling_core/src/ast/data.rs index 1c2cd798fbcf..8ea42bd36c87 100644 --- a/third_party/rust/darling_core/src/ast/data.rs +++ b/third_party/rust/darling_core/src/ast/data.rs @@ -1,4 +1,4 @@ -use std::slice; +use std::{slice, vec}; use syn; @@ -16,7 +16,7 @@ pub enum Data { Struct(Fields), } -#[deprecated(since = "0.3", note = "this has been renamed to Data")] +#[deprecated(since = "0.3.0", note = "this has been renamed to Data")] pub type Body = Data; impl Data { @@ -32,7 +32,7 @@ impl Data { /// Creates a new `Data<&'a V, &'a F>` instance from `Data`. pub fn as_ref<'a>(&'a self) -> Data<&'a V, &'a F> { match *self { - Data::Enum(ref variants) => Data::Enum(variants.into_iter().collect()), + Data::Enum(ref variants) => Data::Enum(variants.iter().collect()), Data::Struct(ref data) => Data::Struct(data.as_ref()), } } @@ -107,11 +107,7 @@ impl Data { syn::Data::Enum(ref data) => { let mut items = Vec::with_capacity(data.variants.len()); let mut errors = Vec::new(); - for v_result in data.variants - .clone() - .into_iter() - .map(|v| FromVariant::from_variant(&v)) - { + for v_result in data.variants.iter().map(FromVariant::from_variant) { match v_result { Ok(val) => items.push(val), Err(err) => errors.push(err), @@ -156,13 +152,14 @@ impl UsesLifetimes for Data { } } +/// Equivalent to `syn::Fields`, but replaces the AST element with a generic. #[derive(Debug, Clone, PartialEq, Eq)] pub struct Fields { pub style: Style, pub fields: Vec, } -#[deprecated(since = "0.3", note = "this has been renamed to Fields")] +#[deprecated(since = "0.3.0", note = "this has been renamed to Fields")] pub type VariantData = Fields; impl Fields { @@ -181,7 +178,7 @@ impl Fields { /// Returns true if this variant's data makes it a newtype. pub fn is_newtype(&self) -> bool { - self.style == Style::Tuple && self.fields.len() == 1 + self.style == Style::Tuple && self.len() == 1 } pub fn is_unit(&self) -> bool { @@ -216,6 +213,16 @@ impl Fields { pub fn iter(&self) -> slice::Iter { self.fields.iter() } + + /// Returns the number of fields in the structure. + pub fn len(&self) -> usize { + self.fields.len() + } + + /// Returns `true` if the `Fields` contains no fields. + pub fn is_empty(&self) -> bool { + self.fields.is_empty() + } } impl Fields { @@ -226,8 +233,7 @@ impl Fields { let mut errors = Vec::new(); for field in &fields.named { - let f_result = FromField::from_field(field); - match f_result { + match FromField::from_field(field) { Ok(val) => items.push(val), Err(err) => errors.push(if let Some(ref ident) = field.ident { err.at(ident) @@ -244,8 +250,7 @@ impl Fields { let mut errors = Vec::new(); for field in &fields.unnamed { - let f_result = FromField::from_field(field); - match f_result { + match FromField::from_field(field) { Ok(val) => items.push(val), Err(err) => errors.push(if let Some(ref ident) = field.ident { err.at(ident) @@ -271,6 +276,15 @@ impl Fields { } } +impl IntoIterator for Fields { + type Item = T; + type IntoIter = vec::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.fields.into_iter() + } +} + impl From