Skip to content

Commit

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

Successful merges:

 - #57929 (Rustdoc remove old style files)
 - #57981 (Fix #57730)
 - #58074 (Stabilize slice_sort_by_cached_key)
 - #58196 (Add specific feature gate error for const-unstable features)
 - #58293 (Remove code for updating copyright years in generate-deriving-span-tests)
 - #58306 (Don't default on std crate when manipulating browser history)
 - #58359 (librustc_mir: use ? in impl_snapshot_for! macro)
 - #58395 (Instant::checked_duration_since)
 - #58429 (fix Box::into_unique effecitvely transmuting to a raw ptr)
 - #58433 (Update which libcore/liballoc tests Miri ignores, and document why)
 - #58438 (Use posix_spawn_file_actions_addchdir_np when possible)
 - #58440 (Whitelist the ARM v6 target-feature)
 - #58448 (rustdoc: mask `compiler_builtins` docs)
 - #58468 (split MaybeUninit into several features, expand docs a bit)
 - #58477 (Fix the syntax error in publish_toolstate.py)
 - #58479 (compile-pass test for #53606)
 - #58489 (Fix runtime error in generate-keyword-tests)
 - #58496 (Fix documentation for std::path::PathBuf::pop)
 - #58509 (Notify myself when Clippy toolstate changes)
  • Loading branch information
