Skip to content

Commit

Permalink
Auto merge of #56186 - kennytm:rollup, r=kennytm
Browse files Browse the repository at this point in the history
Rollup of 14 pull requests

Successful merges:

 - #55767 (Disable some pretty-printers when gdb is rust-enabled)
 - #55838 (Fix #[cfg] for step impl on ranges)
 - #55869 (Add std::iter::unfold)
 - #55945 (Ensure that the argument to `static_assert` is a `bool`)
 - #56022 (When popping in CTFE, perform validation before jumping to next statement to have a better span for the error)
 - #56048 (Add rustc_codegen_ssa to sysroot)
 - #56091 (Fix json output in the self-profiler)
 - #56097 (Fix invalid bitcast taking bool out of a union represented as a scalar)
 - #56116 (ci: Download clang/lldb from tarballs)
 - #56120 (Add unstable Literal::subspan().)
 - #56154 (Pass additional linker flags when targeting Fuchsia)
 - #56162 (std::str Adapt documentation to reality)
 - #56163 ([master] Backport 1.30.1 release notes)
 - #56168 (Fix the tracking issue for hash_raw_entry)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Nov 23, 2018
2 parents 821bad3 + 36189a2 commit 1f57e48
Show file tree
Hide file tree
Showing 27 changed files with 606 additions and 96 deletions.
19 changes: 18 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2073,6 +2073,7 @@ dependencies = [
name = "rustc-main"
version = "0.0.0"
dependencies = [
"rustc_codegen_ssa 0.0.0",
"rustc_driver 0.0.0",
"rustc_target 0.0.0",
]
Expand Down Expand Up @@ -2169,18 +2170,34 @@ dependencies = [
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_codegen_ssa 0.0.0",
"rustc_llvm 0.0.0",
]

[[package]]
name = "rustc_codegen_ssa"
version = "0.0.0"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
"jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_allocator 0.0.0",
"rustc_apfloat 0.0.0",
"rustc_codegen_utils 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_errors 0.0.0",
"rustc_fs_util 0.0.0",
"rustc_incremental 0.0.0",
"rustc_mir 0.0.0",
"rustc_target 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
"syntax_pos 0.0.0",
]

[[package]]
Expand Down
8 changes: 8 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ Cargo
[cargo-rename-reference]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml
[const-reference]: https://doc.rust-lang.org/reference/items/functions.html#const-functions

Version 1.30.1 (2018-11-08)
===========================

- [Fixed overflow ICE in rustdoc][54199]
- [Cap Cargo progress bar width at 60 in MSYS terminals][cargo/6122]

[54199]: https://github.com/rust-lang/rust/pull/54199
[cargo/6122]: https://github.com/rust-lang/cargo/pull/6122

Version 1.30.0 (2018-10-25)
==========================
Expand Down
1 change: 1 addition & 0 deletions src/ci/init_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function fetch_submodule {
}

included="src/llvm src/llvm-emscripten src/doc/book src/doc/rust-by-example"
included="$included src/tools/lld src/tools/clang src/tools/lldb"
modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
modules=($modules)
use_git=""
Expand Down
43 changes: 25 additions & 18 deletions src/etc/gdb_rust_pretty_printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
if sys.version_info[0] >= 3:
xrange = range

rust_enabled = 'set language rust' in gdb.execute('complete set language ru', to_string = True)

#===============================================================================
# GDB Pretty Printing Module for Rust
#===============================================================================
Expand Down Expand Up @@ -99,27 +101,9 @@ def rust_pretty_printer_lookup_function(gdb_val):
val = GdbValue(gdb_val)
type_kind = val.type.get_type_kind()

if type_kind == rustpp.TYPE_KIND_EMPTY:
return RustEmptyPrinter(val)

if type_kind == rustpp.TYPE_KIND_REGULAR_STRUCT:
return RustStructPrinter(val,
omit_first_field = False,
omit_type_name = False,
is_tuple_like = False)

if type_kind == rustpp.TYPE_KIND_STRUCT_VARIANT:
return RustStructPrinter(val,
omit_first_field = True,
omit_type_name = False,
is_tuple_like = False)

if type_kind == rustpp.TYPE_KIND_SLICE:
return RustSlicePrinter(val)

if type_kind == rustpp.TYPE_KIND_STR_SLICE:
return RustStringSlicePrinter(val)

if type_kind == rustpp.TYPE_KIND_STD_VEC:
return RustStdVecPrinter(val)

Expand All @@ -138,6 +122,29 @@ def rust_pretty_printer_lookup_function(gdb_val):
if type_kind == rustpp.TYPE_KIND_OS_STRING:
return RustOsStringPrinter(val)

