Skip to content

Commit dc200a6

Browse files
committed
Reformat comments of non-public serde_derive internals
Fixes these being treated as "tests" by `cargo test` in serde_derive: running 3 tests test src/internals/check.rs - internals::check::check_remote_generic (line 23) ... FAILED test src/internals/check.rs - internals::check::check_remote_generic (line 29) ... FAILED test src/lib.rs - (line 3) ... ok failures: ---- src/internals/check.rs - internals::check::check_remote_generic (line 23) stdout ---- error: unknown start of token: \u{2026} --> src/internals/check.rs:25:20 | 4 | struct Generic<T> {…} | ^ error: cannot find attribute `serde` in this scope --> src/internals/check.rs:24:3 | 3 | #[serde(remote = "Generic")] | ^^^^^ | = note: `serde` is in scope, but it is a crate, not an attribute error[E0392]: parameter `T` is never used --> src/internals/check.rs:25:16 | 4 | struct Generic<T> {…} | ^ unused parameter | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `T` to be a const parameter, use `const T: usize` instead ---- src/internals/check.rs - internals::check::check_remote_generic (line 29) stdout ---- error: unknown start of token: \u{2026} --> src/internals/check.rs:31:21 | 4 | struct ConcreteDef {…} | ^ error: cannot find attribute `serde` in this scope --> src/internals/check.rs:30:3 | 3 | #[serde(remote = "Generic<T>")] | ^^^^^ | = note: `serde` is in scope, but it is a crate, not an attribute
1 parent 2c0999a commit dc200a6

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

serde_derive/src/internals/check.rs

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use internals::attr::{Identifier, TagType};
33
use internals::{ungroup, Ctxt, Derive};
44
use syn::{Member, Type};
55

6-
/// Cross-cutting checks that require looking at more than a single attrs
7-
/// object. Simpler checks should happen when parsing and building the attrs.
6+
// Cross-cutting checks that require looking at more than a single attrs object.
7+
// Simpler checks should happen when parsing and building the attrs.
88
pub fn check(cx: &Ctxt, cont: &mut Container, derive: Derive) {
99
check_remote_generic(cx, cont);
1010
check_getter(cx, cont);
@@ -17,18 +17,18 @@ pub fn check(cx: &Ctxt, cont: &mut Container, derive: Derive) {
1717
check_from_and_try_from(cx, cont);
1818
}
1919

20-
/// Remote derive definition type must have either all of the generics of the
21-
/// remote type:
22-
///
23-
/// #[serde(remote = "Generic")]
24-
/// struct Generic<T> {…}
25-
///
26-
/// or none of them, i.e. defining impls for one concrete instantiation of the
27-
/// remote type only:
28-
///
29-
/// #[serde(remote = "Generic<T>")]
30-
/// struct ConcreteDef {…}
31-
///
20+
// Remote derive definition type must have either all of the generics of the
21+
// remote type:
22+
//
23+
// #[serde(remote = "Generic")]
24+
// struct Generic<T> {…}
25+
//
26+
// or none of them, i.e. defining impls for one concrete instantiation of the
27+
// remote type only:
28+
//
29+
// #[serde(remote = "Generic<T>")]
30+
// struct ConcreteDef {…}
31+
//
3232
fn check_remote_generic(cx: &Ctxt, cont: &Container) {
3333
if let Some(remote) = cont.attrs.remote() {
3434
let local_has_generic = !cont.generics.params.is_empty();
@@ -39,8 +39,8 @@ fn check_remote_generic(cx: &Ctxt, cont: &Container) {
3939
}
4040
}
4141

42-
/// Getters are only allowed inside structs (not enums) with the `remote`
43-
/// attribute.
42+
// Getters are only allowed inside structs (not enums) with the `remote`
43+
// attribute.
4444
fn check_getter(cx: &Ctxt, cont: &Container) {
4545
match cont.data {
4646
Data::Enum(_) => {
@@ -62,7 +62,7 @@ fn check_getter(cx: &Ctxt, cont: &Container) {
6262
}
6363
}
6464

65-
/// Flattening has some restrictions we can test.
65+
// Flattening has some restrictions we can test.
6666
fn check_flatten(cx: &Ctxt, cont: &Container) {
6767
match &cont.data {
6868
Data::Enum(variants) => {
@@ -101,12 +101,12 @@ fn check_flatten_field(cx: &Ctxt, style: Style, field: &Field) {
101101
}
102102
}
103103

104-
/// The `other` attribute must be used at most once and it must be the last
105-
/// variant of an enum.
106-
///
107-
/// Inside a `variant_identifier` all variants must be unit variants. Inside a
108-
/// `field_identifier` all but possibly one variant must be unit variants. The
109-
/// last variant may be a newtype variant which is an implicit "other" case.
104+
// The `other` attribute must be used at most once and it must be the last
105+
// variant of an enum.
106+
//
107+
// Inside a `variant_identifier` all variants must be unit variants. Inside a
108+
// `field_identifier` all but possibly one variant must be unit variants. The
109+
// last variant may be a newtype variant which is an implicit "other" case.
110110
fn check_identifier(cx: &Ctxt, cont: &Container) {
111111
let variants = match &cont.data {
112112
Data::Enum(variants) => variants,
@@ -189,8 +189,8 @@ fn check_identifier(cx: &Ctxt, cont: &Container) {
189189
}
190190
}
191191

192-
/// Skip-(de)serializing attributes are not allowed on variants marked
193-
/// (de)serialize_with.
192+
// Skip-(de)serializing attributes are not allowed on variants marked
193+
// (de)serialize_with.
194194
fn check_variant_skip_attrs(cx: &Ctxt, cont: &Container) {
195195
let variants = match &cont.data {
196196
Data::Enum(variants) => variants,
@@ -264,10 +264,9 @@ fn check_variant_skip_attrs(cx: &Ctxt, cont: &Container) {
264264
}
265265
}
266266

267-
/// The tag of an internally-tagged struct variant must not be
268-
/// the same as either one of its fields, as this would result in
269-
/// duplicate keys in the serialized output and/or ambiguity in
270-
/// the to-be-deserialized input.
267+
// The tag of an internally-tagged struct variant must not be the same as either
268+
// one of its fields, as this would result in duplicate keys in the serialized
269+
// output and/or ambiguity in the to-be-deserialized input.
271270
fn check_internal_tag_field_name_conflict(cx: &Ctxt, cont: &Container) {
272271
let variants = match &cont.data {
273272
Data::Enum(variants) => variants,
@@ -313,8 +312,8 @@ fn check_internal_tag_field_name_conflict(cx: &Ctxt, cont: &Container) {
313312
}
314313
}
315314

316-
/// In the case of adjacently-tagged enums, the type and the
317-
/// contents tag must differ, for the same reason.
315+
// In the case of adjacently-tagged enums, the type and the contents tag must
316+
// differ, for the same reason.
318317
fn check_adjacent_tag_conflict(cx: &Ctxt, cont: &Container) {
319318
let (type_tag, content_tag) = match cont.attrs.tag() {
320319
TagType::Adjacent { tag, content } => (tag, content),
@@ -332,7 +331,7 @@ fn check_adjacent_tag_conflict(cx: &Ctxt, cont: &Container) {
332331
}
333332
}
334333

335-
/// Enums and unit structs cannot be transparent.
334+
// Enums and unit structs cannot be transparent.
336335
fn check_transparent(cx: &Ctxt, cont: &mut Container, derive: Derive) {
337336
if !cont.attrs.transparent() {
338337
return;

0 commit comments

Comments
 (0)