File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 294294#![ feature( f128) ]
295295#![ feature( ffi_const) ]
296296#![ feature( formatting_options) ]
297+ #![ feature( hash_map_internals) ]
297298#![ feature( hash_map_macro) ]
298299#![ feature( if_let_guard) ]
299300#![ feature( intra_doc_pointers) ]
302303#![ feature( lang_items) ]
303304#![ feature( link_cfg) ]
304305#![ feature( linkage) ]
305- #![ feature( macro_metavar_expr) ]
306306#![ feature( macro_metavar_expr_concat) ]
307307#![ feature( maybe_uninit_fill) ]
308308#![ feature( min_specialization) ]
Original file line number Diff line number Diff line change @@ -380,6 +380,17 @@ macro_rules! dbg {
380380 } ;
381381}
382382
383+ #[ doc( hidden) ]
384+ #[ macro_export]
385+ #[ unstable( feature = "hash_map_internals" , issue = "none" ) ]
386+ macro_rules! repetition_utils {
387+ ( @count $( $tokens: tt) ,* ) => { {
388+ [ $( $crate:: repetition_count!( @replace $tokens => ( ) ) ) ,* ] . len( )
389+ } } ;
390+
391+ ( @replace $x: tt => $y: tt) => { $y }
392+ }
393+
383394/// Creates a [`HashMap`] containing the arguments.
384395///
385396/// This macro creates or either an empty [`HashMap`] using
@@ -423,15 +434,17 @@ macro_rules! dbg {
423434/// [`HashMap::new`]: crate::collections::HashMap::new
424435/// [`HashMap::insert`]: crate::collections::HashMap::insert
425436#[ macro_export]
426- #[ allow_internal_unstable( macro_metavar_expr ) ]
437+ #[ allow_internal_unstable( hash_map_internals ) ]
427438#[ unstable( feature = "hash_map_macro" , issue = "144032" ) ]
428439macro_rules! hash_map {
429440 ( ) => { {
430441 $crate:: collections:: HashMap :: new( )
431442 } } ;
432443
433444 ( $( $key: expr => $value: expr ) ,* $( , ) ? ) => { {
434- let mut map = $crate:: collections:: HashMap :: with_capacity( ${ count( $key) } ) ;
445+ let mut map = $crate:: collections:: HashMap :: with_capacity(
446+ const { $crate:: repetition_utils( @count $( $key) ,* ) }
447+ ) ;
435448 $( map. insert( $key, $value) ; ) *
436449 map
437450 } }
You can’t perform that action at this time.
0 commit comments