Skip to content
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

Rollup of 20 pull requests #62333

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
4583238
squash commit for nth_back on chunks exact
Jun 22, 2019
1e9e4b0
Add mention of VS 2019 in link error output.
crlf0710 Jun 21, 2019
19f8622
Just switch to English linker output using environment variable when …
crlf0710 Jun 24, 2019
bb26e07
Add debug assertions to write_bytes and copy*
nitnelave Feb 27, 2019
0533f12
Handle null from LLVMRustGetSectionName
nitnelave Mar 27, 2019
8a4573f
format a bit
RalfJung Jun 24, 2019
4159b27
order things more traditionally
RalfJung Jun 24, 2019
a68afc5
ignore some codegen tests in debug mode
RalfJung Jun 25, 2019
d3e1bf9
nits
RalfJung Jun 25, 2019
9d798b7
Adjust warning of -C extra-filename with -o.
ehuss Jun 25, 2019
722cfc4
Update the `rust-installer` submodule
alexcrichton Jun 26, 2019
e1e95a8
Use force_bits when casting from a pointer
pvdrz Jun 26, 2019
8339211
Added comment description.
crlf0710 Jun 27, 2019
2a37582
std: Move a process test out of libstd
alexcrichton Jun 27, 2019
a0e5fcf
import gdb for explicit access to gdb.current_objfile()
cclauss Jun 28, 2019
7f1e160
Reorganize code for readabilty and fixed problem with type sizes
pvdrz Jun 28, 2019
9527565
Add Vec::leak
cramertj Jun 27, 2019
95bc720
Use pointer size as the source size
pvdrz Jun 29, 2019
51793bd
Simplify control flow
pvdrz Jun 29, 2019
dfb9f5b
Add missing links for TryFrom docs
GuillaumeGomez Jun 29, 2019
3e83728
Add missing type urls in Into trait
GuillaumeGomez Jun 27, 2019
92c28bf
Replace error by bug macro
pvdrz Jun 30, 2019
0ffb643
Make sure `#[rustc_doc_only_macro]` and other rustc attributes are re…
petrochenkov Jun 29, 2019
e4e7eb2
Feature gate `rustc` attributes harder
petrochenkov Jun 30, 2019
fc70c37
Improve box clone doctests to ensure the documentation is valid
czipperz Jun 30, 2019
de00ae7
Switch tracking issue for 'slice_patterns'.
Centril Jun 30, 2019
353b5d4
Fix michaelwoerister's mailmap
Mark-Simulacrum Jul 2, 2019
069c52f
Check if the archive has already been added to avoid duplicates
petrhosek Jul 2, 2019
7454b29
HashMap is UnwindSafe
SimonSapin Jul 2, 2019
dd702cc
Fix mismatching Kleene operators
ia0 Jul 2, 2019
8d2f80b
Use link attributes on extern "C" blocks with llvm-libuwind
petrhosek Jul 2, 2019
e5ede80
Fixed document bug, those replaced each other
Flast Jul 3, 2019
ac27aed
Rollup merge of #62021 - crlf0710:msvc_link_output_improve, r=alexcri…
Mark-Simulacrum Jul 3, 2019
42a865f
Rollup merge of #62064 - wizAmit:feature/chunks_exact_nth_back, r=sco…
Mark-Simulacrum Jul 3, 2019
3b3ff6e
Rollup merge of #62103 - RalfJung:debug-assert, r=alexcrichton
Mark-Simulacrum Jul 3, 2019
9763f8c
Rollup merge of #62128 - ehuss:extra-filename-warning, r=matthewjasper
Mark-Simulacrum Jul 3, 2019
351442b
Rollup merge of #62133 - petrochenkov:norustc, r=eddyb
Mark-Simulacrum Jul 3, 2019
a1c1d11
Rollup merge of #62153 - alexcrichton:parallel-compress, r=Mark-Simul…
Mark-Simulacrum Jul 3, 2019
2d0c1d4
Rollup merge of #62161 - GuillaumeGomez:add-missing-tryfrom-links, r=…
Mark-Simulacrum Jul 3, 2019
cd9d360
Rollup merge of #62183 - alexcrichton:fix-tests, r=nikomatsakis
Mark-Simulacrum Jul 3, 2019
64a6736
Rollup merge of #62186 - GuillaumeGomez:add-missing-type-links-into, …
Mark-Simulacrum Jul 3, 2019
c973d65
Rollup merge of #62196 - cramertj:vec-leak, r=centril,withoutboats
Mark-Simulacrum Jul 3, 2019
28ea0ae
Rollup merge of #62199 - cclauss:patch-1, r=nikomatsakis
Mark-Simulacrum Jul 3, 2019
e9a218c
Rollup merge of #62229 - christianpoveda:intptrcast-explicit-casts, r…
Mark-Simulacrum Jul 3, 2019
6ce503c
Rollup merge of #62250 - czipperz:improve-box-clone-doctests, r=Guill…
Mark-Simulacrum Jul 3, 2019
4c41d18
Rollup merge of #62255 - Centril:slice-patterns-change-issue, r=varkor
Mark-Simulacrum Jul 3, 2019
0ac9019
Rollup merge of #62285 - Mark-Simulacrum:mailmap-mw, r=Centril
Mark-Simulacrum Jul 3, 2019
147d87f
Rollup merge of #62286 - petrhosek:rustc-no-duplicate-archives, r=cra…
Mark-Simulacrum Jul 3, 2019
64135ef
Rollup merge of #62287 - petrhosek:libunwind-link-attribute, r=tmandry
Mark-Simulacrum Jul 3, 2019
5a507d8
Rollup merge of #62304 - SimonSapin:safe, r=eddyb
Mark-Simulacrum Jul 3, 2019
1ad66ed
Rollup merge of #62319 - ia0:fix_kleene, r=petrochenkov
Mark-Simulacrum Jul 3, 2019
6e9a80e
Rollup merge of #62327 - Flast:patch-1, r=Mark-Simulacrum
Mark-Simulacrum Jul 3, 2019
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
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ Matthijs Hofstra <[email protected]>
Melody Horn <[email protected]> <[email protected]>
Michael Williams <[email protected]>
Michael Woerister <michaelwoerister@posteo> <michaelwoerister@gmail>
Michael Woerister <michaelwoerister@posteo> <[email protected]>
Michael Woerister <michaelwoerister@posteo> <[email protected]>
Mickaël Raybaud-Roig <[email protected]> m-r-r <[email protected]>
Ms2ger <[email protected]> <[email protected]>
Mukilan Thiagarajan <[email protected]>
Expand Down
3 changes: 2 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1272,9 +1272,10 @@ name = "installer"
version = "0.0.0"
dependencies = [
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tar 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down
4 changes: 2 additions & 2 deletions src/doc/unstable-book/src/language-features/slice-patterns.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# `slice_patterns`

The tracking issue for this feature is: [#23121]
The tracking issue for this feature is: [#62254]

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

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

Expand Down
1 change: 1 addition & 0 deletions src/etc/gdb_load_rust_pretty_printers.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import gdb
import gdb_rust_pretty_printing
gdb_rust_pretty_printing.register_printers(gdb.current_objfile())
14 changes: 13 additions & 1 deletion src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,23 +367,35 @@ impl<T: Clone> Clone for Box<T> {
/// ```
/// let x = Box::new(5);
/// let y = x.clone();
///
/// // The value is the same
/// assert_eq!(x, y);
///
/// // But they are unique objects
/// assert_ne!(&*x as *const i32, &*y as *const i32);
/// ```
#[rustfmt::skip]
#[inline]
fn clone(&self) -> Box<T> {
box { (**self).clone() }
}

/// Copies `source`'s contents into `self` without creating a new allocation.
///
/// # Examples
///
/// ```
/// let x = Box::new(5);
/// let mut y = Box::new(10);
/// let yp: *const i32 = &*y;
///
/// y.clone_from(&x);
///
/// assert_eq!(*y, 5);
/// // The value is the same
/// assert_eq!(x, y);
///
/// // And no allocation occurred
/// assert_eq!(yp, &*y);
/// ```
#[inline]
fn clone_from(&mut self, source: &Box<T>) {
Expand Down
34 changes: 34 additions & 0 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,40 @@ impl<T> Vec<T> {
self.truncate(new_len);
}
}

/// Consumes and leaks the `Vec`, returning a mutable reference to the contents,
/// `&'a mut [T]`. Note that the type `T` must outlive the chosen lifetime
/// `'a`. If the type has only static references, or none at all, then this
/// may be chosen to be `'static`.
///
/// This function is similar to the `leak` function on `Box`.
///
/// This function is mainly useful for data that lives for the remainder of
/// the program's life. Dropping the returned reference will cause a memory
/// leak.
///
/// # Examples
///
/// Simple usage:
///
/// ```
/// #![feature(vec_leak)]
///
/// fn main() {
/// let x = vec![1, 2, 3];
/// let static_ref: &'static mut [usize] = Vec::leak(x);
/// static_ref[0] += 1;
/// assert_eq!(static_ref, &[2, 2, 3]);
/// }
/// ```
#[unstable(feature = "vec_leak", issue = "62195")]
#[inline]
pub fn leak<'a>(vec: Vec<T>) -> &'a mut [T]
where
T: 'a // Technically not needed, but kept to be explicit.
{
Box::leak(vec.into_boxed_slice())
}
}

impl<T: Clone> Vec<T> {
Expand Down
25 changes: 14 additions & 11 deletions src/libcore/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ pub trait AsMut<T: ?Sized> {
///
/// # Examples
///
/// [`String`] implements `Into<Vec<u8>>`:
/// [`String`] implements [`Into`]`<`[`Vec`]`<`[`u8`]`>>`:
///
/// In order to express that we want a generic function to take all arguments that can be
/// converted to a specified type `T`, we can use a trait bound of [`Into`]`<T>`.
/// For example: The function `is_hello` takes all arguments that can be converted into a
/// `Vec<u8>`.
/// [`Vec`]`<`[`u8`]`>`.
///
/// ```
/// fn is_hello<T: Into<Vec<u8>>>(s: T) {
Expand All @@ -274,6 +274,7 @@ pub trait AsMut<T: ?Sized> {
/// [`String`]: ../../std/string/struct.String.html
/// [`From`]: trait.From.html
/// [`Into`]: trait.Into.html
/// [`Vec`]: ../../std/vec/struct.Vec.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Into<T>: Sized {
/// Performs the conversion.
Expand Down Expand Up @@ -410,12 +411,12 @@ pub trait TryInto<T>: Sized {
///
/// This is useful when you are doing a type conversion that may
/// trivially succeed but may also need special handling.
/// For example, there is no way to convert an `i64` into an `i32`
/// using the [`From`] trait, because an `i64` may contain a value
/// that an `i32` cannot represent and so the conversion would lose data.
/// This might be handled by truncating the `i64` to an `i32` (essentially
/// giving the `i64`'s value modulo `i32::MAX`) or by simply returning
/// `i32::MAX`, or by some other method. The `From` trait is intended
/// For example, there is no way to convert an [`i64`] into an [`i32`]
/// using the [`From`] trait, because an [`i64`] may contain a value
/// that an [`i32`] cannot represent and so the conversion would lose data.
/// This might be handled by truncating the [`i64`] to an [`i32`] (essentially
/// giving the [`i64`]'s value modulo [`i32::MAX`]) or by simply returning
/// [`i32::MAX`], or by some other method. The [`From`] trait is intended
/// for perfect conversions, so the `TryFrom` trait informs the
/// programmer when a type conversion could go bad and lets them
/// decide how to handle it.
Expand All @@ -425,8 +426,8 @@ pub trait TryInto<T>: Sized {
/// - `TryFrom<T> for U` implies [`TryInto`]`<U> for T`
/// - [`try_from`] is reflexive, which means that `TryFrom<T> for T`
/// is implemented and cannot fail -- the associated `Error` type for
/// calling `T::try_from()` on a value of type `T` is `Infallible`.
/// When the `!` type is stablized `Infallible` and `!` will be
/// calling `T::try_from()` on a value of type `T` is [`Infallible`].
/// When the [`!`] type is stablized [`Infallible`] and [`!`] will be
/// equivalent.
///
/// `TryFrom<T>` can be implemented as follows:
Expand All @@ -451,7 +452,7 @@ pub trait TryInto<T>: Sized {
///
/// # Examples
///
/// As described, [`i32`] implements `TryFrom<i64>`:
/// As described, [`i32`] implements `TryFrom<`[`i64`]`>`:
///
/// ```
/// use std::convert::TryFrom;
Expand All @@ -474,6 +475,8 @@ pub trait TryInto<T>: Sized {
///
/// [`try_from`]: trait.TryFrom.html#tymethod.try_from
/// [`TryInto`]: trait.TryInto.html
/// [`i32::MAX`]: ../../std/i32/constant.MAX.html
/// [`!`]: ../../std/primitive.never.html
#[stable(feature = "try_from", since = "1.34.0")]
pub trait TryFrom<T>: Sized {
/// The type returned in the event of a conversion error.
Expand Down
33 changes: 32 additions & 1 deletion src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
issue = "0")]
#![allow(missing_docs)]

use crate::mem;

#[stable(feature = "drop_in_place", since = "1.8.0")]
#[rustc_deprecated(reason = "no longer an intrinsic - use `ptr::drop_in_place` directly",
since = "1.18.0")]
Expand Down Expand Up @@ -1331,6 +1333,26 @@ extern "rust-intrinsic" {
// (`transmute` also falls into this category, but it cannot be wrapped due to the
// check that `T` and `U` have the same size.)

/// Checks whether `ptr` is properly aligned with respect to
/// `align_of::<T>()`.
pub(crate) fn is_aligned_and_not_null<T>(ptr: *const T) -> bool {
!ptr.is_null() && ptr as usize % mem::align_of::<T>() == 0
}

/// Checks whether the regions of memory starting at `src` and `dst` of size
/// `count * size_of::<T>()` overlap.
fn overlaps<T>(src: *const T, dst: *const T, count: usize) -> bool {
let src_usize = src as usize;
let dst_usize = dst as usize;
let size = mem::size_of::<T>().checked_mul(count).unwrap();
let diff = if src_usize > dst_usize {
src_usize - dst_usize
} else {
dst_usize - src_usize
};
size > diff
}

/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
/// and destination must *not* overlap.
///
Expand Down Expand Up @@ -1420,7 +1442,11 @@ pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
extern "rust-intrinsic" {
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
}
copy_nonoverlapping(src, dst, count);

debug_assert!(is_aligned_and_not_null(src), "attempt to copy from unaligned or null pointer");
debug_assert!(is_aligned_and_not_null(dst), "attempt to copy to unaligned or null pointer");
debug_assert!(!overlaps(src, dst, count), "attempt to copy to overlapping memory");
copy_nonoverlapping(src, dst, count)
}

/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
Expand Down Expand Up @@ -1480,6 +1506,9 @@ pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
extern "rust-intrinsic" {
fn copy<T>(src: *const T, dst: *mut T, count: usize);
}

debug_assert!(is_aligned_and_not_null(src), "attempt to copy from unaligned or null pointer");
debug_assert!(is_aligned_and_not_null(dst), "attempt to copy to unaligned or null pointer");
copy(src, dst, count)
}

Expand Down Expand Up @@ -1561,6 +1590,8 @@ pub unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
extern "rust-intrinsic" {
fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
}

debug_assert!(is_aligned_and_not_null(dst), "attempt to write to unaligned or null pointer");
write_bytes(dst, val, count)
}

Expand Down
1 change: 1 addition & 0 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#![feature(concat_idents)]
#![feature(const_fn)]
#![feature(const_fn_union)]
#![feature(custom_inner_attributes)]
#![feature(doc_cfg)]
#![feature(doc_spotlight)]
#![feature(extern_types)]
Expand Down
21 changes: 18 additions & 3 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use crate::cmp::Ordering::{self, Less, Equal, Greater};
use crate::cmp;
use crate::fmt;
use crate::intrinsics::{assume, exact_div, unchecked_sub};
use crate::intrinsics::{assume, exact_div, unchecked_sub, is_aligned_and_not_null};
use crate::isize;
use crate::iter::*;
use crate::ops::{FnMut, Try, self};
Expand Down Expand Up @@ -4453,6 +4453,21 @@ impl<'a, T> DoubleEndedIterator for ChunksExact<'a, T> {
Some(snd)
}
}

#[inline]
fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
let len = self.len();
if n >= len {
self.v = &[];
None
} else {
let start = (len - 1 - n) * self.chunk_size;
let end = start + self.chunk_size;
let nth_back = &self.v[start..end];
self.v = &self.v[..start];
Some(nth_back)
}
}
}

#[stable(feature = "chunks_exact", since = "1.31.0")]
Expand Down Expand Up @@ -5213,7 +5228,7 @@ unsafe impl<'a, T> TrustedRandomAccess for RChunksExactMut<'a, T> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
debug_assert!(data as usize % mem::align_of::<T>() == 0, "attempt to create unaligned slice");
debug_assert!(is_aligned_and_not_null(data), "attempt to create unaligned or null slice");
debug_assert!(mem::size_of::<T>().saturating_mul(len) <= isize::MAX as usize,
"attempt to create slice covering half the address space");
&*ptr::slice_from_raw_parts(data, len)
Expand All @@ -5234,7 +5249,7 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T] {
debug_assert!(data as usize % mem::align_of::<T>() == 0, "attempt to create unaligned slice");
debug_assert!(is_aligned_and_not_null(data), "attempt to create unaligned or null slice");
debug_assert!(mem::size_of::<T>().saturating_mul(len) <= isize::MAX as usize,
"attempt to create slice covering half the address space");
&mut *ptr::slice_from_raw_parts_mut(data, len)
Expand Down
32 changes: 16 additions & 16 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3716,10 +3716,10 @@ impl str {
///
/// # Text directionality
///
/// A string is a sequence of bytes. 'Left' in this context means the first
/// position of that byte string; for a language like Arabic or Hebrew
/// which are 'right to left' rather than 'left to right', this will be
/// the _right_ side, not the left.
/// A string is a sequence of bytes. `start` in this context means the first
/// position of that byte string; for a left-to-right language like English or
/// Russian, this will be left side, and for right-to-left languages like
/// like Arabic or Hebrew, this will be the right side.
///
/// # Examples
///
Expand Down Expand Up @@ -3755,10 +3755,10 @@ impl str {
///
/// # Text directionality
///
/// A string is a sequence of bytes. 'Right' in this context means the last
/// position of that byte string; for a language like Arabic or Hebrew
/// which are 'right to left' rather than 'left to right', this will be
/// the _left_ side, not the right.
/// A string is a sequence of bytes. `end` in this context means the last
/// position of that byte string; for a left-to-right language like English or
/// Russian, this will be right side, and for right-to-left languages like
/// like Arabic or Hebrew, this will be the left side.
///
/// # Examples
///
Expand Down Expand Up @@ -3804,10 +3804,10 @@ impl str {
///
/// # Text directionality
///
/// A string is a sequence of bytes. `start` in this context means the first
/// position of that byte string; for a left-to-right language like English or
/// Russian, this will be left side, and for right-to-left languages like
/// like Arabic or Hebrew, this will be the right side.
/// A string is a sequence of bytes. 'Left' in this context means the first
/// position of that byte string; for a language like Arabic or Hebrew
/// which are 'right to left' rather than 'left to right', this will be
/// the _right_ side, not the left.
///
/// # Examples
///
Expand Down Expand Up @@ -3840,10 +3840,10 @@ impl str {
///
/// # Text directionality
///
/// A string is a sequence of bytes. `end` in this context means the last
/// position of that byte string; for a left-to-right language like English or
/// Russian, this will be right side, and for right-to-left languages like
/// like Arabic or Hebrew, this will be the left side.
/// A string is a sequence of bytes. 'Right' in this context means the last
/// position of that byte string; for a language like Arabic or Hebrew
/// which are 'right to left' rather than 'left to right', this will be
/// the _left_ side, not the right.
///
/// # Examples
///
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/tests/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ macro_rules! assert_none {
stringify!($what), b);
}
}
)*
)+
}};
($what:ident, $($str:tt),+,) => (assert_none!($what,$($str),+))
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/tests/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::str::pattern::*;
macro_rules! search_asserts {
($haystack:expr, $needle:expr, $testname:expr, [$($func:ident),*], $result:expr) => {
let mut searcher = $needle.into_searcher($haystack);
let arr = [$( Step::from(searcher.$func()) ),+];
let arr = [$( Step::from(searcher.$func()) ),*];
assert_eq!(&arr[..], &$result, $testname);
}
}
Expand Down
Loading