From 00460b8dee15a098a5218b9ec3117e1082dbeccb Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 21 Oct 2024 19:41:43 -0700 Subject: [PATCH] Fix wording in comments from PR 2558 --- serde_derive/src/ser.rs | 2 +- .../incorrect_type_enum_adjacently_tagged.rs | 5 +- ...correct_type_enum_adjacently_tagged.stderr | 54 +++++++++---------- .../incorrect_type_enum_externally_tagged.rs | 5 +- ...correct_type_enum_externally_tagged.stderr | 18 +++---- .../incorrect_type_enum_internally_tagged.rs | 7 +-- ...correct_type_enum_internally_tagged.stderr | 12 ++--- .../incorrect_type_enum_untagged.rs | 5 +- .../incorrect_type_enum_untagged.stderr | 54 +++++++++---------- .../incorrect_type_newtype.rs | 3 +- .../incorrect_type_newtype.stderr | 26 ++++----- .../incorrect_type_struct.rs | 3 +- .../incorrect_type_struct.stderr | 34 ++++++------ .../default-attribute/incorrect_type_tuple.rs | 3 +- .../incorrect_type_tuple.stderr | 26 ++++----- 15 files changed, 132 insertions(+), 125 deletions(-) diff --git a/serde_derive/src/ser.rs b/serde_derive/src/ser.rs index 9a45b81d..72585121 100644 --- a/serde_derive/src/ser.rs +++ b/serde_derive/src/ser.rs @@ -1227,7 +1227,7 @@ fn wrap_serialize_with( quote_spanned!(serialize_with.span()=> { #[doc(hidden)] struct __SerializeWith #wrapper_impl_generics #where_clause { - // If #field_tys is empty, `values` does not used + // If #field_tys is empty, this field is unused #[allow(dead_code)] values: (#(&'__a #field_tys, )*), phantom: _serde::__private::PhantomData<#this_type #ty_generics>, diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs b/test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs index 339af63d..2e0fc867 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs +++ b/test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs @@ -1,10 +1,11 @@ -//! Ensures that error message points to the path in attribute +// Tests that type error points to the path in attribute + use serde_derive::Deserialize; #[derive(Deserialize)] #[serde(tag = "tag", content = "content")] enum Enum { - // Newtype variants does not use the provided path, so it is forbidden here + // Newtype variants do not use the provided path, so it is forbidden here // Newtype(#[serde(default = "main")] u8), Tuple(u8, #[serde(default = "main")] i8), Struct { diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.stderr index 984f2425..c21b4769 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.stderr @@ -1,35 +1,35 @@ error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:9:33 - | -4 | #[derive(Deserialize)] - | ----------- - | | - | this is found to be of type `i8` - | `match` arms have incompatible types -... -9 | Tuple(u8, #[serde(default = "main")] i8), - | ^^^^^^ expected `i8`, found `()` - -error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:11:27 + --> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:10:33 | -4 | #[derive(Deserialize)] - | ----------- - | | - | this is found to be of type `u8` - | `match` arms have incompatible types -... -11 | #[serde(default = "main")] - | ^^^^^^ expected `u8`, found `()` - -error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:14:27 - | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` | `match` arms have incompatible types ... -14 | #[serde(default = "main")] +10 | Tuple(u8, #[serde(default = "main")] i8), + | ^^^^^^ expected `i8`, found `()` + +error[E0308]: `match` arms have incompatible types + --> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:12:27 + | +5 | #[derive(Deserialize)] + | ----------- + | | + | this is found to be of type `u8` + | `match` arms have incompatible types +... +12 | #[serde(default = "main")] + | ^^^^^^ expected `u8`, found `()` + +error[E0308]: `match` arms have incompatible types + --> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:15:27 + | +5 | #[derive(Deserialize)] + | ----------- + | | + | this is found to be of type `i8` + | `match` arms have incompatible types +... +15 | #[serde(default = "main")] | ^^^^^^ expected `i8`, found `()` diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs b/test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs index 02dc6446..7c92b15f 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs +++ b/test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs @@ -1,9 +1,10 @@ -//! Ensures that error message points to the path in attribute +// Tests that type error points to the path in attribute + use serde_derive::Deserialize; #[derive(Deserialize)] enum Enum { - // Newtype variants does not use the provided path, so it is forbidden here + // Newtype variants do not use the provided path, so it is forbidden here // Newtype(#[serde(default = "main")] u8), Tuple(u8, #[serde(default = "main")] i8), Struct { diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.stderr index 01672cfa..09da2438 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.stderr @@ -1,35 +1,35 @@ error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs:8:33 + --> tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs:9:33 | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` | `match` arms have incompatible types ... -8 | Tuple(u8, #[serde(default = "main")] i8), +9 | Tuple(u8, #[serde(default = "main")] i8), | ^^^^^^ expected `i8`, found `()` error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs:10:27 + --> tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs:11:27 | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `u8` | `match` arms have incompatible types ... -10 | #[serde(default = "main")] +11 | #[serde(default = "main")] | ^^^^^^ expected `u8`, found `()` error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs:13:27 + --> tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs:14:27 | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` | `match` arms have incompatible types ... -13 | #[serde(default = "main")] +14 | #[serde(default = "main")] | ^^^^^^ expected `i8`, found `()` diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs b/test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs index d5026415..5e1a4e84 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs +++ b/test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs @@ -1,12 +1,13 @@ -//! Ensures that error message points to the path in attribute +// Tests that type error points to the path in attribute + use serde_derive::Deserialize; #[derive(Deserialize)] #[serde(tag = "tag")] enum Enum { - // Newtype variants does not use the provided path, so it is forbidden here + // Newtype variants do not use the provided path, so it is forbidden here // Newtype(#[serde(default = "main")] u8), - // Tuple variants does not supported in internally tagged enums + // Tuple variants are not supported in internally tagged enums Struct { #[serde(default = "main")] f1: u8, diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.stderr index 752806b6..74fead2d 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.stderr @@ -1,23 +1,23 @@ error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs:11:27 + --> tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs:12:27 | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `u8` | `match` arms have incompatible types ... -11 | #[serde(default = "main")] +12 | #[serde(default = "main")] | ^^^^^^ expected `u8`, found `()` error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs:14:27 + --> tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs:15:27 | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` | `match` arms have incompatible types ... -14 | #[serde(default = "main")] +15 | #[serde(default = "main")] | ^^^^^^ expected `i8`, found `()` diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.rs b/test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.rs index 530f4a9d..1c5e910d 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.rs +++ b/test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.rs @@ -1,10 +1,11 @@ -//! Ensures that error message points to the path in attribute +// Tests that type error points to the path in attribute + use serde_derive::Deserialize; #[derive(Deserialize)] #[serde(untagged)] enum Enum { - // Newtype variants does not use the provided path, so it is forbidden here + // Newtype variants do not use the provided path, so it is forbidden here // Newtype(#[serde(default = "main")] u8), Tuple(u8, #[serde(default = "main")] i8), Struct { diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.stderr index d782fe30..9e1167d9 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.stderr @@ -1,35 +1,35 @@ error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:9:33 - | -4 | #[derive(Deserialize)] - | ----------- - | | - | this is found to be of type `i8` - | `match` arms have incompatible types -... -9 | Tuple(u8, #[serde(default = "main")] i8), - | ^^^^^^ expected `i8`, found `()` - -error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:11:27 + --> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:10:33 | -4 | #[derive(Deserialize)] - | ----------- - | | - | this is found to be of type `u8` - | `match` arms have incompatible types -... -11 | #[serde(default = "main")] - | ^^^^^^ expected `u8`, found `()` - -error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:14:27 - | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` | `match` arms have incompatible types ... -14 | #[serde(default = "main")] +10 | Tuple(u8, #[serde(default = "main")] i8), + | ^^^^^^ expected `i8`, found `()` + +error[E0308]: `match` arms have incompatible types + --> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:12:27 + | +5 | #[derive(Deserialize)] + | ----------- + | | + | this is found to be of type `u8` + | `match` arms have incompatible types +... +12 | #[serde(default = "main")] + | ^^^^^^ expected `u8`, found `()` + +error[E0308]: `match` arms have incompatible types + --> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:15:27 + | +5 | #[derive(Deserialize)] + | ----------- + | | + | this is found to be of type `i8` + | `match` arms have incompatible types +... +15 | #[serde(default = "main")] | ^^^^^^ expected `i8`, found `()` diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_newtype.rs b/test_suite/tests/ui/default-attribute/incorrect_type_newtype.rs index 7db2a3d4..84b60942 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_newtype.rs +++ b/test_suite/tests/ui/default-attribute/incorrect_type_newtype.rs @@ -1,4 +1,5 @@ -//! Ensures that error message points to the path in attribute +// Tests that type error points to the path in attribute + use serde_derive::Deserialize; #[derive(Deserialize)] diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_newtype.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_newtype.stderr index b8910514..b4e066ae 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_newtype.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_newtype.stderr @@ -1,37 +1,37 @@ error[E0308]: mismatched types - --> tests/ui/default-attribute/incorrect_type_newtype.rs:5:19 + --> tests/ui/default-attribute/incorrect_type_newtype.rs:6:19 | -5 | #[serde(default = "main")] +6 | #[serde(default = "main")] | ^^^^^^ | | | expected `Newtype`, found `()` | expected due to this error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_newtype.rs:6:34 + --> tests/ui/default-attribute/incorrect_type_newtype.rs:7:34 | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `u8` | `match` arms have incompatible types -5 | #[serde(default = "main")] -6 | struct Newtype(#[serde(default = "main")] u8); +6 | #[serde(default = "main")] +7 | struct Newtype(#[serde(default = "main")] u8); | ^^^^^^ expected `u8`, found `()` error[E0308]: mismatched types - --> tests/ui/default-attribute/incorrect_type_newtype.rs:5:19 + --> tests/ui/default-attribute/incorrect_type_newtype.rs:6:19 | -5 | #[serde(default = "main")] +6 | #[serde(default = "main")] | ^^^^^^ expected `Newtype`, found `()` -6 | struct Newtype(#[serde(default = "main")] u8); +7 | struct Newtype(#[serde(default = "main")] u8); | ------- expected due to this error[E0308]: mismatched types - --> tests/ui/default-attribute/incorrect_type_newtype.rs:6:34 + --> tests/ui/default-attribute/incorrect_type_newtype.rs:7:34 | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- expected due to the type of this binding -5 | #[serde(default = "main")] -6 | struct Newtype(#[serde(default = "main")] u8); +6 | #[serde(default = "main")] +7 | struct Newtype(#[serde(default = "main")] u8); | ^^^^^^ expected `u8`, found `()` diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_struct.rs b/test_suite/tests/ui/default-attribute/incorrect_type_struct.rs index 52d5af9a..3c5370b8 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_struct.rs +++ b/test_suite/tests/ui/default-attribute/incorrect_type_struct.rs @@ -1,4 +1,5 @@ -//! Ensures that error message points to the path in attribute +// Tests that type error points to the path in attribute + use serde_derive::Deserialize; #[derive(Deserialize)] diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_struct.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_struct.stderr index 5663c320..13431b03 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_struct.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_struct.stderr @@ -1,58 +1,58 @@ error[E0308]: mismatched types - --> tests/ui/default-attribute/incorrect_type_struct.rs:5:19 + --> tests/ui/default-attribute/incorrect_type_struct.rs:6:19 | -5 | #[serde(default = "main")] +6 | #[serde(default = "main")] | ^^^^^^ | | | expected `Struct`, found `()` | expected due to this error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_struct.rs:7:23 + --> tests/ui/default-attribute/incorrect_type_struct.rs:8:23 | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `u8` | `match` arms have incompatible types ... -7 | #[serde(default = "main")] +8 | #[serde(default = "main")] | ^^^^^^ expected `u8`, found `()` error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_struct.rs:10:23 + --> tests/ui/default-attribute/incorrect_type_struct.rs:11:23 | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` | `match` arms have incompatible types ... -10 | #[serde(default = "main")] +11 | #[serde(default = "main")] | ^^^^^^ expected `i8`, found `()` error[E0308]: mismatched types - --> tests/ui/default-attribute/incorrect_type_struct.rs:5:19 + --> tests/ui/default-attribute/incorrect_type_struct.rs:6:19 | -5 | #[serde(default = "main")] +6 | #[serde(default = "main")] | ^^^^^^ expected `Struct`, found `()` -6 | struct Struct { +7 | struct Struct { | ------ expected due to this error[E0308]: mismatched types - --> tests/ui/default-attribute/incorrect_type_struct.rs:7:23 + --> tests/ui/default-attribute/incorrect_type_struct.rs:8:23 | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- expected due to the type of this binding ... -7 | #[serde(default = "main")] +8 | #[serde(default = "main")] | ^^^^^^ expected `u8`, found `()` error[E0308]: mismatched types - --> tests/ui/default-attribute/incorrect_type_struct.rs:10:23 + --> tests/ui/default-attribute/incorrect_type_struct.rs:11:23 | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- expected due to the type of this binding ... -10 | #[serde(default = "main")] +11 | #[serde(default = "main")] | ^^^^^^ expected `i8`, found `()` diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_tuple.rs b/test_suite/tests/ui/default-attribute/incorrect_type_tuple.rs index 895ce652..f40e1165 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_tuple.rs +++ b/test_suite/tests/ui/default-attribute/incorrect_type_tuple.rs @@ -1,4 +1,5 @@ -//! Ensures that error message points to the path in attribute +// Tests that type error points to the path in attribute + use serde_derive::Deserialize; #[derive(Deserialize)] diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_tuple.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_tuple.stderr index a767c8c5..131158e2 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_tuple.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_tuple.stderr @@ -1,37 +1,37 @@ error[E0308]: mismatched types - --> tests/ui/default-attribute/incorrect_type_tuple.rs:5:19 + --> tests/ui/default-attribute/incorrect_type_tuple.rs:6:19 | -5 | #[serde(default = "main")] +6 | #[serde(default = "main")] | ^^^^^^ | | | expected `Tuple`, found `()` | expected due to this error[E0308]: `match` arms have incompatible types - --> tests/ui/default-attribute/incorrect_type_tuple.rs:6:36 + --> tests/ui/default-attribute/incorrect_type_tuple.rs:7:36 | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` | `match` arms have incompatible types -5 | #[serde(default = "main")] -6 | struct Tuple(u8, #[serde(default = "main")] i8); +6 | #[serde(default = "main")] +7 | struct Tuple(u8, #[serde(default = "main")] i8); | ^^^^^^ expected `i8`, found `()` error[E0308]: mismatched types - --> tests/ui/default-attribute/incorrect_type_tuple.rs:5:19 + --> tests/ui/default-attribute/incorrect_type_tuple.rs:6:19 | -5 | #[serde(default = "main")] +6 | #[serde(default = "main")] | ^^^^^^ expected `Tuple`, found `()` -6 | struct Tuple(u8, #[serde(default = "main")] i8); +7 | struct Tuple(u8, #[serde(default = "main")] i8); | ----- expected due to this error[E0308]: mismatched types - --> tests/ui/default-attribute/incorrect_type_tuple.rs:6:36 + --> tests/ui/default-attribute/incorrect_type_tuple.rs:7:36 | -4 | #[derive(Deserialize)] +5 | #[derive(Deserialize)] | ----------- expected due to the type of this binding -5 | #[serde(default = "main")] -6 | struct Tuple(u8, #[serde(default = "main")] i8); +6 | #[serde(default = "main")] +7 | struct Tuple(u8, #[serde(default = "main")] i8); | ^^^^^^ expected `i8`, found `()`