File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -121,11 +121,19 @@ macro_rules! ascii_case_insensitive_phf_map {
121121#[ doc( hidden) ]
122122macro_rules! _cssparser_internal_to_lowercase {
123123 ( $input: expr, $BUFFER_SIZE: expr => $output: ident) => {
124- #[ allow( unsafe_code) ]
125- let mut buffer = unsafe {
126- :: std:: mem:: MaybeUninit :: <[ :: std:: mem:: MaybeUninit <u8 >; $BUFFER_SIZE] >:: uninit( )
127- . assume_init( )
128- } ;
124+ /// Create a new array of MaybeUninit<T> items, in an uninitialized state.
125+ #[ inline( always) ]
126+ fn create_uninit_array<const N : usize >( ) -> [ :: std:: mem:: MaybeUninit <u8 >; N ] {
127+ unsafe {
128+ // SAFETY: An uninitialized `[MaybeUninit<_>; LEN]` is valid.
129+ // See: https://doc.rust-lang.org/stable/core/mem/union.MaybeUninit.html#method.uninit_array
130+ :: std:: mem:: MaybeUninit :: <[ :: std:: mem:: MaybeUninit <u8 >; N ] >:: uninit( )
131+ . assume_init( )
132+ }
133+ }
134+
135+ const BUFFER_SIZE : usize = $BUFFER_SIZE as usize ;
136+ let mut buffer = create_uninit_array:: <BUFFER_SIZE >( ) ;
129137 let input: & str = $input;
130138 let $output = $crate:: _cssparser_internal_to_lowercase( & mut buffer, input) ;
131139 } ;
You can’t perform that action at this time.
0 commit comments