Skip to content

Rollup of 12 pull requests #41098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Apr 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
57009ca
Identify missing item category in `impl`s
estebank Mar 25, 2017
c963d61
Simplify error output
estebank Mar 28, 2017
1e3bc5a
Allow using Vec::<T>::place_back for T: !Clone
nagisa Mar 29, 2017
3fa28cc
Add a note about overflow for fetch_add/fetch_sub
Mar 30, 2017
2946c41
More consistent wording
Mar 30, 2017
09ac56d
mark build::cfg::start_new_block as inline(never)
arielb1 Apr 2, 2017
29a6a9e
iter: Use underlying find/rfind for the same methods in Rev
bluss Apr 3, 2017
74f8ea2
iter: Simplification in rfind's provided implementation
bluss Apr 3, 2017
7b89bd7
Add ptr::offset_to
Amanieu Mar 31, 2017
8f31e19
Merge branch 'master' into issue-40006
estebank Apr 3, 2017
018c5c9
Make 'overlapping_inherent_impls' lint a hard error
topecongiro Apr 4, 2017
6132fb8
Replace magic number with readable sig constant
anatol Apr 4, 2017
09f42ee
Move 'overlapping_inherent_impls' test to ui
topecongiro Apr 4, 2017
db60b0b
Move 'coherence-overlapping-inherent-impl-trait' test to ui
topecongiro Apr 4, 2017
2e3f0d8
add [T]::rsplit() and rsplit_mut() #41020
jorendorff Apr 3, 2017
a45fedf
simplify implementation of [T]::splitn and friends #41020
jorendorff Apr 3, 2017
f07ebd6
Simplify HashMap Bucket interface
arthurprs Mar 15, 2017
56902fb
Fixes other targets rustlibs installation
Mar 13, 2017
1f70247
Add tracking issue for offset_to
Amanieu Apr 5, 2017
44bcd26
Reduce a table used for `Debug` impl of `str`.
lifthrasiir Mar 21, 2017
540fc2c
Rollup merge of #40479 - sezaru:master, r=alexcrichton
Apr 5, 2017
327b9be
Rollup merge of #40561 - arthurprs:hm-adapt2, r=pczarn
Apr 5, 2017
a182027
Rollup merge of #40709 - lifthrasiir:leaner-unicode-debug-str, r=alex…
Apr 5, 2017
cee0508
Rollup merge of #40815 - estebank:issue-40006, r=GuillaumeGomez
Apr 5, 2017
1fdcb79
Rollup merge of #40909 - nagisa:fix-vec-placement, r=alexcrichton
Apr 5, 2017
fc5ff66
Rollup merge of #40927 - stjepang:docs-atomic-overflow-note, r=alexcr…
Apr 5, 2017
9d07447
Rollup merge of #40943 - Amanieu:offset_to, r=alexcrichton
Apr 5, 2017
b712950
Rollup merge of #41015 - arielb1:new-block-stack, r=alexcrichton
Apr 5, 2017
5e410ba
Rollup merge of #41028 - bluss:rev-rfind, r=alexcrichton
Apr 5, 2017
a69fcfa
Rollup merge of #41052 - topecongiro:overlapping_inherent_impls, r=es…
Apr 5, 2017
fa0f102
Rollup merge of #41054 - anatol:master, r=alexcrichton
Apr 5, 2017
d8b6109
Rollup merge of #41065 - jorendorff:slice-rsplit-41020, r=alexcrichton
Apr 5, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/bootstrap/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,17 @@ pub fn install(build: &Build, stage: u32, host: &str) {
install_sh(&build, "docs", "rust-docs", stage, host, &prefix,
&docdir, &libdir, &mandir, &empty_dir);
}

for target in build.config.target.iter() {
install_sh(&build, "std", "rust-std", stage, target, &prefix,
&docdir, &libdir, &mandir, &empty_dir);
}

if build.config.rust_save_analysis {
install_sh(&build, "analysis", "rust-analysis", stage, host, &prefix,
&docdir, &libdir, &mandir, &empty_dir);
}
install_sh(&build, "std", "rust-std", stage, host, &prefix,
&docdir, &libdir, &mandir, &empty_dir);

install_sh(&build, "rustc", "rustc", stage, host, &prefix,
&docdir, &libdir, &mandir, &empty_dir);
t!(fs::remove_dir_all(&empty_dir));
Expand Down
2 changes: 2 additions & 0 deletions src/doc/unstable-book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
- [no_debug](no-debug.md)
- [non_ascii_idents](non-ascii-idents.md)
- [nonzero](nonzero.md)
- [offset_to](offset-to.md)
- [omit_gdb_pretty_printer_section](omit-gdb-pretty-printer-section.md)
- [on_unimplemented](on-unimplemented.md)
- [once_poison](once-poison.md)
Expand Down Expand Up @@ -171,6 +172,7 @@
- [slice_concat_ext](slice-concat-ext.md)
- [slice_get_slice](slice-get-slice.md)
- [slice_patterns](slice-patterns.md)
- [slice_rsplit](slice-rsplit.md)
- [sort_internals](sort-internals.md)
- [sort_unstable](sort-unstable.md)
- [specialization](specialization.md)
Expand Down
7 changes: 7 additions & 0 deletions src/doc/unstable-book/src/offset-to.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# `offset_to`

