Move all compile-fail tests to ui tests

The update-references.sh script makes these much easier to update in
bulk compared to compile-fail tests.
This commit is contained in:
David Tolnay
2018-11-24 15:37:35 -08:00
parent b3d9d51b51
commit 4821d09a48
134 changed files with 603 additions and 73 deletions
@@ -0,0 +1,18 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
struct Test<'a> {
#[serde(borrow = "zzz")]
s: &'a str,
}
fn main() {}
@@ -0,0 +1,8 @@
error: failed to parse borrowed lifetimes: "zzz"
--> $DIR/bad_lifetimes.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,18 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
struct Test<'a> {
#[serde(borrow = "'a + 'a")]
s: &'a str,
}
fn main() {}
@@ -0,0 +1,8 @@
error: duplicate borrowed lifetime `'a`
--> $DIR/duplicate_lifetime.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,21 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
struct Str<'a>(&'a str);
#[derive(Deserialize)]
enum Test<'a> {
#[serde(borrow)]
S(#[serde(borrow)] Str<'a>),
}
fn main() {}
@@ -0,0 +1,8 @@
error: duplicate serde attribute `borrow`
--> $DIR/duplicate_variant.rs:15:10
|
15 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,18 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
struct Test<'a> {
#[serde(borrow = "")]
s: &'a str,
}
fn main() {}
@@ -0,0 +1,8 @@
error: at least one lifetime must be borrowed
--> $DIR/empty_lifetimes.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,18 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
struct Test {
#[serde(borrow)]
s: String,
}
fn main() {}
@@ -0,0 +1,8 @@
error: field `s` has no lifetimes to borrow
--> $DIR/no_lifetimes.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,21 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
struct Str<'a>(&'a str);
#[derive(Deserialize)]
enum Test<'a> {
#[serde(borrow)]
S { s: Str<'a> },
}
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(borrow)] may only be used on newtype variants
--> $DIR/struct_variant.rs:15:10
|
15 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,18 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
struct Test<'a> {
#[serde(borrow = "'b")]
s: &'a str,
}
fn main() {}
@@ -0,0 +1,8 @@
error: field `s` does not have lifetime 'b
--> $DIR/wrong_lifetime.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,19 @@
// Copyright 2018 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
#[serde(tag = "conflict", content = "conflict")]
enum E {
A,
B,
}
fn main() {}
@@ -0,0 +1,8 @@
error: enum tags `conflict` for type and content conflict with each other
--> $DIR/adjacent-tag.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,15 @@
// Copyright 2018 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
struct Foo(#[serde(flatten)] HashMap<String, String>);
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(flatten)] cannot be used on newtype structs
--> $DIR/flatten-newtype-struct.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,23 @@
// Copyright 2018 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
struct Foo {
#[serde(flatten, skip_deserializing)]
other: Other,
}
#[derive(Deserialize)]
struct Other {
x: u32,
}
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(flatten] can not be combined with #[serde(skip_deserializing)]
--> $DIR/flatten-skip-deserializing.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,23 @@
// Copyright 2018 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
struct Foo {
#[serde(flatten, skip_serializing_if = "Option::is_none")]
other: Option<Other>,
}
#[derive(Serialize)]
struct Other {
x: u32,
}
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(flatten] can not be combined with #[serde(skip_serializing_if = "...")]
--> $DIR/flatten-skip-serializing-if.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,23 @@
// Copyright 2018 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
struct Foo {
#[serde(flatten, skip_serializing)]
other: Other,
}
#[derive(Serialize)]
struct Other {
x: u32,
}
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(flatten] can not be combined with #[serde(skip_serializing)]
--> $DIR/flatten-skip-serializing.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,15 @@
// Copyright 2018 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
struct Foo(u32, #[serde(flatten)] HashMap<String, String>);
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(flatten)] cannot be used on tuple structs
--> $DIR/flatten-tuple-struct.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,21 @@
// Copyright 2018 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
#[serde(tag = "conflict")]
enum E {
A {
#[serde(rename = "conflict")]
x: (),
},
}
fn main() {}
@@ -0,0 +1,8 @@
error: variant field name `conflict` conflicts with internal tag
--> $DIR/internal-tag.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,16 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
#[serde(default)]
enum E {
S { f: u8 },
}
@@ -0,0 +1,8 @@
error: #[serde(default)] can only be used on structs with named fields
--> $DIR/enum.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,16 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
#[serde(default)]
struct T(u8, u8);
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(default)] can only be used on structs with named fields
--> $DIR/nameless_struct_fields.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,18 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
struct S {
#[serde(rename = "x", serialize = "y")]
x: (),
}
fn main() {}
@@ -0,0 +1,8 @@
error: unknown serde field attribute `serialize`
--> $DIR/rename-and-ser.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,19 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
struct S {
#[serde(rename = "x")]
#[serde(rename(deserialize = "y"))]
x: (),
}
fn main() {}
@@ -0,0 +1,8 @@
error: duplicate serde attribute `rename`
--> $DIR/rename-rename-de.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,18 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
struct S {
#[serde(rename(serialize = "x"), rename(serialize = "y"))]
x: (),
}
fn main() {}
@@ -0,0 +1,8 @@
error: duplicate serde attribute `rename`
--> $DIR/rename-ser-rename-ser.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,19 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
struct S {
#[serde(rename(serialize = "x"))]
#[serde(rename = "y")]
x: (),
}
fn main() {}
@@ -0,0 +1,8 @@
error: duplicate serde attribute `rename`
--> $DIR/rename-ser-rename.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,18 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
struct S {
#[serde(rename(serialize = "x", serialize = "y"))]
x: (),
}
fn main() {}
@@ -0,0 +1,8 @@
error: duplicate serde attribute `rename`
--> $DIR/rename-ser-ser.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,19 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
struct S {
#[serde(rename(serialize = "x"))]
#[serde(rename(serialize = "y"))]
x: (),
}
fn main() {}
@@ -0,0 +1,8 @@
error: duplicate serde attribute `rename`
--> $DIR/two-rename-ser.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,18 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
struct S {
#[serde(with = "w", serialize_with = "s")]
x: (),
}
fn main() {}
@@ -0,0 +1,8 @@
error: duplicate serde attribute `serialize_with`
--> $DIR/with-and-serialize-with.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,18 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
#[serde(tag = "type")]
enum E {
Tuple(u8, u8),
}
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(tag = "...")] cannot be used with tuple variants
--> $DIR/internal-tuple-variant.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,16 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
#[serde(tag = "type")]
struct S;
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(tag = "...")] can only be used on enums
--> $DIR/internally-tagged-struct.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,20 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
#[serde(untagged)]
#[serde(tag = "type")]
enum E {
A(u8),
B(String),
}
fn main() {}
@@ -0,0 +1,8 @@
error: enum cannot be both untagged and internally tagged
--> $DIR/untagged-and-internal.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,16 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
#[serde(untagged)]
struct S;
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(untagged)] can only be used on enums
--> $DIR/untagged-struct.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
+19
View File
@@ -0,0 +1,19 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
#[serde(field_identifier, variant_identifier)]
enum F {
A,
B,
}
fn main() {}
@@ -0,0 +1,8 @@
error: `field_identifier` and `variant_identifier` cannot both be set
--> $DIR/both.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,16 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
#[serde(field_identifier)]
struct S;
fn main() {}
@@ -0,0 +1,8 @@
error: `field_identifier` can only be used on an enum
--> $DIR/field_struct.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,19 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
#[serde(field_identifier)]
enum F {
A,
B(u8, u8),
}
fn main() {}
@@ -0,0 +1,8 @@
error: field_identifier may only contain unit variants
--> $DIR/field_tuple.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,20 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
#[serde(field_identifier)]
enum F {
A,
Other(String),
B,
}
fn main() {}
@@ -0,0 +1,8 @@
error: `Other` must be the last variant
--> $DIR/newtype_not_last.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,20 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
#[serde(field_identifier)]
enum F {
A,
#[serde(other)]
Other(u8, u8),
}
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(other)] must be on a unit variant
--> $DIR/not_unit.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,21 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
#[serde(field_identifier)]
enum F {
A,
#[serde(other)]
Other,
B,
}
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(other)] must be the last variant
--> $DIR/other_not_last.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,19 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
#[serde(field_identifier)]
enum F {
A,
B,
}
fn main() {}
@@ -0,0 +1,8 @@
error: field identifiers cannot be serialized
--> $DIR/serialize.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,16 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
#[serde(variant_identifier)]
struct S;
fn main() {}
@@ -0,0 +1,8 @@
error: `variant_identifier` can only be used on an enum
--> $DIR/variant_struct.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,19 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
#[serde(variant_identifier)]
enum F {
A,
B(u8, u8),
}
fn main() {}
@@ -0,0 +1,8 @@
error: variant_identifier may only contain unit variants
--> $DIR/variant_tuple.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,15 @@
// Copyright 2018 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
struct S<'de> {
s: &'de str,
}
@@ -0,0 +1,8 @@
error: cannot deserialize when there is a lifetime parameter called 'de
--> $DIR/deserialize_de_lifetime.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,16 @@
// Copyright 2018 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
struct S {
string: String,
slice: [u8],
}
@@ -0,0 +1,8 @@
error: cannot deserialize a dynamically sized struct
--> $DIR/deserialize_dst.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
+25
View File
@@ -0,0 +1,25 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
mod remote {
pub struct S {
a: u8,
}
}
#[derive(Serialize)]
#[serde(remote = "remote::S")]
struct S {
#[serde(getter = "~~~")]
a: u8,
}
fn main() {}
@@ -0,0 +1,8 @@
error: failed to parse path: "~~~"
--> $DIR/bad_getter.rs:18:10
|
18 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
+24
View File
@@ -0,0 +1,24 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
mod remote {
pub struct S {
a: u8,
}
}
#[derive(Serialize)]
#[serde(remote = "~~~")]
struct S {
a: u8,
}
fn main() {}
@@ -0,0 +1,8 @@
error: failed to parse path: "~~~"
--> $DIR/bad_remote.rs:18:10
|
18 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
+27
View File
@@ -0,0 +1,27 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
mod remote {
pub enum E {
A { a: u8 },
}
}
#[derive(Serialize)]
#[serde(remote = "remote::E")]
pub enum E {
A {
#[serde(getter = "get_a")]
a: u8,
},
}
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(getter = "...")] is not allowed in an enum
--> $DIR/enum_getter.rs:18:10
|
18 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,25 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
mod remote {
pub struct S {
pub a: u8,
pub b: u8,
}
}
#[derive(Serialize, Deserialize)]
#[serde(remote = "remote::S")]
struct S {
a: u8,
}
fn main() {}
@@ -0,0 +1,9 @@
error[E0063]: missing field `b` in initializer of `remote::S`
--> $DIR/missing_field.rs:20:18
|
20 | #[serde(remote = "remote::S")]
| ^^^^^^^^^^^ missing `b`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0063`.
@@ -0,0 +1,24 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
struct S {
#[serde(getter = "S::get")]
a: u8,
}
impl S {
fn get(&self) -> u8 {
self.a
}
}
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(getter = "...")] can only be used in structs that have #[serde(remote = "...")]
--> $DIR/nonremote_getter.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,24 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
mod remote {
pub struct S {
pub a: u8,
}
}
#[derive(Serialize, Deserialize)]
#[serde(remote = "remote::S")]
struct S {
b: u8,
}
fn main() {}
@@ -0,0 +1,16 @@
error[E0609]: no field `b` on type `&remote::S`
--> $DIR/unknown_field.rs:21:5
|
21 | b: u8,
| ^
error[E0560]: struct `remote::S` has no field named `b`
--> $DIR/unknown_field.rs:21:5
|
21 | b: u8,
| ^ field does not exist - did you mean `a`?
error: aborting due to 2 previous errors
Some errors occurred: E0560, E0609.
For more information about an error, try `rustc --explain E0560`.
+20
View File
@@ -0,0 +1,20 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
mod remote {
pub struct S(pub u16);
}
#[derive(Deserialize)]
#[serde(remote = "remote::S")]
struct S(u8);
fn main() {}
@@ -0,0 +1,13 @@
error[E0308]: mismatched types
--> $DIR/wrong_de.rs:16:10
|
16 | #[derive(Deserialize)]
| ^^^^^^^^^^^ expected u16, found u8
help: you can cast an `u8` to `u16`, which will zero-extend the source value
|
16 | #[derive(Deserialize.into())]
| ^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
@@ -0,0 +1,31 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
mod remote {
pub struct S {
a: u8,
}
impl S {
pub fn get(&self) -> u16 {
self.a as u16
}
}
}
#[derive(Serialize)]
#[serde(remote = "remote::S")]
struct S {
#[serde(getter = "remote::S::get")]
a: u8,
}
fn main() {}
@@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/wrong_getter.rs:24:10
|
24 | #[derive(Serialize)]
| ^^^^^^^^^ expected u8, found u16
|
= note: expected type `&u8`
found type `&u16`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
+24
View File
@@ -0,0 +1,24 @@
// Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
mod remote {
pub struct S {
pub a: u16,
}
}
#[derive(Serialize)]
#[serde(remote = "remote::S")]
struct S {
a: u8,
}
fn main() {}
@@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/wrong_ser.rs:18:10
|
18 | #[derive(Serialize)]
| ^^^^^^^^^ expected u8, found u16
|
= note: expected type `&u8`
found type `&u16`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
@@ -0,0 +1,19 @@
// Copyright 2018 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
#[serde(transparent)]
struct S {
a: u8,
b: u8,
}
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(transparent)] requires struct to have at most one transparent field
--> $DIR/at_most_one.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,21 @@
// Copyright 2018 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
#[serde(transparent)]
struct S {
#[serde(skip)]
a: u8,
#[serde(default)]
b: u8,
}
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(transparent)] requires at least one field that is neither skipped nor has a default
--> $DIR/de_at_least_one.rs:12:10
|
12 | #[derive(Deserialize)]
| ^^^^^^^^^^^
error: aborting due to previous error
@@ -0,0 +1,19 @@
// Copyright 2018 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
#[serde(transparent)]
struct S {
#[serde(skip)]
a: u8,
}
fn main() {}
@@ -0,0 +1,8 @@
error: #[serde(transparent)] requires at least one field that is not skipped
--> $DIR/ser_at_least_one.rs:12:10
|
12 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error

Some files were not shown because too many files have changed in this diff Show More