Skip to content

Commit

Permalink
Auto merge of rust-lang#74235 - Manishearth:rollup-bgs3q14, r=Manishe…
Browse files Browse the repository at this point in the history
…arth

Rollup of 19 pull requests

Successful merges:

 - rust-lang#71322 (Accept tuple.0.0 as tuple indexing (take 2))
 - rust-lang#72303 (Add core::future::{poll_fn, PollFn})
 - rust-lang#73862 (Stabilize casts and coercions to `&[T]` in const fn)
 - rust-lang#73887 (stabilize const mem::forget)
 - rust-lang#73989 (adjust ub-enum test to be endianess-independent)
 - rust-lang#74045 (Explain effects of debugging options from config.toml)
 - rust-lang#74076 (Add `read_exact_at` and `write_all_at` to WASI's `FileExt`)
 - rust-lang#74099 (Add VecDeque::range* methods)
 - rust-lang#74100 (Use str::strip* in bootstrap)
 - rust-lang#74103 (Only add CFGuard on `windows-msvc` targets)
 - rust-lang#74109 (Only allow `repr(i128/u128)` on enum)
 - rust-lang#74122 (Start-up clean-up)
 - rust-lang#74125 (Correctly mark the ending span of a match arm)
 - rust-lang#74127 (Avoid "whitelist")
 - rust-lang#74129 (:arrow_up: rust-analyzer)
 - rust-lang#74135 (Update books)
 - rust-lang#74145 (Update rust-installer to latest version)
 - rust-lang#74161 (Fix  disabled dockerfiles)
 - rust-lang#74162 (take self by value in ToPredicate)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Jul 11, 2020
