diff --git a/Cargo.lock b/Cargo.lock index 9470a3f..4fd1425 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,6 +47,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -62,6 +68,12 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + [[package]] name = "libc" version = "0.2.106" @@ -83,13 +95,19 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "once_cell" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" + [[package]] name = "proc-macro2" -version = "1.0.32" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] @@ -118,6 +136,40 @@ version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "serde" +version = "1.0.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" + +[[package]] +name = "serde_derive" +version = "1.0.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +dependencies = [ + "itoa", + "ryu", + "serde", +] + [[package]] name = "static-xml" version = "0.1.0" @@ -137,17 +189,18 @@ dependencies = [ "quote", "static-xml", "syn", + "trybuild", ] [[package]] name = "syn" -version = "1.0.81" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" +checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -170,10 +223,34 @@ dependencies = [ ] [[package]] -name = "unicode-xid" -version = "0.2.2" +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "trybuild" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea496675d71016e9bc76aa42d87f16aefd95447cc5818e671e12b2d7e269075d" +dependencies = [ + "glob", + "once_cell", + "serde", + "serde_derive", + "serde_json", + "termcolor", + "toml", +] + +[[package]] +name = "unicode-ident" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" [[package]] name = "winapi" diff --git a/static-xml-derive/Cargo.toml b/static-xml-derive/Cargo.toml index 2d45609..fcef0da 100644 --- a/static-xml-derive/Cargo.toml +++ b/static-xml-derive/Cargo.toml @@ -19,3 +19,6 @@ syn = "1.0" [lib] proc-macro = true + +[dev-dependencies] +trybuild = "1.0.71" diff --git a/static-xml-derive/tests/test.rs b/static-xml-derive/tests/test.rs new file mode 100644 index 0000000..9f20f75 --- /dev/null +++ b/static-xml-derive/tests/test.rs @@ -0,0 +1,5 @@ +#[test] +fn test() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/ui/field-not-parsetext.rs"); +} diff --git a/static-xml-derive/tests/ui/field-not-parsetext.rs b/static-xml-derive/tests/ui/field-not-parsetext.rs new file mode 100644 index 0000000..854dec2 --- /dev/null +++ b/static-xml-derive/tests/ui/field-not-parsetext.rs @@ -0,0 +1,10 @@ +use static_xml_derive::Deserialize; + +struct Foo; + +#[derive(Deserialize)] +struct Outer { + foo: Foo, +} + +fn main() {} diff --git a/static-xml-derive/tests/ui/field-not-parsetext.stderr b/static-xml-derive/tests/ui/field-not-parsetext.stderr new file mode 100644 index 0000000..c72a61e --- /dev/null +++ b/static-xml-derive/tests/ui/field-not-parsetext.stderr @@ -0,0 +1,40 @@ +error[E0277]: the trait bound `Foo: ParseText` is not satisfied + --> tests/ui/field-not-parsetext.rs:7:5 + | +5 | #[derive(Deserialize)] + | ----------- this tail expression is of type `&mut Foo` +6 | struct Outer { +7 | foo: Foo, + | ^^^^^^^^ the trait `ParseText` is not implemented for `Foo` + | + = help: the following other types implement trait `ParseText`: + String + bool + f32 + f64 + i128 + i16 + i32 + i64 + and $N others + = note: required for `Foo` to implement `Deserialize` + = note: required for `Foo` to implement `DeserializeElementField` + +error[E0277]: the trait bound `Foo: ParseText` is not satisfied + --> tests/ui/field-not-parsetext.rs:7:5 + | +7 | foo: Foo, + | ^^^^^^^^ the trait `ParseText` is not implemented for `Foo` + | + = help: the following other types implement trait `ParseText`: + String + bool + f32 + f64 + i128 + i16 + i32 + i64 + and $N others + = note: required for `Foo` to implement `Deserialize` + = note: required for `Foo` to implement `DeserializeElementField`