# Checks after this point should only be for "compiler" types --
# things that gdb's Rust language support knows about.
if rust_enabled:
return None

if type_kind == rustpp.TYPE_KIND_EMPTY:
return RustEmptyPrinter(val)

if type_kind == rustpp.TYPE_KIND_REGULAR_STRUCT:
return RustStructPrinter(val,
omit_first_field = False,
omit_type_name = False,
is_tuple_like = False)

if type_kind == rustpp.TYPE_KIND_STRUCT_VARIANT:
return RustStructPrinter(val,
omit_first_field = True,
omit_type_name = False,
is_tuple_like = False)

if type_kind == rustpp.TYPE_KIND_STR_SLICE:
return RustStringSlicePrinter(val)

if type_kind == rustpp.TYPE_KIND_TUPLE:
return RustStructPrinter(val,
omit_first_field = False,
Expand Down
6 changes: 4 additions & 2 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@
//!
//! // next() is the only required method
//! fn next(&mut self) -> Option<usize> {
//! // increment our count. This is why we started at zero.
//! // Increment our count. This is why we started at zero.
//! self.count += 1;
//!
//! // check to see if we've finished counting or not.
//! // Check to see if we've finished counting or not.
//! if self.count < 6 {
//! Some(self.count)
//! } else {
Expand Down Expand Up @@ -339,6 +339,8 @@ pub use self::sources::{RepeatWith, repeat_with};
pub use self::sources::{Empty, empty};
#[stable(feature = "iter_once", since = "1.2.0")]
pub use self::sources::{Once, once};
#[unstable(feature = "iter_unfold", issue = "55977")]
pub use self::sources::{Unfold, unfold, Successors, successors};

#[stable(feature = "rust1", since = "1.0.0")]
pub use self::traits::{FromIterator, IntoIterator, DoubleEndedIterator, Extend};
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/iter/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ macro_rules! step_impl_no_between {
}

step_impl_unsigned!(usize u8 u16);
#[cfg(not(target_pointer_witdth = "16"))]
#[cfg(not(target_pointer_width = "16"))]
step_impl_unsigned!(u32);
#[cfg(target_pointer_witdth = "16")]
#[cfg(target_pointer_width = "16")]
step_impl_no_between!(u32);
step_impl_signed!([isize: usize] [i8: u8] [i16: u16]);
#[cfg(not(target_pointer_witdth = "16"))]
#[cfg(not(target_pointer_width = "16"))]
step_impl_signed!([i32: u32]);
#[cfg(target_pointer_witdth = "16")]
#[cfg(target_pointer_width = "16")]
step_impl_no_between!(i32);
#[cfg(target_pointer_width = "64")]
step_impl_unsigned!(u64);
Expand Down
161 changes: 161 additions & 0 deletions src/libcore/iter/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,3 +386,164 @@ impl<T> FusedIterator for Once<T> {}
pub fn once<T>(value: T) -> Once<T> {
Once { inner: Some(value).into_iter() }
}

/// Creates a new iterator where each iteration calls the provided closure
/// `F: FnMut(&mut St) -> Option<T>`.
///
/// This allows creating a custom iterator with any behavior
/// without using the more verbose syntax of creating a dedicated type
/// and implementing the `Iterator` trait for it.
///
/// In addition to its captures and environment,
/// the closure is given a mutable reference to some state
/// that is preserved across iterations.
/// That state starts as the given `initial_state` value.
///
/// Note that the `Unfold` iterator doesn’t make assumptions about the behavior of the closure,
/// and therefore conservatively does not implement [`FusedIterator`],
/// or override [`Iterator::size_hint`] from its default `(0, None)`.
///
/// [`FusedIterator`]: trait.FusedIterator.html
/// [`Iterator::size_hint`]: trait.Iterator.html#method.size_hint
///
/// # Examples
///
/// Let’s re-implement the counter iterator from [module-level documentation]:
///
/// [module-level documentation]: index.html
///
/// ```
/// #![feature(iter_unfold)]
/// let counter = std::iter::unfold(0, |count| {
/// // Increment our count. This is why we started at zero.
/// *count += 1;
///
/// // Check to see if we've finished counting or not.
/// if *count < 6 {
/// Some(*count)
/// } else {
/// None
/// }
/// });
/// assert_eq!(counter.collect::<Vec<_>>(), &[1, 2, 3, 4, 5]);
/// ```
#[inline]
#[unstable(feature = "iter_unfold", issue = "55977")]
pub fn unfold<St, T, F>(initial_state: St, f: F) -> Unfold<St, F>
where F: FnMut(&mut St) -> Option<T>
{
Unfold {
state: initial_state,
f,
}
}

/// An iterator where each iteration calls the provided closure `F: FnMut(&mut St) -> Option<T>`.
///
/// This `struct` is created by the [`unfold`] function.
/// See its documentation for more.
///
/// [`unfold`]: fn.unfold.html
#[derive(Clone)]
#[unstable(feature = "iter_unfold", issue = "55977")]
pub struct Unfold<St, F> {
state: St,
f: F,
}

#[unstable(feature = "iter_unfold", issue = "55977")]
impl<St, T, F> Iterator for Unfold<St, F>
where F: FnMut(&mut St) -> Option<T>
{
type Item = T;

#[inline]
fn next(&mut self) -> Option<Self::Item> {
(self.f)(&mut self.state)
}
}

#[unstable(feature = "iter_unfold", issue = "55977")]
impl<St: fmt::Debug, F> fmt::Debug for Unfold<St, F> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Unfold")
.field("state", &self.state)
.finish()
}
}

