Skip to content

Commit

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

Successful merges:

 - #51807 (Deprecation of str::slice_unchecked(_mut))
 - #52051 (mem::swap the obvious way for types smaller than the SIMD optimization's block size)
 - #52465 (Add CI test harness for `thumb*` targets. [IRR-2018-embedded])
 - #52507 (Reword when `_` couldn't be inferred)
 - #52508 (Document that Unique::empty() and NonNull::dangling() aren't sentinel values)
 - #52521 (Fix links in rustdoc book.)
 - #52581 (Avoid using `#[macro_export]` for documenting builtin macros)
 - #52582 (Typo)
 - #52587 (Add missing backtick in UniversalRegions doc comment)
 - #52594 (Run the error index tool against the sysroot libdir)
 - #52615 (Added new lines to .gitignore.)
  • Loading branch information
bors committed Jul 22, 2018
2 parents 32772fd + b954d4d commit 3b77203
Show file tree
Hide file tree
Showing 36 changed files with 165 additions and 109 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,18 @@ __pycache__/
target/
/test/
/tmp/
tags
tags.*
TAGS
TAGS.emacs
TAGS.vi
TAGS.*
\#*
\#*\#
config.mk
config.stamp
keywords.md
lexer.ml
mir_dump
Session.vim
src/etc/dl
tmp.*.rs
version.md
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,9 @@ impl Step for Compiletest {
builder.ensure(compile::Rustc { compiler, target });
}