The tracking issue for this feature is: [#41079]

[#41079]: https://github.com/rust-lang/rust/issues/41079

------------------------
10 changes: 10 additions & 0 deletions src/doc/unstable-book/src/slice-rsplit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# `slice_rsplit`

The tracking issue for this feature is: [#41020]

[#41020]: https://github.com/rust-lang/rust/issues/41020

------------------------

The `slice_rsplit` feature enables two methods on slices:
`slice.rsplit(predicate)` and `slice.rsplit_mut(predicate)`.
132 changes: 98 additions & 34 deletions src/etc/char_private.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,66 @@ def get_codepoints(f):
for c in range(prev_codepoint + 1, NUM_CODEPOINTS):
yield Codepoint(c, None)

def compress_singletons(singletons):
uppers = [] # (upper, # items in lowers)
lowers = []

for i in singletons:
upper = i >> 8
lower = i & 0xff
if len(uppers) == 0 or uppers[-1][0] != upper:
uppers.append((upper, 1))
else:
upper, count = uppers[-1]
uppers[-1] = upper, count + 1
lowers.append(lower)

return uppers, lowers

def compress_normal(normal):
# lengths 0x00..0x7f are encoded as 00, 01, ..., 7e, 7f
# lengths 0x80..0x7fff are encoded as 80 80, 80 81, ..., ff fe, ff ff
compressed = [] # [truelen, (truelenaux), falselen, (falselenaux)]

prev_start = 0
for start, count in normal:
truelen = start - prev_start
falselen = count
prev_start = start + count

assert truelen < 0x8000 and falselen < 0x8000
entry = []
if truelen > 0x7f:
entry.append(0x80 | (truelen >> 8))
entry.append(truelen & 0xff)
else:
entry.append(truelen & 0x7f)
if falselen > 0x7f:
entry.append(0x80 | (falselen >> 8))
entry.append(falselen & 0xff)
else:
entry.append(falselen & 0x7f)

compressed.append(entry)

return compressed

def print_singletons(uppers, lowers, uppersname, lowersname):
print("const {}: &'static [(u8, u8)] = &[".format(uppersname))
for u, c in uppers:
print(" ({:#04x}, {}),".format(u, c))
print("];")
print("const {}: &'static [u8] = &[".format(lowersname))
for i in range(0, len(lowers), 8):
print(" {}".format(" ".join("{:#04x},".format(l) for l in lowers[i:i+8])))
print("];")

def print_normal(normal, normalname):
print("const {}: &'static [u8] = &[".format(normalname))
for v in normal:
print(" {}".format(" ".join("{:#04x},".format(i) for i in v)))
print("];")

def main():
file = get_file("http://www.unicode.org/Public/UNIDATA/UnicodeData.txt")

Expand Down Expand Up @@ -111,6 +171,11 @@ def main():
else:
normal0.append((a, b - a))

singletons0u, singletons0l = compress_singletons(singletons0)
singletons1u, singletons1l = compress_singletons(singletons1)
normal0 = compress_normal(normal0)
normal1 = compress_normal(normal1)

print("""\
// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
Expand All @@ -125,38 +190,49 @@ def main():
// NOTE: The following code was generated by "src/etc/char_private.py",
// do not edit directly!

use slice::SliceExt;

fn check(x: u16, singletons: &[u16], normal: &[u16]) -> bool {
for &s in singletons {
if x == s {
return false;
} else if x < s {
fn check(x: u16, singletonuppers: &[(u8, u8)], singletonlowers: &[u8],
normal: &[u8]) -> bool {
let xupper = (x >> 8) as u8;
let mut lowerstart = 0;
for &(upper, lowercount) in singletonuppers {
let lowerend = lowerstart + lowercount as usize;
if xupper == upper {
for &lower in &singletonlowers[lowerstart..lowerend] {
if lower == x as u8 {
return false;
}
}
} else if xupper < upper {
break;
}
lowerstart = lowerend;
}
for w in normal.chunks(2) {
let start = w[0];
let len = w[1];
let difference = (x as i32) - (start as i32);
if 0 <= difference {
if difference < len as i32 {
return false;
}

let mut x = x as i32;
let mut normal = normal.iter().cloned();
let mut current = true;
while let Some(v) = normal.next() {
let len = if v & 0x80 != 0 {
((v & 0x7f) as i32) << 8 | normal.next().unwrap() as i32
} else {
v as i32
};
x -= len;
if x < 0 {
break;
}
current = !current;
}
true
current
}

pub fn is_printable(x: char) -> bool {
let x = x as u32;
let lower = x as u16;
if x < 0x10000 {
check(lower, SINGLETONS0, NORMAL0)
check(lower, SINGLETONS0U, SINGLETONS0L, NORMAL0)
} else if x < 0x20000 {
check(lower, SINGLETONS1, NORMAL1)
check(lower, SINGLETONS1U, SINGLETONS1L, NORMAL1)
} else {\
""")
for a, b in extra:
Expand All @@ -169,22 +245,10 @@ def main():
}\
""")
print()
print("const SINGLETONS0: &'static [u16] = &[")
for s in singletons0:
print(" 0x{:x},".format(s))
print("];")
print("const SINGLETONS1: &'static [u16] = &[")
for s in singletons1:
print(" 0x{:x},".format(s))
print("];")
print("const NORMAL0: &'static [u16] = &[")
for a, b in normal0:
print(" 0x{:x}, 0x{:x},".format(a, b))
print("];")
print("const NORMAL1: &'static [u16] = &[")
for a, b in normal1:
print(" 0x{:x}, 0x{:x},".format(a, b))
print("];")
print_singletons(singletons0u, singletons0l, 'SINGLETONS0U', 'SINGLETONS0L')
print_singletons(singletons1u, singletons1l, 'SINGLETONS1U', 'SINGLETONS1L')
print_normal(normal0, 'NORMAL0')
print_normal(normal1, 'NORMAL1')

if __name__ == '__main__':
main()
2 changes: 2 additions & 0 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#![feature(shared)]
#![feature(slice_get_slice)]
#![feature(slice_patterns)]
#![feature(slice_rsplit)]
#![cfg_attr(not(test), feature(sort_unstable))]
#![feature(specialization)]
#![feature(staged_api)]
Expand All @@ -62,6 +63,7 @@
#![feature(untagged_unions)]
#![cfg_attr(not(test), feature(str_checked_slicing))]
#![cfg_attr(test, feature(rand, test))]
#![feature(offset_to)]

#![no_std]

Expand Down
68 changes: 68 additions & 0 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ pub use core::slice::{Iter, IterMut};
pub use core::slice::{SplitMut, ChunksMut, Split};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::slice::{SplitN, RSplitN, SplitNMut, RSplitNMut};
#[unstable(feature = "slice_rsplit", issue = "41020")]
pub use core::slice::{RSplit, RSplitMut};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::slice::{from_raw_parts, from_raw_parts_mut};
#[unstable(feature = "slice_get_slice", issue = "35729")]
Expand Down Expand Up @@ -779,6 +781,72 @@ impl<T> [T] {
core_slice::SliceExt::split_mut(self, pred)
}

/// Returns an iterator over subslices separated by elements that match
/// `pred`, starting at the end of the slice and working backwards.
/// The matched element is not contained in the subslices.
///
/// # Examples
///
/// ```
/// #![feature(slice_rsplit)]
///
/// let slice = [11, 22, 33, 0, 44, 55];
/// let mut iter = slice.rsplit(|num| *num == 0);
///
/// assert_eq!(iter.next().unwrap(), &[44, 55]);
/// assert_eq!(iter.next().unwrap(), &[11, 22, 33]);
/// assert_eq!(iter.next(), None);
/// ```
///
/// As with `split()`, if the first or last element is matched, an empty
/// slice will be the first (or last) item returned by the iterator.
///
/// ```
/// #![feature(slice_rsplit)]
///
/// let v = &[0, 1, 1, 2, 3, 5, 8];
/// let mut it = v.rsplit(|n| *n % 2 == 0);
/// assert_eq!(it.next().unwrap(), &[]);
/// assert_eq!(it.next().unwrap(), &[3, 5]);
/// assert_eq!(it.next().unwrap(), &[1, 1]);
/// assert_eq!(it.next().unwrap(), &[]);
/// assert_eq!(it.next(), None);
/// ```
#[unstable(feature = "slice_rsplit", issue = "41020")]
#[inline]
pub fn rsplit<F>(&self, pred: F) -> RSplit<T, F>
where F: FnMut(&T) -> bool
{
core_slice::SliceExt::rsplit(self, pred)
}

/// Returns an iterator over mutable subslices separated by elements that
/// match `pred`, starting at the end of the slice and working
/// backwards. The matched element is not contained in the subslices.
///
/// # Examples
///
/// ```
/// #![feature(slice_rsplit)]
///
/// let mut v = [100, 400, 300, 200, 600, 500];
///
/// let mut count = 0;
/// for group in v.rsplit_mut(|num| *num % 3 == 0) {
/// count += 1;
/// group[0] = count;
/// }
/// assert_eq!(v, [3, 400, 300, 2, 600, 1]);
/// ```
///
#[unstable(feature = "slice_rsplit", issue = "41020")]
#[inline]
pub fn rsplit_mut<F>(&mut self, pred: F) -> RSplitMut<T, F>
where F: FnMut(&T) -> bool
{
core_slice::SliceExt::rsplit_mut(self, pred)
}

/// Returns an iterator over subslices separated by elements that match
/// `pred`, limited to returning at most `n` items. The matched element is
/// not contained in the subslices.
Expand Down
Loading