Skip to content

Commit

Permalink
Fix handling of map adapters in expansion of const values
Browse files Browse the repository at this point in the history
Summary:
Since the whole constant's value ends up being wrapped in `from_thrift(...)`:

https://www.internalfb.com/code/fbsource/[e4857a1da0accd0665a7ecf2cc85d98488e3986a]/fbcode/thrift/compiler/generate/templates/rust/lib/const.mustache?lines=37-41

the value we generate inside this cannot be the already-adapted type. It has to be the underlying Thrift type.

Reviewed By: capickett

Differential Revision: D66845279

fbshipit-source-id: ff6727a6e8e1bb37d458d2dd16f47d1e0b52a854
  • Loading branch information
David Tolnay authored and facebook-github-bot committed Dec 5, 2024
1 parent 6ce1db5 commit 70d34d8
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@
}}{{#value:mapEntries}}
{{value:indent}}{
{{value:indent}}#[inline(never)]
{{value:indent}}fn __do_insert(map: &mut {{>lib/rawtype}}) {
{{value:indent}}fn __do_insert(map: &mut {{!
}}{{#type:has_adapter?}}{{>lib/adapter/qualified}}::StandardType{{/type:has_adapter?}}{{!
}}{{^type:has_adapter?}}{{>lib/type}}{{/type:has_adapter?}}{{!
}}) {
{{value:indent}}map.insert({{!
}}{{#entry:key}}{{!
}}{{#value:floatingPoint?}}{{!
Expand Down

0 comments on commit 70d34d8

Please sign in to comment.