builder.ensure(compile::Test { compiler, target });
if builder.no_std(target) != Some(true) {
builder.ensure(compile::Test { compiler, target });
}
builder.ensure(native::TestHelpers { target });
builder.ensure(RemoteCopyLibs { compiler, target });

Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pub fn prepare_tool_cargo(

macro_rules! tool {
($($name:ident, $path:expr, $tool_name:expr, $mode:expr $(,llvm_tools = $llvm:expr)*;)+) => {
#[derive(Copy, Clone)]
#[derive(Copy, PartialEq, Eq, Clone)]
pub enum Tool {
$(
$name,
Expand Down Expand Up @@ -640,7 +640,7 @@ impl<'a> Builder<'a> {
fn prepare_tool_cmd(&self, compiler: Compiler, tool: Tool, cmd: &mut Command) {
let host = &compiler.host;
let mut lib_paths: Vec<PathBuf> = vec![
if compiler.stage == 0 {
if compiler.stage == 0 && tool != Tool::ErrorIndex {
self.build.rustc_snapshot_libdir()
} else {
PathBuf::from(&self.sysroot_libdir(compiler, compiler.host))
Expand Down
9 changes: 8 additions & 1 deletion src/ci/docker/dist-various-1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ RUN \
echo "# a" >> /usr/local/mips-linux-musl/bin/mips-openwrt-linux-musl-wrapper.sh && \
echo "# b" >> /usr/local/mipsel-linux-musl/bin/mipsel-openwrt-linux-musl-wrapper.sh

ENV RUN_MAKE_TARGETS=thumbv6m-none-eabi
ENV RUN_MAKE_TARGETS=$RUN_MAKE_TARGETS,thumbv7m-none-eabi
ENV RUN_MAKE_TARGETS=$RUN_MAKE_TARGETS,thumbv7em-none-eabi
ENV RUN_MAKE_TARGETS=$RUN_MAKE_TARGETS,thumbv7em-none-eabihf

ENV TARGETS=asmjs-unknown-emscripten
ENV TARGETS=$TARGETS,wasm32-unknown-emscripten
ENV TARGETS=$TARGETS,x86_64-rumprun-netbsd
Expand Down Expand Up @@ -120,7 +125,9 @@ ENV RUST_CONFIGURE_ARGS \
--enable-emscripten \
--disable-docs

ENV SCRIPT python2.7 ../x.py dist --target $TARGETS
ENV SCRIPT \
python2.7 ../x.py test --target $RUN_MAKE_TARGETS src/test/run-make && \
python2.7 ../x.py dist --target $TARGETS

# sccache
COPY scripts/sccache.sh /scripts/
Expand Down
4 changes: 2 additions & 2 deletions src/doc/rustdoc/src/passes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Rustdoc has a concept called "passes". These are transformations that

In addition to the passes below, check out the docs for these flags:

* [`--passes`](command-line-arguments.html#--passes-add-more-rustdoc-passes)
* [`--no-defaults`](command-line-arguments.html#--no-defaults-dont-run-default-passes)
* [`--passes`](command-line-arguments.html#a--passes-add-more-rustdoc-passes)
* [`--no-defaults`](command-line-arguments.html#a--no-defaults-dont-run-default-passes)

## Default passes

Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ impl str {
let mut result = String::new();
let mut last_end = 0;
for (start, part) in self.match_indices(from) {
result.push_str(unsafe { self.slice_unchecked(last_end, start) });
result.push_str(unsafe { self.get_unchecked(last_end..start) });
result.push_str(to);
last_end = start + part.len();
}
result.push_str(unsafe { self.slice_unchecked(last_end, self.len()) });
result.push_str(unsafe { self.get_unchecked(last_end..self.len()) });
result
}

Expand Down Expand Up @@ -309,11 +309,11 @@ impl str {
let mut result = String::with_capacity(32);
let mut last_end = 0;
for (start, part) in self.match_indices(pat).take(count) {
result.push_str(unsafe { self.slice_unchecked(last_end, start) });
result.push_str(unsafe { self.get_unchecked(last_end..start) });
result.push_str(to);
last_end = start + part.len();
}
result.push_str(unsafe { self.slice_unchecked(last_end, self.len()) });
result.push_str(unsafe { self.get_unchecked(last_end..self.len()) });
result
}

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ impl String {

while idx < len {
let ch = unsafe {
self.slice_unchecked(idx, len).chars().next().unwrap()
self.get_unchecked(idx..len).chars().next().unwrap()
};
let ch_len = ch.len_utf8();

Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ fn test_join_for_different_lengths_with_long_separator() {

#[test]
fn test_unsafe_slice() {
assert_eq!("ab", unsafe {"abc".slice_unchecked(0, 2)});
assert_eq!("bc", unsafe {"abc".slice_unchecked(1, 3)});
assert_eq!("", unsafe {"abc".slice_unchecked(1, 1)});
assert_eq!("ab", unsafe {"abc".get_unchecked(0..2)});
assert_eq!("bc", unsafe {"abc".get_unchecked(1..3)});
assert_eq!("", unsafe {"abc".get_unchecked(1..1)});
fn a_million_letter_a() -> String {
let mut i = 0;
let mut rs = String::new();
Expand All @@ -200,7 +200,7 @@ fn test_unsafe_slice() {
}
let letters = a_million_letter_a();
assert_eq!(half_a_million_letter_a(),
unsafe { letters.slice_unchecked(0, 500000)});
unsafe { letters.get_unchecked(0..500000)});
}

#[test]
Expand Down
49 changes: 17 additions & 32 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ macro_rules! unimplemented {
/// into libsyntax itself.
///
/// For more information, see documentation for `std`'s macros.
#[cfg(dox)]
mod builtin {

/// Unconditionally causes compilation to fail with the given error message when encountered.
Expand All @@ -551,8 +552,7 @@ mod builtin {
///
/// [`std::compile_error!`]: ../std/macro.compile_error.html
#[stable(feature = "compile_error_macro", since = "1.20.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! compile_error {
($msg:expr) => ({ /* compiler built-in */ });
($msg:expr,) => ({ /* compiler built-in */ });
Expand All @@ -564,8 +564,7 @@ mod builtin {
///
/// [`std::format_args!`]: ../std/macro.format_args.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! format_args {
($fmt:expr) => ({ /* compiler built-in */ });
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ });
Expand All @@ -577,8 +576,7 @@ mod builtin {
///
/// [`std::env!`]: ../std/macro.env.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! env {
($name:expr) => ({ /* compiler built-in */ });
($name:expr,) => ({ /* compiler built-in */ });
Expand All @@ -590,8 +588,7 @@ mod builtin {
///
/// [`std::option_env!`]: ../std/macro.option_env.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! option_env {
($name:expr) => ({ /* compiler built-in */ });
($name:expr,) => ({ /* compiler built-in */ });
Expand All @@ -603,8 +600,7 @@ mod builtin {
///
/// [`std::concat_idents!`]: ../std/macro.concat_idents.html
#[unstable(feature = "concat_idents_macro", issue = "29599")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! concat_idents {
($($e:ident),+) => ({ /* compiler built-in */ });
($($e:ident,)+) => ({ /* compiler built-in */ });
Expand All @@ -616,8 +612,7 @@ mod builtin {
///
/// [`std::concat!`]: ../std/macro.concat.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! concat {
($($e:expr),*) => ({ /* compiler built-in */ });
($($e:expr,)*) => ({ /* compiler built-in */ });
Expand All @@ -629,8 +624,7 @@ mod builtin {
///
/// [`std::line!`]: ../std/macro.line.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! line { () => ({ /* compiler built-in */ }) }

/// A macro which expands to the column number on which it was invoked.
Expand All @@ -639,8 +633,7 @@ mod builtin {
///
/// [`std::column!`]: ../std/macro.column.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! column { () => ({ /* compiler built-in */ }) }

/// A macro which expands to the file name from which it was invoked.
Expand All @@ -649,8 +642,7 @@ mod builtin {
///
/// [`std::file!`]: ../std/macro.file.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! file { () => ({ /* compiler built-in */ }) }

/// A macro which stringifies its arguments.
Expand All @@ -659,8 +651,7 @@ mod builtin {
///
/// [`std::stringify!`]: ../std/macro.stringify.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! stringify { ($($t:tt)*) => ({ /* compiler built-in */ }) }

/// Includes a utf8-encoded file as a string.
Expand All @@ -669,8 +660,7 @@ mod builtin {
///
/// [`std::include_str!`]: ../std/macro.include_str.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! include_str {
($file:expr) => ({ /* compiler built-in */ });
($file:expr,) => ({ /* compiler built-in */ });
Expand All @@ -682,8 +672,7 @@ mod builtin {
///
/// [`std::include_bytes!`]: ../std/macro.include_bytes.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! include_bytes {
($file:expr) => ({ /* compiler built-in */ });
($file:expr,) => ({ /* compiler built-in */ });
Expand All @@ -695,8 +684,7 @@ mod builtin {
///
/// [`std::module_path!`]: ../std/macro.module_path.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! module_path { () => ({ /* compiler built-in */ }) }

/// Boolean evaluation of configuration flags, at compile-time.
Expand All @@ -705,8 +693,7 @@ mod builtin {
///
/// [`std::cfg!`]: ../std/macro.cfg.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) }

/// Parse a file as an expression or an item according to the context.
Expand All @@ -715,8 +702,7 @@ mod builtin {
///
/// [`std::include!`]: ../std/macro.include.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
#[cfg(dox)]
#[rustc_doc_only_macro]
macro_rules! include {
($file:expr) => ({ /* compiler built-in */ });
($file:expr,) => ({ /* compiler built-in */ });
Expand All @@ -727,9 +713,8 @@ mod builtin {
/// For more information, see the documentation for [`std::assert!`].
///
/// [`std::assert!`]: ../std/macro.assert.html
#[macro_export]
#[rustc_doc_only_macro]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg(dox)]
macro_rules! assert {
($cond:expr) => ({ /* compiler built-in */ });
($cond:expr,) => ({ /* compiler built-in */ });
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ pub unsafe fn uninitialized<T>() -> T {
#[stable(feature = "rust1", since = "1.0.0")]
pub fn swap<T>(x: &mut T, y: &mut T) {
unsafe {
ptr::swap_nonoverlapping(x, y, 1);
ptr::swap_nonoverlapping_one(x, y);
}
}

Expand Down
23 changes: 23 additions & 0 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
swap_nonoverlapping_bytes(x, y, len)
}

#[inline]
pub(crate) unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
// For types smaller than the block optimization below,
// just swap directly to avoid pessimizing codegen.
if mem::size_of::<T>() < 32 {
let z = read(x);
copy_nonoverlapping(y, x, 1);
write(y, z);
} else {
swap_nonoverlapping(x, y, 1);
}
}

#[inline]
unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
// The approach here is to utilize simd to swap x & y efficiently. Testing reveals
Expand Down Expand Up @@ -2703,6 +2716,11 @@ impl<T: Sized> Unique<T> {
///
/// This is useful for initializing types which lazily allocate, like
/// `Vec::new` does.
///
/// Note that the pointer value may potentially represent a valid pointer to
/// a `T`, which means this must not be used as a "not yet initialized"
/// sentinel value. Types that lazily allocate must track initialization by
/// some other means.
// FIXME: rename to dangling() to match NonNull?
pub const fn empty() -> Self {
unsafe {
Expand Down Expand Up @@ -2834,6 +2852,11 @@ impl<T: Sized> NonNull<T> {
///
/// This is useful for initializing types which lazily allocate, like
/// `Vec::new` does.
///
/// Note that the pointer value may potentially represent a valid pointer to
/// a `T`, which means this must not be used as a "not yet initialized"
/// sentinel value. Types that lazily allocate must track initialization by
/// some other means.
#[stable(feature = "nonnull", since = "1.25.0")]
pub fn dangling() -> Self {
unsafe {
Expand Down
Loading

0 comments on commit 3b77203

Please sign in to comment.