bluss/maplit

support rust 2018 edition

softprops opened this issue · 5 comments

I think this might be a prerequisite for doing something like the following in upstream crates

error: cannot find macro `hashmap!` in this scope
   --> src/lib.rs:184:16
    |
184 |             Ok(maplit::hashmap!("foo".to_string() => "bar".to_string())),

I have been using this crate on 2018 edition and it works great.

I cannot get it to work using the use macro syntax for rust 2018

use maplit::hashmap;
hashmap!("foo".to_string() => "bar".to_string())

or

maplit::hashmap!("foo".to_string() => "bar".to_string())

I use:

use maplit::*;
...
hahsmap![];

Stand corrected. Got it to work for libraries/crates. Can't get it to work for benches, seems to require an extern crate

bluss commented

The macro names have to be in scope to be able to use them. It's not possible to fix this backwards compatibly for all the Rust versions we used to support, but I have now found some code that reproduces the problem you are having, and we can fix it - and updating the minimum required Rust version.

(Edit: found the backwards compat way to do it)