bors committed Feb 16, 2019
2 parents eac0908 + ae922a9 commit f5f8284
Show file tree
Hide file tree
Showing 89 changed files with 818 additions and 299 deletions.
20 changes: 17 additions & 3 deletions src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fn main() {
let libdir = env::var_os("RUSTDOC_LIBDIR").expect("RUSTDOC_LIBDIR was not set");
let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
let mut has_unstable = false;

use std::str::FromStr;

Expand Down Expand Up @@ -54,9 +55,22 @@ fn main() {
// it up so we can make rustdoc print this into the docs
if let Some(version) = env::var_os("RUSTDOC_CRATE_VERSION") {
// This "unstable-options" can be removed when `--crate-version` is stabilized
cmd.arg("-Z")
.arg("unstable-options")
.arg("--crate-version").arg(version);
if !has_unstable {
cmd.arg("-Z")
.arg("unstable-options");
}
cmd.arg("--crate-version").arg(version);
has_unstable = true;
}

// Needed to be able to run all rustdoc tests.
if let Some(_) = env::var_os("RUSTDOC_GENERATE_REDIRECT_PAGES") {
// This "unstable-options" can be removed when `--generate-redirect-pages` is stabilized
if !has_unstable {
cmd.arg("-Z")
.arg("unstable-options");
}
cmd.arg("--generate-redirect-pages");
}

if verbose > 1 {
Expand Down
9 changes: 6 additions & 3 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ impl Step for Std {
cargo.arg("--")
.arg("--markdown-css").arg("rust.css")
.arg("--markdown-no-toc")
.arg("--generate-redirect-pages")
.arg("--index-page").arg(&builder.src.join("src/doc/index.md"));

builder.run(&mut cargo);
Expand Down Expand Up @@ -581,7 +582,9 @@ impl Step for Test {
let mut cargo = builder.cargo(compiler, Mode::Test, target, "doc");
compile::test_cargo(builder, &compiler, target, &mut cargo);

cargo.arg("--no-deps").arg("-p").arg("test");
cargo.arg("--no-deps")
.arg("-p").arg("test")
.env("RUSTDOC_GENERATE_REDIRECT_PAGES", "1");

builder.run(&mut cargo);
builder.cp_r(&my_out, &out);
Expand Down Expand Up @@ -650,9 +653,9 @@ impl Step for WhitelistedRustc {
// We don't want to build docs for internal compiler dependencies in this
// step (there is another step for that). Therefore, we whitelist the crates
// for which docs must be built.
cargo.arg("--no-deps");
for krate in &["proc_macro"] {
cargo.arg("-p").arg(krate);
cargo.arg("-p").arg(krate)
.env("RUSTDOC_GENERATE_REDIRECT_PAGES", "1");
}

builder.run(&mut cargo);
Expand Down
30 changes: 7 additions & 23 deletions src/etc/generate-deriving-span-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
sample usage: src/etc/generate-deriving-span-tests.py
"""

import os, datetime, stat, re
import os, stat

TEST_DIR = os.path.abspath(
os.path.join(os.path.dirname(__file__), '../test/ui/derives/'))

YEAR = datetime.datetime.now().year

TEMPLATE = """
TEMPLATE = """\
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
{error_deriving}
Expand Down Expand Up @@ -63,19 +61,11 @@ def create_test_case(type, trait, super_traits, error_count):

errors = '\n'.join('//~%s ERROR' % ('^' * n) for n in range(error_count))
code = string.format(traits = all_traits, errors = errors)
return TEMPLATE.format(year = YEAR, error_deriving=error_deriving, code = code)
return TEMPLATE.format(error_deriving=error_deriving, code = code)

def write_file(name, string):
test_file = os.path.join(TEST_DIR, 'derives-span-%s.rs' % name)

with open(test_file) as f:
old_str = f.read()
old_str_ignoring_date = re.sub(r'^// Copyright \d+',
'// Copyright {year}'.format(year = YEAR), old_str)
if old_str_ignoring_date == string:
# if all we're doing is updating the copyright year, ignore it
return 0

# set write permission if file exists, so it can be changed
if os.path.exists(test_file):
os.chmod(test_file, stat.S_IWUSR)
Expand All @@ -86,8 +76,6 @@ def write_file(name, string):
# mark file read-only
os.chmod(test_file, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)

return 1


ENUM = 1
STRUCT = 2
Expand All @@ -110,15 +98,11 @@ def write_file(name, string):
('Hash', [], 1)]:
traits[trait] = (ALL, supers, errs)

files = 0

for (trait, (types, super_traits, error_count)) in traits.items():
mk = lambda ty: create_test_case(ty, trait, super_traits, error_count)
if types & ENUM:
files += write_file(trait + '-enum', mk(ENUM_TUPLE))
files += write_file(trait + '-enum-struct-variant', mk(ENUM_STRUCT))
write_file(trait + '-enum', mk(ENUM_TUPLE))
write_file(trait + '-enum-struct-variant', mk(ENUM_STRUCT))
if types & STRUCT:
files += write_file(trait + '-struct', mk(STRUCT_FIELDS))
files += write_file(trait + '-tuple-struct', mk(STRUCT_TUPLE))

print('Generated {files} deriving span test{}.'.format('s' if files != 1 else '', files = files))
write_file(trait + '-struct', mk(STRUCT_FIELDS))
write_file(trait + '-tuple-struct', mk(STRUCT_TUPLE))
4 changes: 2 additions & 2 deletions src/etc/generate-keyword-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import stat


template = """
template = """\
// This file was auto-generated using 'src/etc/generate-keyword-tests.py %s'
fn main() {
Expand All @@ -35,7 +35,7 @@
os.chmod(test_file, stat.S_IWUSR)

with open(test_file, 'wt') as f:
f.write(template % (datetime.datetime.now().year, kw, kw, kw))
f.write(template % (kw, kw, kw))

# mark file read-only
os.chmod(test_file, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
1 change: 0 additions & 1 deletion src/liballoc/benches/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(repr_simd)]
#![feature(slice_sort_by_cached_key)]
#![feature(test)]

extern crate rand;
Expand Down
11 changes: 8 additions & 3 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,15 @@ impl<T: ?Sized> Box<T> {
#[unstable(feature = "ptr_internals", issue = "0", reason = "use into_raw_non_null instead")]
#[inline]
#[doc(hidden)]
pub fn into_unique(b: Box<T>) -> Unique<T> {
let unique = b.0;
pub fn into_unique(mut b: Box<T>) -> Unique<T> {
// Box is kind-of a library type, but recognized as a "unique pointer" by
// Stacked Borrows. This function here corresponds to "reborrowing to
// a raw pointer", but there is no actual reborrow here -- so
// without some care, the pointer we are returning here still carries
// the `Uniq` tag. We round-trip through a mutable reference to avoid that.
let unique = unsafe { b.0.as_mut() as *mut T };
mem::forget(b);
unique
unsafe { Unique::new_unchecked(unique) }
}

/// Consumes and leaks the `Box`, returning a mutable reference,
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
root: self.root,
_marker: PhantomData
},
idx: unsafe { usize::from(*self.as_header().parent_idx.get_ref()) },
idx: unsafe { usize::from(*self.as_header().parent_idx.as_ptr()) },
_marker: PhantomData
})
} else {
Expand Down Expand Up @@ -1143,7 +1143,7 @@ impl<BorrowType, K, V>
NodeRef {
height: self.node.height - 1,
node: unsafe {
self.node.as_internal().edges.get_unchecked(self.idx).get_ref().as_ptr()
(&*self.node.as_internal().edges.get_unchecked(self.idx).as_ptr()).as_ptr()
},
root: self.node.root,
_marker: PhantomData
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
#![feature(rustc_const_unstable)]
#![feature(const_vec_new)]
#![feature(slice_partition_dedup)]
#![feature(maybe_uninit)]
#![feature(maybe_uninit, maybe_uninit_slice, maybe_uninit_array)]
#![feature(alloc_layout_extra)]
#![feature(try_trait)]

Expand Down
7 changes: 5 additions & 2 deletions src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ impl<T> [T] {
/// This sort is stable (i.e., does not reorder equal elements) and `O(m n log(m n))`
/// worst-case, where the key function is `O(m)`.
///
/// For expensive key functions (e.g. functions that are not simple property accesses or
/// basic operations), [`sort_by_cached_key`](#method.sort_by_cached_key) is likely to be
/// significantly faster, as it does not recompute element keys.
///
/// When applicable, unstable sorting is preferred because it is generally faster than stable
/// sorting and it doesn't allocate auxiliary memory.
/// See [`sort_unstable_by_key`](#method.sort_unstable_by_key).
Expand Down Expand Up @@ -312,15 +316,14 @@ impl<T> [T] {
/// # Examples
///
/// ```
/// #![feature(slice_sort_by_cached_key)]
/// let mut v = [-5i32, 4, 32, -3, 2];
///
/// v.sort_by_cached_key(|k| k.to_string());
/// assert!(v == [-3, -5, 2, 32, 4]);
/// ```
///
/// [pdqsort]: https://github.com/orlp/pdqsort
#[unstable(feature = "slice_sort_by_cached_key", issue = "34447")]
#[stable(feature = "slice_sort_by_cached_key", since = "1.34.0")]
#[inline]
pub fn sort_by_cached_key<K, F>(&mut self, f: F)
where F: FnMut(&T) -> K, K: Ord
Expand Down
2 changes: 0 additions & 2 deletions src/liballoc/tests/arc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(not(miri))]

use std::any::Any;
use std::sync::{Arc, Weak};
use std::cell::RefCell;
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/tests/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ fn assert_covariance() {
//
// Destructors must be called exactly once per element.
#[test]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri does not support panics
fn panic_safe() {
static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);

Expand Down
30 changes: 30 additions & 0 deletions src/liballoc/tests/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ use super::DeterministicRng;
#[test]
fn test_basic_large() {
let mut map = BTreeMap::new();
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;
assert_eq!(map.len(), 0);

for i in 0..size {
Expand Down Expand Up @@ -69,7 +72,10 @@ fn test_basic_small() {

#[test]
fn test_iter() {
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;

// Forwards
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
Expand All @@ -91,7 +97,10 @@ fn test_iter() {

#[test]
fn test_iter_rev() {
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;

// Forwards
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
Expand Down Expand Up @@ -127,7 +136,10 @@ fn test_values_mut() {

#[test]
fn test_iter_mixed() {
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;

// Forwards
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
Expand Down Expand Up @@ -214,42 +226,50 @@ fn test_range_equal_empty_cases() {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_range_equal_excluded() {
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
map.range((Excluded(2), Excluded(2)));
}

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_range_backwards_1() {
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
map.range((Included(3), Included(2)));
}

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_range_backwards_2() {
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
map.range((Included(3), Excluded(2)));
}

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_range_backwards_3() {
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
map.range((Excluded(3), Included(2)));
}

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_range_backwards_4() {
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
map.range((Excluded(3), Excluded(2)));
}

#[test]
fn test_range_1000() {
#[cfg(not(miri))] // Miri is too slow
let size = 1000;
#[cfg(miri)]
let size = 200;
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();

fn test(map: &BTreeMap<u32, u32>, size: u32, min: Bound<&u32>, max: Bound<&u32>) {
Expand Down Expand Up @@ -286,7 +306,10 @@ fn test_range_borrowed_key() {

#[test]
fn test_range() {
#[cfg(not(miri))] // Miri is too slow
let size = 200;
#[cfg(miri)]
let size = 30;
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();

for i in 0..size {
Expand All @@ -305,7 +328,10 @@ fn test_range() {

#[test]
fn test_range_mut() {
#[cfg(not(miri))] // Miri is too slow
let size = 200;
#[cfg(miri)]
let size = 30;
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();

for i in 0..size {
Expand Down Expand Up @@ -479,7 +505,10 @@ fn test_bad_zst() {
#[test]
fn test_clone() {
let mut map = BTreeMap::new();
#[cfg(not(miri))] // Miri is too slow
let size = 100;
#[cfg(miri)]
let size = 30;
assert_eq!(map.len(), 0);

for i in 0..size {
Expand Down Expand Up @@ -631,6 +660,7 @@ create_append_test!(test_append_145, 145);
create_append_test!(test_append_170, 170);
create_append_test!(test_append_181, 181);
create_append_test!(test_append_239, 239);
#[cfg(not(miri))] // Miri is too slow
create_append_test!(test_append_1700, 1700);

fn rand_data(len: usize) -> Vec<(u32, u32)> {
Expand Down
2 changes: 0 additions & 2 deletions src/liballoc/tests/btree/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(not(miri))]

mod map;
mod set;

Expand Down
2 changes: 0 additions & 2 deletions src/liballoc/tests/heap.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(not(miri))]

use std::alloc::{Global, Alloc, Layout, System};

/// Issue #45955.
Expand Down
Loading

0 comments on commit f5f8284

Please sign in to comment.