-
-
Notifications
You must be signed in to change notification settings - Fork 777
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make compile error message point to field type instead of call site f…
…or not implemented Serialize trait
- Loading branch information
Showing
11 changed files
with
477 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use serde_derive::{Deserialize, Serialize}; | ||
|
||
struct NoImpls; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
struct S { | ||
x1: u32, | ||
x2: NoImpls, | ||
} | ||
|
||
fn main() {} |
166 changes: 166 additions & 0 deletions
166
test_suite/tests/ui/on-unimplemented/struct_field.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
error[E0277]: the trait bound `NoImpls: Serialize` is not satisfied | ||
--> tests/ui/on-unimplemented/struct_field.rs:8:9 | ||
| | ||
8 | x2: NoImpls, | ||
| ^^^^^^^ the trait `Serialize` is not implemented for `NoImpls` | ||
| | ||
= note: for local types consider adding `#[derive(serde::Serialize)]` to your `NoImpls` type | ||
= note: for types from other crates check whether the crate offers a `serde` feature flag | ||
= help: the following other types implement trait `Serialize`: | ||
&'a T | ||
&'a mut T | ||
() | ||
(T,) | ||
(T0, T1) | ||
(T0, T1, T2) | ||
(T0, T1, T2, T3) | ||
(T0, T1, T2, T3, T4) | ||
and $N others | ||
note: required by a bound in `_::_serde::ser::SerializeStruct::serialize_field` | ||
--> $WORKSPACE/serde/src/ser/mod.rs | ||
| | ||
| fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error> | ||
| --------------- required by a bound in this associated function | ||
| where | ||
| T: ?Sized + Serialize; | ||
| ^^^^^^^^^ required by this bound in `SerializeStruct::serialize_field` | ||
|
||
error[E0277]: the trait bound `NoImpls: Deserialize<'_>` is not satisfied | ||
--> tests/ui/on-unimplemented/struct_field.rs:8:9 | ||
| | ||
8 | x2: NoImpls, | ||
| ^^^^^^^ the trait `Deserialize<'_>` is not implemented for `NoImpls` | ||
| | ||
= note: for local types consider adding `#[derive(serde::Deserialize)]` to your `NoImpls` type | ||
= note: for types from other crates check whether the crate offers a `serde` feature flag | ||
= help: the following other types implement trait `Deserialize<'de>`: | ||
&'a Path | ||
&'a [u8] | ||
&'a str | ||
() | ||
(T,) | ||
(T0, T1) | ||
(T0, T1, T2) | ||
(T0, T1, T2, T3) | ||
and $N others | ||
note: required by a bound in `next_element` | ||
--> $WORKSPACE/serde/src/de/mod.rs | ||
| | ||
| fn next_element<T>(&mut self) -> Result<Option<T>, Self::Error> | ||
| ------------ required by a bound in this associated function | ||
| where | ||
| T: Deserialize<'de>, | ||
| ^^^^^^^^^^^^^^^^ required by this bound in `SeqAccess::next_element` | ||
|
||
error[E0277]: the trait bound `NoImpls: Deserialize<'_>` is not satisfied | ||
--> tests/ui/on-unimplemented/struct_field.rs:8:9 | ||
| | ||
8 | x2: NoImpls, | ||
| ^^^^^^^ the trait `Deserialize<'_>` is not implemented for `NoImpls` | ||
| | ||
= note: for local types consider adding `#[derive(serde::Deserialize)]` to your `NoImpls` type | ||
= note: for types from other crates check whether the crate offers a `serde` feature flag | ||
= help: the following other types implement trait `Deserialize<'de>`: | ||
&'a Path | ||
&'a [u8] | ||
&'a str | ||
() | ||
(T,) | ||
(T0, T1) | ||
(T0, T1, T2) | ||
(T0, T1, T2, T3) | ||
and $N others | ||
note: required by a bound in `next_value` | ||
--> $WORKSPACE/serde/src/de/mod.rs | ||
| | ||
| fn next_value<V>(&mut self) -> Result<V, Self::Error> | ||
| ---------- required by a bound in this associated function | ||
| where | ||
| V: Deserialize<'de>, | ||
| ^^^^^^^^^^^^^^^^ required by this bound in `MapAccess::next_value` | ||
|
||
error[E0277]: the trait bound `NoImpls: Deserialize<'_>` is not satisfied | ||
--> tests/ui/on-unimplemented/struct_field.rs:5:21 | ||
| | ||
5 | #[derive(Serialize, Deserialize)] | ||
| ^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `NoImpls` | ||
| | ||
= note: for local types consider adding `#[derive(serde::Deserialize)]` to your `NoImpls` type | ||
= note: for types from other crates check whether the crate offers a `serde` feature flag | ||
= help: the following other types implement trait `Deserialize<'de>`: | ||
&'a Path | ||
&'a [u8] | ||
&'a str | ||
() | ||
(T,) | ||
(T0, T1) | ||
(T0, T1, T2) | ||
(T0, T1, T2, T3) | ||
and $N others | ||
note: required by a bound in `_::_serde::__private::de::missing_field` | ||
--> $WORKSPACE/serde/src/private/de.rs | ||
| | ||
| pub fn missing_field<'de, V, E>(field: &'static str) -> Result<V, E> | ||
| ------------- required by a bound in this function | ||
| where | ||
| V: Deserialize<'de>, | ||
| ^^^^^^^^^^^^^^^^ required by this bound in `missing_field` | ||
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0277]: the trait bound `NoImpls: Deserialize<'_>` is not satisfied | ||
--> tests/ui/on-unimplemented/struct_field.rs:5:21 | ||
| | ||
5 | #[derive(Serialize, Deserialize)] | ||
| ^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `NoImpls`, which is required by `InPlaceSeed<'_, NoImpls>: DeserializeSeed<'_>` | ||
| | ||
= note: for local types consider adding `#[derive(serde::Deserialize)]` to your `NoImpls` type | ||
= note: for types from other crates check whether the crate offers a `serde` feature flag | ||
= help: the following other types implement trait `Deserialize<'de>`: | ||
&'a Path | ||
&'a [u8] | ||
&'a str | ||
() | ||
(T,) | ||
(T0, T1) | ||
(T0, T1, T2) | ||
(T0, T1, T2, T3) | ||
and $N others | ||
= note: required for `InPlaceSeed<'_, NoImpls>` to implement `DeserializeSeed<'_>` | ||
note: required by a bound in `next_element_seed` | ||
--> $WORKSPACE/serde/src/de/mod.rs | ||
| | ||
| fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error> | ||
| ----------------- required by a bound in this associated function | ||
| where | ||
| T: DeserializeSeed<'de>; | ||
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `SeqAccess::next_element_seed` | ||
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0277]: the trait bound `NoImpls: Deserialize<'_>` is not satisfied | ||
--> tests/ui/on-unimplemented/struct_field.rs:5:21 | ||
| | ||
5 | #[derive(Serialize, Deserialize)] | ||
| ^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `NoImpls`, which is required by `InPlaceSeed<'_, NoImpls>: DeserializeSeed<'_>` | ||
| | ||
= note: for local types consider adding `#[derive(serde::Deserialize)]` to your `NoImpls` type | ||
= note: for types from other crates check whether the crate offers a `serde` feature flag | ||
= help: the following other types implement trait `Deserialize<'de>`: | ||
&'a Path | ||
&'a [u8] | ||
&'a str | ||
() | ||
(T,) | ||
(T0, T1) | ||
(T0, T1, T2) | ||
(T0, T1, T2, T3) | ||
and $N others | ||
= note: required for `InPlaceSeed<'_, NoImpls>` to implement `DeserializeSeed<'_>` | ||
note: required by a bound in `next_value_seed` | ||
--> $WORKSPACE/serde/src/de/mod.rs | ||
| | ||
| fn next_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Self::Error> | ||
| --------------- required by a bound in this associated function | ||
| where | ||
| V: DeserializeSeed<'de>; | ||
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `MapAccess::next_value_seed` | ||
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use serde_derive::{Deserialize, Serialize}; | ||
|
||
struct NoImpls; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
enum E { | ||
S { x1: u32, x2: NoImpls }, | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.