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
+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`.