Skip to content

Commit 3de4017

Browse files
committed
Unconditionally use MaybeUninit
This raises the minimum Rust version to 1.36.0, so this is a breaking change.
1 parent 6c69040 commit 3de4017

File tree

4 files changed

+8
-33
lines changed

4 files changed

+8
-33
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ rust:
33
- nightly
44
- beta
55
- stable
6-
- 1.31.0
6+
- 1.36.0
77

88
script:
99
- cargo build --verbose

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cssparser"
3-
version = "0.25.9"
3+
version = "0.26.0"
44
authors = [ "Simon Sapin <[email protected]>" ]
55

66
description = "Rust implementation of CSS Syntax Level 3"
@@ -19,7 +19,7 @@ difference = "2.0"
1919
encoding_rs = "0.8"
2020

2121
[dependencies]
22-
cssparser-macros = {path = "./macros", version = "0.3.3"}
22+
cssparser-macros = {path = "./macros", version = "0.4.0"}
2323
dtoa-short = "0.3"
2424
heapsize = {version = ">= 0.3, < 0.5", optional = true}
2525
itoa = "0.4"

macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cssparser-macros"
3-
version = "0.3.6"
3+
version = "0.4.0"
44
authors = ["Simon Sapin <[email protected]>"]
55
description = "Procedural macros for cssparser"
66
documentation = "https://docs.rs/cssparser-macros/"

src/macros.rs

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -111,41 +111,16 @@ macro_rules! ascii_case_insensitive_phf_map {
111111
macro_rules! cssparser_internal__to_lowercase {
112112
($input: expr, $BUFFER_SIZE: expr => $output: ident) => {
113113
let mut buffer;
114-
// Safety: `buffer` is only used in `_internal__to_lowercase`,
115-
// which initializes with `copy_from_slice` the part of the buffer it uses,
116-
// before it uses it.
117114
#[allow(unsafe_code)]
118-
let buffer = unsafe { cssparser_internal__uninit!(buffer, $BUFFER_SIZE) };
115+
let buffer = unsafe {
116+
buffer = ::std::mem::MaybeUninit::<[u8; $BUFFER_SIZE]>::uninit();
117+
&mut *(buffer.as_mut_ptr())
118+
};
119119
let input: &str = $input;
120120
let $output = $crate::_internal__to_lowercase(buffer, input);
121121
};
122122
}
123123

124-
#[cfg(has_std__mem__MaybeUninit)]
125-
#[macro_export]
126-
#[doc(hidden)]
127-
macro_rules! cssparser_internal__uninit {
128-
($buffer: ident, $BUFFER_SIZE: expr) => {
129-
{
130-
$buffer = ::std::mem::MaybeUninit::<[u8; $BUFFER_SIZE]>::uninit();
131-
&mut *($buffer.as_mut_ptr())
132-
}
133-
}
134-
}
135-
136-
// FIXME: remove this when we require Rust 1.36
137-
#[cfg(not(has_std__mem__MaybeUninit))]
138-
#[macro_export]
139-
#[doc(hidden)]
140-
macro_rules! cssparser_internal__uninit {
141-
($buffer: ident, $BUFFER_SIZE: expr) => {
142-
{
143-
$buffer = ::std::mem::uninitialized::<[u8; $BUFFER_SIZE]>();
144-
&mut $buffer
145-
}
146-
}
147-
}
148-
149124
/// Implementation detail of match_ignore_ascii_case! and ascii_case_insensitive_phf_map! macros.
150125
///
151126
/// **This function is not part of the public API. It can change or be removed between any verisons.**

0 commit comments

Comments
 (0)