2 parents daecab3 + 79fc386 commit 346aec9
Show file tree
Hide file tree
Showing 130 changed files with 1,599 additions and 596 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1366,8 +1366,8 @@ checksum = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d"
name = "installer"
version = "0.0.0"
dependencies = [
"anyhow",
"clap",
"failure",
"flate2",
"lazy_static",
"num_cpus",
Expand Down
8 changes: 6 additions & 2 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@
#codegen-units-std = 1

# Whether or not debug assertions are enabled for the compiler and standard
# library.
# library. Debug assertions control the maximum log level used by rustc. When
# enabled calls to `trace!` and `debug!` macros are preserved in the compiled
# binary, otherwise they are omitted.
#
# Defaults to rust.debug value
#debug-assertions = false
Expand All @@ -331,7 +333,9 @@

# Debuginfo level for most of Rust code, corresponds to the `-C debuginfo=N` option of `rustc`.
# `0` - no debug info
# `1` - line tables only
# `1` - line tables only - sufficient to generate backtraces that include line
# information and inlined functions, set breakpoints at source code
# locations, and step through execution in a debugger.
# `2` - full debug info with variable and type information
# Can be overridden for specific subsets of Rust code (rustc, std or tools).
# Debuginfo for tests run with compiletest is not controlled by this option
Expand Down
9 changes: 5 additions & 4 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,10 +963,11 @@ pub fn run_cargo(
.collect::<Vec<_>>();
for (prefix, extension, expected_len) in toplevel {
let candidates = contents.iter().filter(|&&(_, ref filename, ref meta)| {
filename.starts_with(&prefix[..])
&& filename[prefix.len()..].starts_with('-')
&& filename.ends_with(&extension[..])
&& meta.len() == expected_len
meta.len() == expected_len
&& filename
.strip_prefix(&prefix[..])
.map(|s| s.starts_with('-') && s.ends_with(&extension[..]))
.unwrap_or(false)
});
let max = candidates
.max_by_key(|&&(_, _, ref metadata)| FileTime::from_last_modification_time(metadata));
Expand Down
6 changes: 4 additions & 2 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,6 @@ impl Step for Std {
builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "rustdoc");
compile::std_cargo(builder, target, compiler.stage, &mut cargo);

// Keep a whitelist so we do not build internal stdlib crates, these will be
// build by the rustc step later if enabled.
cargo.arg("-p").arg(package);
// Create all crate output directories first to make sure rustdoc uses
// relative links.
Expand All @@ -460,6 +458,10 @@ impl Step for Std {

builder.run(&mut cargo.into());
};
// Only build the following crates. While we could just iterate over the
// folder structure, that would also build internal crates that we do
// not want to show in documentation. These crates will later be visited
// by the rustc step, so internal documentation will show them.
let krates = ["alloc", "core", "std", "proc_macro", "test"];
for krate in &krates {
run_cargo_rustdoc_for(krate);
Expand Down
11 changes: 5 additions & 6 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,9 @@ impl Build {
output(Command::new(&build.initial_rustc).arg("--version").arg("--verbose"));
let local_release = local_version_verbose
.lines()
.filter(|x| x.starts_with("release:"))
.filter_map(|x| x.strip_prefix("release:"))
.next()
.unwrap()
.trim_start_matches("release:")
.trim();
let my_version = channel::CFG_RELEASE_NUM;
if local_release.split('.').take(2).eq(my_version.split('.').take(2)) {
Expand Down Expand Up @@ -1089,10 +1088,10 @@ impl Build {
let toml_file_name = self.src.join(&format!("src/tools/{}/Cargo.toml", package));
let toml = t!(fs::read_to_string(&toml_file_name));
for line in toml.lines() {
let prefix = "version = \"";
let suffix = "\"";
if line.starts_with(prefix) && line.ends_with(suffix) {
return line[prefix.len()..line.len() - suffix.len()].to_string();
if let Some(stripped) =
line.strip_prefix("version = \"").and_then(|s| s.strip_suffix("\""))
{
return stripped.to_owned();
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/ci/docker/host-x86_64/disabled/riscv64gc-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ RUN curl https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.16.tar.xz | tar
cp linux.config linux-5.6.16/.config && \
cd /build/linux-5.6.16 && \
make olddefconfig && \
make -j$(nproc) vmlinux
RUN cp linux-5.6.16/vmlinux /tmp
RUN rm -rf linux-5.6.16
make -j$(nproc) vmlinux && \
cp vmlinux /tmp && \
rm -rf linux-5.6.16

# Compile an instance of busybox as this provides a lightweight system and init
# binary which we will boot into. Only trick here is configuring busybox to
Expand Down
4 changes: 2 additions & 2 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then
exit 1
fi
# Transform changes the context of disabled Dockerfiles to match the enabled ones
tar --transform 's#^./disabled/#./#' -C $docker_dir -c . | docker \
tar --transform 's#disabled/#./#' -C $script_dir -c . | docker \
build \
--rm \
-t rust-ci \
-f "$image/Dockerfile" \
-f "host-$(uname -m)/$image/Dockerfile" \
-
else
echo Invalid image: $image
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book
2 changes: 1 addition & 1 deletion src/doc/embedded-book
2 changes: 1 addition & 1 deletion src/doc/reference
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
8 changes: 3 additions & 5 deletions src/etc/test-float-parse/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ def main():
global MAILBOX
tests = [os.path.splitext(f)[0] for f in glob('*.rs')
if not f.startswith('_')]
whitelist = sys.argv[1:]
if whitelist:
tests = [test for test in tests if test in whitelist]
listed = sys.argv[1:]
if listed:
tests = [test for test in tests if test in listed]
if not tests:
print("Error: No tests to run")
sys.exit(1)
Expand All @@ -210,8 +210,6 @@ def main():
mailman.daemon = True
mailman.start()
for test in tests:
if whitelist and test not in whitelist:
continue
run(test)
MAILBOX.put(None)
mailman.join()
Expand Down
116 changes: 103 additions & 13 deletions src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,108 @@ impl<T> VecDeque<T> {
self.tail == self.head
}

fn range_start_end<R>(&self, range: R) -> (usize, usize)
where
R: RangeBounds<usize>,
{
let len = self.len();
let start = match range.start_bound() {
Included(&n) => n,
Excluded(&n) => n + 1,
Unbounded => 0,
};
let end = match range.end_bound() {
Included(&n) => n + 1,
Excluded(&n) => n,
Unbounded => len,
};
assert!(start <= end, "lower bound was too large");
assert!(end <= len, "upper bound was too large");
(start, end)
}

/// Creates an iterator that covers the specified range in the `VecDeque`.
///
/// # Panics
///
/// Panics if the starting point is greater than the end point or if
/// the end point is greater than the length of the vector.
///
/// # Examples
///
/// ```
/// #![feature(deque_range)]
///
/// use std::collections::VecDeque;
///
/// let v: VecDeque<_> = vec![1, 2, 3].into_iter().collect();
/// let range = v.range(2..).copied().collect::<VecDeque<_>>();
/// assert_eq!(range, [3]);
///
/// // A full range covers all contents
/// let all = v.range(..);
/// assert_eq!(all.len(), 3);
/// ```
#[inline]
#[unstable(feature = "deque_range", issue = "74217")]
pub fn range<R>(&self, range: R) -> Iter<'_, T>
where
R: RangeBounds<usize>,
{
let (start, end) = self.range_start_end(range);
let tail = self.wrap_add(self.tail, start);
let head = self.wrap_add(self.tail, end);
Iter {
tail,
head,
// The shared reference we have in &self is maintained in the '_ of Iter.
ring: unsafe { self.buffer_as_slice() },
}
}

/// Creates an iterator that covers the specified mutable range in the `VecDeque`.
///
/// # Panics
///
/// Panics if the starting point is greater than the end point or if
/// the end point is greater than the length of the vector.
///
/// # Examples
///
/// ```
/// #![feature(deque_range)]
///
/// use std::collections::VecDeque;
///
/// let mut v: VecDeque<_> = vec![1, 2, 3].into_iter().collect();
/// for v in v.range_mut(2..) {
/// *v *= 2;
/// }
/// assert_eq!(v, vec![1, 2, 6]);
///
/// // A full range covers all contents
/// for v in v.range_mut(..) {
/// *v *= 2;
/// }
/// assert_eq!(v, vec![2, 4, 12]);
/// ```
#[inline]
#[unstable(feature = "deque_range", issue = "74217")]
pub fn range_mut<R>(&mut self, range: R) -> IterMut<'_, T>
where
R: RangeBounds<usize>,
{
let (start, end) = self.range_start_end(range);
let tail = self.wrap_add(self.tail, start);
let head = self.wrap_add(self.tail, end);
IterMut {
tail,
head,
// The shared reference we have in &mut self is maintained in the '_ of IterMut.
ring: unsafe { self.buffer_as_mut_slice() },
}
}

/// Creates a draining iterator that removes the specified range in the
/// `VecDeque` and yields the removed items.
///
Expand Down Expand Up @@ -1129,19 +1231,7 @@ impl<T> VecDeque<T> {
// When finished, the remaining data will be copied back to cover the hole,
// and the head/tail values will be restored correctly.
//
let len = self.len();
let start = match range.start_bound() {
Included(&n) => n,
Excluded(&n) => n + 1,
Unbounded => 0,
};
let end = match range.end_bound() {
Included(&n) => n + 1,
Excluded(&n) => n,
Unbounded => len,
};
assert!(start <= end, "drain lower bound was too large");
assert!(end <= len, "drain upper bound was too large");
let (start, end) = self.range_start_end(range);

// The deque's elements are parted into three segments:
// * self.tail -> drain_tail
Expand Down
59 changes: 59 additions & 0 deletions src/liballoc/collections/vec_deque/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,65 @@ fn test_remove() {
}
}

#[test]
fn test_range() {
let mut tester: VecDeque<usize> = VecDeque::with_capacity(7);

let cap = tester.capacity();
for len in 0..=cap {
for tail in 0..=cap {
for start in 0..=len {
for end in start..=len {
tester.tail = tail;
tester.head = tail;
for i in 0..len {
tester.push_back(i);
}

// Check that we iterate over the correct values
let range: VecDeque<_> = tester.range(start..end).copied().collect();
let expected: VecDeque<_> = (start..end).collect();
assert_eq!(range, expected);
}
}
}
}
}

#[test]
fn test_range_mut() {
let mut tester: VecDeque<usize> = VecDeque::with_capacity(7);

let cap = tester.capacity();
for len in 0..=cap {
for tail in 0..=cap {
for start in 0..=len {
for end in start..=len {
tester.tail = tail;
tester.head = tail;
for i in 0..len {
tester.push_back(i);
}

let head_was = tester.head;
let tail_was = tester.tail;

// Check that we iterate over the correct values
let range: VecDeque<_> = tester.range_mut(start..end).map(|v| *v).collect();
let expected: VecDeque<_> = (start..end).collect();
assert_eq!(range, expected);

// We shouldn't have changed the capacity or made the
// head or tail out of bounds
assert_eq!(tester.capacity(), cap);
assert_eq!(tester.tail, tail_was);
assert_eq!(tester.head, head_was);
}
}
}
}
}

#[test]
fn test_drain() {
let mut tester: VecDeque<usize> = VecDeque::with_capacity(7);
Expand Down
1 change: 1 addition & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
#![feature(const_in_array_repeat_expressions)]
#![cfg_attr(bootstrap, feature(const_if_match))]
#![feature(cow_is_borrowed)]
#![feature(deque_range)]
#![feature(dispatch_from_dyn)]
#![feature(core_intrinsics)]
#![feature(container_error_extra)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl<'a, 'f: 'a> DerefMut for VaList<'a, 'f> {
// within a private module. Once RFC 2145 has been implemented look into
// improving this.
mod sealed_trait {
/// Trait which whitelists the allowed types to be used with [VaList::arg]
/// Trait which permits the allowed types to be used with [VaList::arg].
///
/// [VaList::arg]: ../struct.VaList.html#method.arg
#[unstable(
Expand Down
4 changes: 4 additions & 0 deletions src/libcore/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
mod future;
mod into_future;
mod pending;
mod poll_fn;
mod ready;

#[stable(feature = "futures_api", since = "1.36.0")]
Expand All @@ -25,6 +26,9 @@ pub use pending::{pending, Pending};
#[unstable(feature = "future_readiness_fns", issue = "70921")]
pub use ready::{ready, Ready};

#[unstable(feature = "future_poll_fn", issue = "72302")]
pub use poll_fn::{poll_fn, PollFn};

/// This type is needed because:
///
/// a) Generators cannot implement `for<'a, 'b> Generator<&'a mut Context<'b>>`, so we need to pass
Expand Down
Loading

0 comments on commit 346aec9

Please sign in to comment.