projectfluent / fluent-rs

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

Invalid Rust code in resmgr: cannot infer type #174

Closed alerque closed 4 years ago

alerque commented 4 years ago

This line of code as in the example will not compile for me:

https://github.com/projectfluent/fluent-rs/blob/c9e456515f4c084eb9650f3910722a31707a6b32/fluent-resmgr/examples/simple-resmgr.rs#L56

In the context of my app (slightly different args but trying to copy this example pletty literally, I get this error that suggests the problem is upstream from my code:

error[E0282]: type annotations needed for `std::vec::Vec<T>`
  --> src/main.rs:90:21
   |
90 |     let resources = vec!["cli.ftl".into(), "cli-errors.ftl".into()];
   |         ---------   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
   |         |
   |         consider giving `resources` the explicit type `std::vec::Vec<T>`, where the type parameter `T` is specified
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

I have to do something like this:

let resources: std::vec::Vec<String> = ...
zbraniecki commented 4 years ago

Hi, can you try against the latest releases?

alerque commented 4 years ago

I am unable to confirm this one is fixed in my own code (I ditched following along with resmgr and started using langneg instead, which have similar but different code examples to handle a lot of the same functionality). Given that the example code I linked to works, I thinks it's probably safe to call this a non issue.

$ cargo run -p fluent-resmgr --example simple-resmgr 1
"⁨1⁩" has ⁨0⁩ Collatz steps.
alerque commented 4 years ago

Looking at Git logs I think I must have bumped into this before I started using the Git HEAD version, which would mean I was following examples from master but building them on an older release. I'll shout if it crops up again but I think this is probably resolved.