projectfluent / fluent-rs

Rust implementation of Project Fluent
https://projectfluent.org
Apache License 2.0
1.05k stars 95 forks source link

[fluent-fallback] Code error in example incompatable with published crates #175

Closed alerque closed 4 years ago

alerque commented 4 years ago

The Cargo.toml for fluent-fallback specifies it requires 0.11.0 of the other tools, but then it proceeds to use the versions from the relative path.

If I try to use the example code in my project based on the released 0.11.0 and 0.0.3 crates, I get an error:

error[E0271]: type mismatch resolving `<[closure@src/main.rs:144:23: 160:10 locales:_, res_path_scheme:_, res_ids:_, res_mgr:_] as std::ops::FnOnce<()>>::Output == std::option::Option<fluent_bundle::bundle::FluentBundle<_>>`
   --> src/main.rs:162:15
    |
162 |     let loc = Localization::new(
    |               ^^^^^^^^^^^^^^^^^ expected struct `fluent_bundle::bundle::FluentBundleBase`, found struct `fluent_bundle::bundle::FluentBundle`
    | 
   ::: /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/fluent-fallback-0.0.3/src/lib.rs:30:47
    |
30  |         I: Iterator<Item = FluentBundle<R>> + 'loc,
    |                                               ---- required by this bound in `fluent_fallback::Localization::<'loc, R>::new`
    |
    = note: expected enum `std::option::Option<fluent_bundle::bundle::FluentBundleBase<&fluent_bundle::resource::FluentResource, intl_memoizer::IntlLangMemoizer>>`
               found enum `std::option::Option<fluent_bundle::bundle::FluentBundle<_>>`
    = note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::FromFn<[closure@src/main.rs:144:23: 160:10 locales:_, res_path_scheme:_, res_ids:_, res_mgr:_]>`

If instead of using the crates.io release I depend on the Git HEAD version instead, I can successfully make something similar to the example code work in my project. Note I have to use Git HEAD for both fluent and fluent-fallback.

In other words there is a serious mismatch between the published versions where they are incompatible with each-other, but this has since been fixed.

It would be nice to at least bump the published patch version so that the example code works as advertised.

Note this almost certainly is related to 9ba8239.

zbraniecki commented 4 years ago

Hi. Just updated the whole toolchain. Can you try against the latest releases?

alerque commented 4 years ago

That did the trick, thanks!