You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[test]#[ignore]fntype_override(){// The macro should always use std::collections::HashMap and ignore crate::std::collections::HashMapmod std {pubmod collections {pubstructHashMap;implHashMap{#[allow(dead_code)]pubfnnew() -> Self{panic!("Do not allow users to override which HashMap is used");}#[allow(dead_code)]pubfninsert<K,V>(&mutself,_key:K,_val:V){panic!("Do not allow users to override which HashMap is used");}}}}let _empty:::std::collections::HashMap<(),()> = hashmap!();let _without_comma = hashmap!(1 => 2,3 => 4);let _with_trailing = hashmap!(1 => 2,3 => 4,);}
incorrectly produces a compiler error when the correct std::collections::HashMap is used. I believe the intended purpose was to panic if the incorrect version was used, but it also breaks compiling the whole crate since rust throws a compiler error. Instead, we should use simple_trybuild::compile_fail to detect if the build succeeds. If it does, the hashmap macro was built incorrectly and we will fail the build. If it fails to compile, the usage is correctly using the std struct (presumably no one is going to build their own implementation of HashMap, though it would be technically permissible).
The text was updated successfully, but these errors were encountered:
At Exercism we use our Community Forum, not GitHub issues, as the primary place for discussion. That allows maintainers and contributors from across Exercism's ecosystem to discuss your problems/ideas/suggestions without them having to subscribe to hundreds of repositories.
This issue will be automatically closed. Please use this link to copy your GitHub Issue into a new topic on the forum, where we look forward to chatting with you!
If you're interested in learning more about this auto-responder, please read this blog post.
This code in tests/macros.rs:
incorrectly produces a compiler error when the correct
std::collections::HashMap
is used. I believe the intended purpose was to panic if the incorrect version was used, but it also breaks compiling the whole crate since rust throws a compiler error. Instead, we should use simple_trybuild::compile_fail to detect if the build succeeds. If it does, thehashmap
macro was built incorrectly and we will fail the build. If it fails to compile, the usage is correctly using the std struct (presumably no one is going to build their own implementation ofHashMap
, though it would be technically permissible).The text was updated successfully, but these errors were encountered: