Update bootstrap compiler

Also remove a number of `stage0` annotations and such
This commit is contained in:
Alex Crichton
2017-11-29 12:14:03 -08:00
parent 78fcf33883
commit a850bb0e5d
13 changed files with 66 additions and 289 deletions

View File

@@ -298,198 +298,6 @@ pub trait AsciiExt {
fn is_ascii_control(&self) -> bool { unimplemented!(); }
}
// FIXME(LukasKalbertodt): this impl block can be removed in the future. This is
// possible once the stage0 compiler is new enough to contain the inherent
// ascii methods for `[str]`. See FIXME comment further down.
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
impl AsciiExt for str {
type Owned = String;
#[inline]
fn is_ascii(&self) -> bool {
self.bytes().all(|b| b.is_ascii())
}
#[inline]
fn to_ascii_uppercase(&self) -> String {
let mut bytes = self.as_bytes().to_vec();
bytes.make_ascii_uppercase();
// make_ascii_uppercase() preserves the UTF-8 invariant.
unsafe { String::from_utf8_unchecked(bytes) }
}
#[inline]
fn to_ascii_lowercase(&self) -> String {
let mut bytes = self.as_bytes().to_vec();
bytes.make_ascii_lowercase();
// make_ascii_uppercase() preserves the UTF-8 invariant.
unsafe { String::from_utf8_unchecked(bytes) }
}
#[inline]
fn eq_ignore_ascii_case(&self, other: &str) -> bool {
self.as_bytes().eq_ignore_ascii_case(other.as_bytes())
}
fn make_ascii_uppercase(&mut self) {
let me = unsafe { self.as_bytes_mut() };
me.make_ascii_uppercase()
}
fn make_ascii_lowercase(&mut self) {
let me = unsafe { self.as_bytes_mut() };
me.make_ascii_lowercase()
}
#[inline]
fn is_ascii_alphabetic(&self) -> bool {
self.bytes().all(|b| b.is_ascii_alphabetic())
}
#[inline]
fn is_ascii_uppercase(&self) -> bool {
self.bytes().all(|b| b.is_ascii_uppercase())
}
#[inline]
fn is_ascii_lowercase(&self) -> bool {
self.bytes().all(|b| b.is_ascii_lowercase())
}
#[inline]
fn is_ascii_alphanumeric(&self) -> bool {
self.bytes().all(|b| b.is_ascii_alphanumeric())
}
#[inline]
fn is_ascii_digit(&self) -> bool {
self.bytes().all(|b| b.is_ascii_digit())
}
#[inline]
fn is_ascii_hexdigit(&self) -> bool {
self.bytes().all(|b| b.is_ascii_hexdigit())
}
#[inline]
fn is_ascii_punctuation(&self) -> bool {
self.bytes().all(|b| b.is_ascii_punctuation())
}
#[inline]
fn is_ascii_graphic(&self) -> bool {
self.bytes().all(|b| b.is_ascii_graphic())
}
#[inline]
fn is_ascii_whitespace(&self) -> bool {
self.bytes().all(|b| b.is_ascii_whitespace())
}
#[inline]
fn is_ascii_control(&self) -> bool {
self.bytes().all(|b| b.is_ascii_control())
}
}
// FIXME(LukasKalbertodt): this impl block can be removed in the future. This is
// possible once the stage0 compiler is new enough to contain the inherent
// ascii methods for `[u8]`. See FIXME comment further down.
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
impl AsciiExt for [u8] {
type Owned = Vec<u8>;
#[inline]
fn is_ascii(&self) -> bool {
self.iter().all(|b| b.is_ascii())
}
#[inline]
fn to_ascii_uppercase(&self) -> Vec<u8> {
let mut me = self.to_vec();
me.make_ascii_uppercase();
return me
}
#[inline]
fn to_ascii_lowercase(&self) -> Vec<u8> {
let mut me = self.to_vec();
me.make_ascii_lowercase();
return me
}
#[inline]
fn eq_ignore_ascii_case(&self, other: &[u8]) -> bool {
self.len() == other.len() &&
self.iter().zip(other).all(|(a, b)| {
a.eq_ignore_ascii_case(b)
})
}
fn make_ascii_uppercase(&mut self) {
for byte in self {
byte.make_ascii_uppercase();
}
}
fn make_ascii_lowercase(&mut self) {
for byte in self {
byte.make_ascii_lowercase();
}
}
#[inline]
fn is_ascii_alphabetic(&self) -> bool {
self.iter().all(|b| b.is_ascii_alphabetic())
}
#[inline]
fn is_ascii_uppercase(&self) -> bool {
self.iter().all(|b| b.is_ascii_uppercase())
}
#[inline]
fn is_ascii_lowercase(&self) -> bool {
self.iter().all(|b| b.is_ascii_lowercase())
}
#[inline]
fn is_ascii_alphanumeric(&self) -> bool {
self.iter().all(|b| b.is_ascii_alphanumeric())
}
#[inline]
fn is_ascii_digit(&self) -> bool {
self.iter().all(|b| b.is_ascii_digit())
}
#[inline]
fn is_ascii_hexdigit(&self) -> bool {
self.iter().all(|b| b.is_ascii_hexdigit())
}
#[inline]
fn is_ascii_punctuation(&self) -> bool {
self.iter().all(|b| b.is_ascii_punctuation())
}
#[inline]
fn is_ascii_graphic(&self) -> bool {
self.iter().all(|b| b.is_ascii_graphic())
}
#[inline]
fn is_ascii_whitespace(&self) -> bool {
self.iter().all(|b| b.is_ascii_whitespace())
}
#[inline]
fn is_ascii_control(&self) -> bool {
self.iter().all(|b| b.is_ascii_control())
}
}
macro_rules! delegating_ascii_methods {
() => {
#[inline]
@@ -562,10 +370,6 @@ impl AsciiExt for char {
delegating_ascii_ctype_methods!();
}
// FIXME(LukasKalbertodt): the macro invocation should replace the impl block
// for `[u8]` above. But this is not possible until the stage0 compiler is new
// enough to contain the inherent ascii methods for `[u8]`.
#[cfg(not(stage0))]
#[stable(feature = "rust1", since = "1.0.0")]
impl AsciiExt for [u8] {
type Owned = Vec<u8>;
@@ -623,10 +427,6 @@ impl AsciiExt for [u8] {
}
}
// FIXME(LukasKalbertodt): the macro invocation should replace the impl block
// for `str` above. But this is not possible until the stage0 compiler is new
// enough to contain the inherent ascii methods for `str`.
#[cfg(not(stage0))]
#[stable(feature = "rust1", since = "1.0.0")]
impl AsciiExt for str {
type Owned = String;