Beispiel
serde deny_unknown_fields stops rejecting unknown keys once the struct is flattened, while the pair the documentation calls unsupported compiles and works in the ordinary case
sha256:0c0a0329b6b2d901cce677b9664dd22b748c2a5249af00e202c0d2e12eab06f0
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Fall
- Ziel
- serde deny_unknown_fields stops rejecting unknown keys once the struct is flattened, while the pair the documentation calls unsupported compiles and works in the ordinary case FIX
- Pakete
- serde 1.0.229 serde_json 1.0.151
- Umgebung
- rust 1
- Erstellt
- 2026-08-14T13:02:45Z
Contract
- assert deny_unknown_fields rejects an extra key as a Category::Data error naming the field and the accepted names
- assert rename_all is applied first, so the Rust field name is itself rejected as unknown
- assert the accepted-names list is worded three different ways depending on how many fields there are
- compile a probe file with rustc to prove deny_unknown_fields together with flatten emits no error and no warning, because serde_derive implements the pair rather than rejecting it
- compile a probe file with rustc to prove flatten on a newtype struct is the combination serde_derive does reject
- assert deny_unknown_fields with a flattened map rejects every key the map was supposed to collect, so only an empty map is accepted
- assert that rejection carries no expected-names list, unlike deny_unknown_fields on its own
- assert deny_unknown_fields with a flattened struct accepts the flattened fields and rejects only the leftovers
- assert deny_unknown_fields on a struct that is flattened into another one never rejects anything
- assert the key that flattened struct ignored is dropped rather than kept, so it is gone from the re-serialized output
- assert an Option field is filled in with None when absent, with no attribute on it
- assert a field that is neither Option nor defaulted is reported as a missing field
- assert #[serde(default)] covers an absent field but not an explicit null
- assert Option answers None for both absent and null, so the two cannot be told apart
- assert Option serializes as null rather than omitting the key
- assert rename_all on a struct renames its fields but not the variant values of an enum field
- assert rename_all on an enum renames variants and rename_all_fields is what renames their fields
- assert skip_serializing_if omits an Option key entirely instead of writing null
- assert skip_serializing_if on a non-Option field breaks the round trip with a missing field error
- assert an internally tagged enum reports an unknown tag with the tag values it knows
- assert a missing tag is reported as a missing field and an externally tagged enum names its variants
- assert an internally tagged enum drops unknown payload keys, and that deny_unknown_fields on the enum does fire and reject them
- assert that enum rejection arrives with no line and column suffix, unlike every other error here
Dateien
- Cargo.lock
- Cargo.toml
- csx.json
- rustc_probe/deny_unknown_with_flatten.rs
- rustc_probe/flatten_on_newtype.rs
- src/main.rs
Ursprungs-Seeder
Verifizierungsbelege
- rust 1 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · cargo@1 · 2026-08-14 · ed25519:a2ec939a4c60e243
- · CONTAINER_RUN · compile:SKIPPED · contract:FAIL · load:SKIPPED · resolve:PASS · cargo@1 · 2026-08-14 · ed25519:7da3f610facce8bf