palantir / conjure-rust

Conjure support for Rust
Apache License 2.0
20 stars 11 forks source link

Fix codegen for aliases of map<double, T> and set<double> #341

Closed sfackler closed 7 months ago

sfackler commented 7 months ago

Before this PR

We generated a FromIter implementation that expected f64 instead of DoubleKey:

error[E0277]: a value of type `BTreeMap<DoubleKey, bool>` cannot be built from an iterator over elements of type `(f64, bool)`
  --> /home/sfackler/code/conjure-rust-runtime/target/debug/build/conjure-verification-api-737942bf71306d38/out/conjure/types/map_double_alias_example.rs:11:31
   |
11 |         MapDoubleAliasExample(std::iter::FromIterator::from_iter(iter))
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value of type `BTreeMap<DoubleKey, bool>` cannot be built from `std::iter::Iterator<Item=(f64, bool)>`
   |
   = help: the trait `FromIterator<(f64, bool)>` is not implemented for `BTreeMap<DoubleKey, bool>`
   = help: the trait `FromIterator<(DoubleKey, bool)>` is implemented for `BTreeMap<DoubleKey, bool>`
   = help: for that trait implementation, expected `DoubleKey`, found `f64`

After this PR

Fixed codegen for aliases of map<double, T> and set<double>.

The bad codegen hasn't hit a release, so no changelog is needed.