File tree Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " cssparser"
3- version = " 0.25.7 "
3+ version = " 0.25.8 "
44authors = [ " Simon Sapin <simon.sapin@exyr.org>" ]
55
66description = " Rust implementation of CSS Syntax Level 3"
@@ -30,6 +30,7 @@ serde = {version = "1.0", optional = true}
3030smallvec = " 0.6"
3131
3232[build-dependencies ]
33+ autocfg = " 0.1.4"
3334syn = { version = " 0.15.12" , features = [" extra-traits" , " fold" , " full" ] }
3435quote = " 0.6"
3536proc-macro2 = " 0.4"
Original file line number Diff line number Diff line change 22 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44
5+ extern crate autocfg;
56#[ macro_use]
67extern crate quote;
78#[ macro_use]
@@ -49,5 +50,7 @@ fn main() {
4950 println ! ( "cargo:rustc-cfg=rustc_has_pr45225" )
5051 }
5152
53+ autocfg:: new ( ) . emit_has_path ( "std::mem::MaybeUninit" ) ;
54+
5255 codegen:: main ( ) ;
5356}
Original file line number Diff line number Diff line change @@ -110,13 +110,26 @@ macro_rules! ascii_case_insensitive_phf_map {
110110#[ doc( hidden) ]
111111macro_rules! cssparser_internal__to_lowercase {
112112 ( $input: expr, $BUFFER_SIZE: expr => $output: ident) => {
113- // mem::uninitialized() is ok because `buffer` is only used in `_internal__to_lowercase`,
113+ let mut buffer;
114+ // Safety: `buffer` is only used in `_internal__to_lowercase`,
114115 // which initializes with `copy_from_slice` the part of the buffer it uses,
115116 // before it uses it.
116117 #[ allow( unsafe_code) ]
117- let mut buffer: [ u8 ; $BUFFER_SIZE] = unsafe { :: std:: mem:: uninitialized( ) } ;
118+ let buffer = unsafe {
119+ // FIXME: remove this when we require Rust 1.36
120+ #[ cfg( not( has_std__mem__MaybeUninit) ) ]
121+ {
122+ buffer = :: std:: mem:: uninitialized:: <[ u8 ; $BUFFER_SIZE] >( ) ;
123+ & mut buffer
124+ }
125+ #[ cfg( has_std__mem__MaybeUninit) ]
126+ {
127+ buffer = :: std:: mem:: MaybeUninit :: <[ u8 ; $BUFFER_SIZE] >:: uninit( ) ;
128+ & mut * ( buffer. as_mut_ptr( ) )
129+ }
130+ } ;
118131 let input: & str = $input;
119- let $output = $crate:: _internal__to_lowercase( & mut buffer, input) ;
132+ let $output = $crate:: _internal__to_lowercase( buffer, input) ;
120133 } ;
121134}
122135
You can’t perform that action at this time.
0 commit comments