Commit e1a1ad6
Add
Summary:
The Rust generator has validations to disallow the combination of adapter + serde on the same type. However, those validations are not currently enforced correctly - the Rust generator initializes its options in `generate_program`. This means the options are *not* initialized when `validate_program` runs.
https://www.internalfb.com/code/fbsource/[017165f964e6]/xplat/thrift/compiler/compiler.cc?lines=526-536
This means the Rust validators don't get the true view of options, which currently allows invalid programs to pass validation.
E.g. `validate_struct_annotations` disallows the `rust.Adapter` annotation with the `serde` compiler/generator option, but because `rust_codegen_options::serde` is not initialized until `generate_program` is called, `serde` will always be `false` when the validator runs.
This adds a new `serde` option on the `rust.Adapter` annotation, which can be set to inform the compiler/generator "this adapter will implement Serialize/Deserialize traits". A follow-up change will update the validation to allow `rust.Adapter` in combination with serde if this option is set to true.
Reviewed By: dtolnay
Differential Revision: D98007932
fbshipit-source-id: 6ce3eb479fbc26d749ff817cc76d81587c47e419serde option to @rust.Adapter annotation1 parent 39380e1 commit e1a1ad6
1 file changed
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
347 | 358 | | |
348 | 359 | | |
349 | 360 | | |
| |||
0 commit comments