/// Creates a new iterator where each successive item is computed based on the preceding one.
///
/// The iterator starts with the given first item (if any)
/// and calls the given `FnMut(&T) -> Option<T>` closure to compute each item’s successor.
///
/// ```
/// #![feature(iter_unfold)]
/// use std::iter::successors;
///
/// let powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10));
/// assert_eq!(powers_of_10.collect::<Vec<_>>(), &[1, 10, 100, 1_000, 10_000]);
/// ```
#[unstable(feature = "iter_unfold", issue = "55977")]
pub fn successors<T, F>(first: Option<T>, succ: F) -> Successors<T, F>
where F: FnMut(&T) -> Option<T>
{
// If this function returned `impl Iterator<Item=T>`
// it could be based on `unfold` and not need a dedicated type.
// However having a named `Successors<T, F>` type allows it to be `Clone` when `T` and `F` are.
Successors {
next: first,
succ,
}
}

/// An new iterator where each successive item is computed based on the preceding one.
///
/// This `struct` is created by the [`successors`] function.
/// See its documentation for more.
///
/// [`successors`]: fn.successors.html
#[derive(Clone)]
#[unstable(feature = "iter_unfold", issue = "55977")]
pub struct Successors<T, F> {
next: Option<T>,
succ: F,
}

#[unstable(feature = "iter_unfold", issue = "55977")]
impl<T, F> Iterator for Successors<T, F>
where F: FnMut(&T) -> Option<T>
{
type Item = T;

#[inline]
fn next(&mut self) -> Option<Self::Item> {
self.next.take().map(|item| {
self.next = (self.succ)(&item);
item
})
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
if self.next.is_some() {
(1, None)
} else {
(0, Some(0))
}
}
}

#[unstable(feature = "iter_unfold", issue = "55977")]
impl<T, F> FusedIterator for Successors<T, F>
where F: FnMut(&T) -> Option<T>
{}

#[unstable(feature = "iter_unfold", issue = "55977")]
impl<T: fmt::Debug, F> fmt::Debug for Successors<T, F> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Successors")
.field("next", &self.next)
.finish()
}
}
6 changes: 2 additions & 4 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1424,10 +1424,8 @@ fn contains_nonascii(x: usize) -> bool {
(x & NONASCII_MASK) != 0
}

/// Walks through `iter` checking that it's a valid UTF-8 sequence,
/// returning `true` in that case, or, if it is invalid, `false` with
/// `iter` reset such that it is pointing at the first byte in the
/// invalid sequence.
/// Walks through `v` checking that it's a valid UTF-8 sequence,
/// returning `Ok(())` in that case, or, if it is invalid, `Err(err)`.
#[inline]
fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
let mut index = 0;
Expand Down
11 changes: 11 additions & 0 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,17 @@ fn test_repeat_with_take_collect() {
assert_eq!(v, vec![1, 2, 4, 8, 16]);
}

#[test]
fn test_successors() {
let mut powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10));
assert_eq!(powers_of_10.by_ref().collect::<Vec<_>>(), &[1, 10, 100, 1_000, 10_000]);
assert_eq!(powers_of_10.next(), None);

let mut empty = successors(None::<u32>, |_| unimplemented!());
assert_eq!(empty.next(), None);
assert_eq!(empty.next(), None);
}

#[test]
fn test_fuse() {
let mut it = 0..3;
Expand Down
1 change: 1 addition & 0 deletions src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#![feature(flt2dec)]
#![feature(fmt_internals)]
#![feature(hashmap_internals)]
#![feature(iter_unfold)]
#![feature(pattern)]
#![feature(range_is_empty)]
#![feature(raw)]
Expand Down
Loading

0 comments on commit 1f57e48

Please sign in to comment.