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 8 pull requests #62372

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
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
1c6b4d5
rustc: codegen: Build import library for all windows targets
chouquette May 27, 2019
c1b6716
libstd: windows: compat: Allow use of attributes
chouquette May 27, 2019
863cd6b
bootstrap: Build startup object for all windows-gnu target
chouquette May 27, 2019
e5d7043
std: Link UWP with allowed libraries only
chouquette May 27, 2019
98f9bba
libunwind: Use libunwind when targeting UWP
chouquette May 27, 2019
20eb746
std: rand: Use BCrypt on UWP
chouquette May 27, 2019
0f15466
std: win: Don't use SetHandleInformation on UWP
chouquette May 27, 2019
5466e9f
std: win: Don't expose link() on UWP
chouquette May 27, 2019
b514557
std: win: Don't use GetUserProfileDirectoryW on UWP
chouquette May 27, 2019
07d11ae
std: win: Don't use GetFileInformationByHandle on UWP
chouquette May 27, 2019
a7ad699
std: win: Don't use console APIs on UWP
chouquette May 27, 2019
1a0a263
std: win: Disable stack overflow handling on UWP
chouquette May 27, 2019
1726259
Add UWP targets
chouquette May 27, 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
069c52f
Check if the archive has already been added to avoid duplicates
petrhosek Jul 2, 2019
ec8c2e1
Use a single CtxtInterners
Zoxc May 31, 2019
de8bf5b
libstd: windows: Use qualified path for cfg_if
chouquette Jul 3, 2019
848962f
libstd: windows: Use cfg_if instead of NIH ifdef macro
chouquette Jul 3, 2019
096a2a2
libstd: windows: Reindent after last change
chouquette Jul 3, 2019
bb7fbb9
Add separate 'async_closure' feature gate.
Centril Jul 2, 2019
43315bc
Adjust tests wrt. 'async_closure' feature gate.
Centril Jul 2, 2019
830ff4a
remove StringReader::peek
matklad Jul 2, 2019
e9dc95c
remove peek_token from StringReader
matklad Jul 2, 2019
256df83
remove peek_span_src_raw from StringReader
matklad Jul 3, 2019
601bad8
cleanup lexer constructors
matklad Jul 3, 2019
30fa99e
move constructors to top
matklad Jul 3, 2019
1c6eb19
slightly comment lexer API
matklad Jul 3, 2019
8bea334
don't rely on spans when checking tokens for jointness
matklad Jul 3, 2019
3035a05
remove unused mk_sp_and_raw
matklad Jul 3, 2019
3e362a4
make unwrap_or_abort non-generic again
matklad Jul 3, 2019
55bd214
Add tracking issue for Box::into_pin
Nemo157 Jul 4, 2019
356a8a7
Rollup merge of #60260 - videolabs:rust_uwp2, r=alexcrichton
Mark-Simulacrum Jul 4, 2019
bfe2925
Rollup merge of #61392 - Zoxc:single-interner, r=eddyb
Mark-Simulacrum Jul 4, 2019
7bae0b7
Rollup merge of #62103 - RalfJung:debug-assert, r=alexcrichton
Mark-Simulacrum Jul 4, 2019
b5246fd
Rollup merge of #62133 - petrochenkov:norustc, r=eddyb
Mark-Simulacrum Jul 4, 2019
30d5f41
Rollup merge of #62286 - petrhosek:rustc-no-duplicate-archives, r=cra…
Mark-Simulacrum Jul 4, 2019
99366a9
Rollup merge of #62292 - Centril:split-async-closures, r=cramertj
Mark-Simulacrum Jul 4, 2019
7854e9e
Rollup merge of #62329 - matklad:no-peeking, r=petrochenkov
Mark-Simulacrum Jul 4, 2019
866233b
Rollup merge of #62371 - Nemo157:fix-62288, r=Centril
Mark-Simulacrum Jul 4, 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
3 changes: 2 additions & 1 deletion src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl Step for StartupObjects {
fn run(self, builder: &Builder<'_>) {
let for_compiler = self.compiler;
let target = self.target;
if !target.contains("pc-windows-gnu") {
if !target.contains("windows-gnu") {
return
}

Expand Down Expand Up @@ -1130,6 +1130,7 @@ pub fn run_cargo(builder: &Builder<'_>,
// Skip files like executables
if !filename.ends_with(".rlib") &&
!filename.ends_with(".lib") &&
!filename.ends_with(".a") &&
!is_dylib(&filename) &&
!(is_check && filename.ends_with(".rmeta")) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ impl<T: ?Sized> Box<T> {
/// This conversion does not allocate on the heap and happens in place.
///
/// This is also available via [`From`].
#[unstable(feature = "box_into_pin", issue = "0")]
#[unstable(feature = "box_into_pin", issue = "62370")]
pub fn into_pin(boxed: Box<T>) -> Pin<Box<T>> {
// It's not possible to move or replace the insides of a `Pin<Box<T>>`
// when `T: !Unpin`, so it's safe to pin it directly without any
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
6 changes: 3 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 @@ -5228,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 @@ -5249,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
Loading