use the slice_pat hack in libstd too
This commit is contained in:
parent
9b1abf5c65
commit
f0174fcbee
@ -467,3 +467,15 @@ pub mod __rand {
|
||||
// the rustdoc documentation for primitive types. Using `include!`
|
||||
// because rustdoc only looks for these modules at the crate level.
|
||||
include!("primitive_docs.rs");
|
||||
|
||||
// FIXME(stage0): remove this after a snapshot
|
||||
// HACK: this is needed because the interpretation of slice
|
||||
// patterns changed between stage0 and now.
|
||||
#[cfg(stage0)]
|
||||
fn slice_pat<'a, 'b, T>(t: &'a &'b [T]) -> &'a &'b [T] {
|
||||
t
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
fn slice_pat<'a, 'b, T>(t: &'a &'b [T]) -> &'b [T] {
|
||||
*t
|
||||
}
|
||||
|
@ -560,20 +560,15 @@ impl Wtf8 {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(stage0): use slice patterns after snapshot
|
||||
#[inline]
|
||||
fn final_lead_surrogate(&self) -> Option<u16> {
|
||||
let len = self.len();
|
||||
if len < 3 {
|
||||
return None
|
||||
}
|
||||
if self.bytes[len-3] == 0xed &&
|
||||
self.bytes[len-2] >= 0xa0 &&
|
||||
self.bytes[len-2] <= 0xaf
|
||||
{
|
||||
Some(decode_surrogate(self.bytes[len-2], self.bytes[len-1]))
|
||||
} else {
|
||||
None
|
||||
match ::slice_pat(&&self.bytes[(len - 3)..]) {
|
||||
&[0xED, b2 @ 0xA0...0xAF, b3] => Some(decode_surrogate(b2, b3)),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
@ -583,13 +578,9 @@ impl Wtf8 {
|
||||
if len < 3 {
|
||||
return None
|
||||
}
|
||||
if self.bytes[0] == 0xed &&
|
||||
self.bytes[1] >= 0xb0 &&
|
||||
self.bytes[1] <= 0xbf
|
||||
{
|
||||
Some(decode_surrogate(self.bytes[1], self.bytes[2]))
|
||||
} else {
|
||||
None
|
||||
match ::slice_pat(&&self.bytes[..3]) {
|
||||
&[0xED, b2 @ 0xB0...0xBF, b3] => Some(decode_surrogate(b2, b3)),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,10 +117,10 @@ impl Drop for FindNextFileHandle {
|
||||
|
||||
impl DirEntry {
|
||||
fn new(root: &Arc<PathBuf>, wfd: &c::WIN32_FIND_DATAW) -> Option<DirEntry> {
|
||||
match &wfd.cFileName[0..3] {
|
||||
match ::slice_pat(&&wfd.cFileName[0..3]) {
|
||||
// check for '.' and '..'
|
||||
[46, 0, ..] |
|
||||
[46, 46, 0, ..] => return None,
|
||||
&[46, 0, ..] |
|
||||
&[46, 46, 0, ..] => return None,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user