Skip to content

Commit

Permalink
Auto merge of #67626 - JohnTitor:rollup-bt8kv3i, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 6 pull requests

Successful merges:

 - #67576 (reuse `capacity` variable in slice::repeat)
 - #67598 (Fix ICE / miscompilation when inlining simd shuffle intrinsic in MIR.)
 - #67602 (Use issue = "none" instead of "0" in intrinsics)
 - #67604 (Add Scalar::to_(u|i)16 methods)
 - #67605 (tidy: change msdn links to newer locations)
 - #67617 (Remove `compiler_builtins_lib` documentation)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Dec 26, 2019
2 parents c0b16b4 + e5aa687 commit 7d1b419
Show file tree
Hide file tree
Showing 23 changed files with 147 additions and 104 deletions.
6 changes: 1 addition & 5 deletions src/doc/unstable-book/src/language-features/lang-items.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,7 @@ pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {

In many cases, you may need to manually link to the `compiler_builtins` crate
when building a `no_std` binary. You may observe this via linker error messages
such as "```undefined reference to `__rust_probestack'```". Using this crate
also requires enabling the library feature `compiler_builtins_lib`. You can read
more about this [here][compiler-builtins-lib].

[compiler-builtins-lib]: ../library-features/compiler-builtins-lib.md
such as "```undefined reference to `__rust_probestack'```".

## More about the language items

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/etc/installer/msi/rust.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<Property Id="ARPPRODUCTICON" Value="rust.ico" />
<Property Id="ARPURLINFOABOUT" Value="https://www.rust-lang.org/" />
<Property Id="ARPCOMMENTS" Value="$(env.CFG_RELEASE_INFO)" />
<!-- This is a dual-mode package. http://msdn.microsoft.com/en-us/library/windows/desktop/dd408068.aspx -->
<!-- This is a dual-mode package. https://docs.microsoft.com/en-us/windows/win32/msi/single-package-authoring -->
<Property Id="ALLUSERS" Value="2" Secure="yes" />
<Property Id="MSIINSTALLPERUSER" Secure="yes" />
<!-- The actual install location (initialized below) -->
Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ impl<T> [T] {
// and `rem` is the remaining part of `n`.

// Using `Vec` to access `set_len()`.
let mut buf = Vec::with_capacity(self.len().checked_mul(n).expect("capacity overflow"));
let capacity = self.len().checked_mul(n).expect("capacity overflow");
let mut buf = Vec::with_capacity(capacity);

// `2^expn` repetition is done by doubling `buf` `expn`-times.
buf.extend(self);
Expand All @@ -476,7 +477,7 @@ impl<T> [T] {

// `rem` (`= n - 2^expn`) repetition is done by copying
// first `rem` repetitions from `buf` itself.
let rem_len = self.len() * n - buf.len(); // `self.len() * rem`
let rem_len = capacity - buf.len(); // `self.len() * rem`
if rem_len > 0 {
// `buf.extend(buf[0 .. rem_len])`:
unsafe {
Expand All @@ -487,8 +488,7 @@ impl<T> [T] {
rem_len,
);
// `buf.len() + rem_len` equals to `buf.capacity()` (`= self.len() * n`).
let buf_cap = buf.capacity();
buf.set_len(buf_cap);
buf.set_len(capacity);
}
}
buf
Expand Down
12 changes: 6 additions & 6 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ extern "rust-intrinsic" {

#[rustc_const_stable(feature = "const_min_align_of", since = "1.40.0")]
pub fn min_align_of<T>() -> usize;
#[rustc_const_unstable(feature = "const_pref_align_of", issue = "0")]
#[rustc_const_unstable(feature = "const_pref_align_of", issue = "none")]
pub fn pref_align_of<T>() -> usize;

/// The size of the referenced value in bytes.
Expand All @@ -708,13 +708,13 @@ extern "rust-intrinsic" {
pub fn min_align_of_val<T: ?Sized>(_: &T) -> usize;

/// Gets a static string slice containing the name of a type.
#[rustc_const_unstable(feature = "const_type_name", issue = "0")]
#[rustc_const_unstable(feature = "const_type_name", issue = "none")]
pub fn type_name<T: ?Sized>() -> &'static str;

/// Gets an identifier which is globally unique to the specified type. This
/// function will return the same value for a type regardless of whichever
/// crate it is invoked in.
#[rustc_const_unstable(feature = "const_type_id", issue = "0")]
#[rustc_const_unstable(feature = "const_type_id", issue = "none")]
pub fn type_id<T: ?Sized + 'static>() -> u64;

/// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited:
Expand Down Expand Up @@ -1222,7 +1222,7 @@ extern "rust-intrinsic" {
/// let num_leading = unsafe { ctlz_nonzero(x) };
/// assert_eq!(num_leading, 3);
/// ```
#[rustc_const_unstable(feature = "constctlz", issue = "0")]
#[rustc_const_unstable(feature = "constctlz", issue = "none")]
pub fn ctlz_nonzero<T>(x: T) -> T;

/// Returns the number of trailing unset bits (zeroes) in an integer type `T`.
Expand Down Expand Up @@ -1267,7 +1267,7 @@ extern "rust-intrinsic" {
/// let num_trailing = unsafe { cttz_nonzero(x) };
/// assert_eq!(num_trailing, 3);
/// ```
#[rustc_const_unstable(feature = "const_cttz", issue = "0")]
#[rustc_const_unstable(feature = "const_cttz", issue = "none")]
pub fn cttz_nonzero<T>(x: T) -> T;

/// Reverses the bytes in an integer type `T`.
Expand Down Expand Up @@ -1396,7 +1396,7 @@ extern "rust-intrinsic" {
pub fn nontemporal_store<T>(ptr: *mut T, val: T);

/// See documentation of `<*const T>::offset_from` for details.
#[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "0")]
#[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "none")]
pub fn ptr_offset_from<T>(ptr: *const T, base: *const T) -> isize;

/// Internal hook used by Miri to implement unwinding.
Expand Down
2 changes: 1 addition & 1 deletion src/libpanic_unwind/seh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
//! are then recovered in the filter function to be written to the stack frame
//! of the `try` intrinsic.
//!
//! [win64]: http://msdn.microsoft.com/en-us/library/1eyas8tf.aspx
//! [win64]: https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64
//! [llvm]: http://llvm.org/docs/ExceptionHandling.html#background-on-windows-exceptions
#![allow(nonstandard_style)]
Expand Down
56 changes: 35 additions & 21 deletions src/librustc/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,48 +415,62 @@ impl<'tcx, Tag> Scalar<Tag> {
}
}

#[inline]
fn to_unsigned_with_bit_width(self, bits: u64) -> InterpResult<'static, u128> {
let sz = Size::from_bits(bits);
self.to_bits(sz)
}

/// Converts the scalar to produce an `u8`. Fails if the scalar is a pointer.
pub fn to_u8(self) -> InterpResult<'static, u8> {
let sz = Size::from_bits(8);
let b = self.to_bits(sz)?;
Ok(b as u8)
self.to_unsigned_with_bit_width(8).map(|v| v as u8)
}

/// Converts the scalar to produce an `u16`. Fails if the scalar is a pointer.
pub fn to_u16(self) -> InterpResult<'static, u16> {
self.to_unsigned_with_bit_width(16).map(|v| v as u16)
}

/// Converts the scalar to produce an `u32`. Fails if the scalar is a pointer.
pub fn to_u32(self) -> InterpResult<'static, u32> {
let sz = Size::from_bits(32);
let b = self.to_bits(sz)?;
Ok(b as u32)
self.to_unsigned_with_bit_width(32).map(|v| v as u32)
}

/// Converts the scalar to produce an `u64`. Fails if the scalar is a pointer.
pub fn to_u64(self) -> InterpResult<'static, u64> {
let sz = Size::from_bits(64);
let b = self.to_bits(sz)?;
Ok(b as u64)
self.to_unsigned_with_bit_width(64).map(|v| v as u64)
}

pub fn to_machine_usize(self, cx: &impl HasDataLayout) -> InterpResult<'static, u64> {
let b = self.to_bits(cx.data_layout().pointer_size)?;
Ok(b as u64)
}

pub fn to_i8(self) -> InterpResult<'static, i8> {
let sz = Size::from_bits(8);
#[inline]
fn to_signed_with_bit_width(self, bits: u64) -> InterpResult<'static, i128> {
let sz = Size::from_bits(bits);
let b = self.to_bits(sz)?;
let b = sign_extend(b, sz) as i128;
Ok(b as i8)
Ok(sign_extend(b, sz) as i128)
}

/// Converts the scalar to produce an `i8`. Fails if the scalar is a pointer.
pub fn to_i8(self) -> InterpResult<'static, i8> {
self.to_signed_with_bit_width(8).map(|v| v as i8)
}

/// Converts the scalar to produce an `i16`. Fails if the scalar is a pointer.
pub fn to_i16(self) -> InterpResult<'static, i16> {
self.to_signed_with_bit_width(16).map(|v| v as i16)
}

/// Converts the scalar to produce an `i32`. Fails if the scalar is a pointer.
pub fn to_i32(self) -> InterpResult<'static, i32> {
let sz = Size::from_bits(32);
let b = self.to_bits(sz)?;
let b = sign_extend(b, sz) as i128;
Ok(b as i32)
self.to_signed_with_bit_width(32).map(|v| v as i32)
}

/// Converts the scalar to produce an `i64`. Fails if the scalar is a pointer.
pub fn to_i64(self) -> InterpResult<'static, i64> {
let sz = Size::from_bits(64);
let b = self.to_bits(sz)?;
let b = sign_extend(b, sz) as i128;
Ok(b as i64)
self.to_signed_with_bit_width(64).map(|v| v as i64)
}

pub fn to_machine_isize(self, cx: &impl HasDataLayout) -> InterpResult<'static, i64> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub fn metadata_section_name(target: &Target) -> &'static str {
// > Executable images do not use a string table and do not support
// > section names longer than 8 characters
//
// https://msdn.microsoft.com/en-us/library/windows/hardware/gg463119.aspx
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
//
// As a result, we choose a slightly shorter name! As to why
// `.note.rustc` works on MinGW, that's another good question...
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_ssa/back/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ impl Command {
// error code if we fail to spawn and automatically re-spawning the
// linker with smaller arguments.
//
// [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
// [2]: https://blogs.msdn.microsoft.com/oldnewthing/20031210-00/?p=41553
// [1]: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa
// [2]: https://devblogs.microsoft.com/oldnewthing/?p=41553

let estimated_command_line_len = self.args.iter().map(|a| a.len()).sum::<usize>();
estimated_command_line_len > 1024 * 6
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ pub fn exec_linker(
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_like_msvc {
// This is "documented" at
// https://msdn.microsoft.com/en-us/library/4xdcbak7.aspx
// https://docs.microsoft.com/en-us/cpp/build/reference/at-specify-a-linker-response-file
//
// Unfortunately there's not a great specification of the
// syntax I could find online (at least) but some local
Expand Down
9 changes: 6 additions & 3 deletions src/librustc_codegen_ssa/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,14 +618,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
if let mir::PlaceRef {
base:
&PlaceBase::Static(box Static {
kind: StaticKind::Promoted(promoted, _),
kind: StaticKind::Promoted(promoted, substs),
ty,
def_id: _,
def_id,
}),
projection: &[],
} = place.as_ref()
{
let c = bx.tcx().const_eval_promoted(self.instance, promoted);
let c = bx.tcx().const_eval_promoted(
Instance::new(def_id, self.monomorphize(&substs)),
promoted,
);
let (llval, ty) = self.simd_shuffle_indices(
&bx,
terminator.source_info.span,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_target/abi/call/x86_win64.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::abi::call::{ArgAbi, FnAbi, Reg};
use crate::abi::Abi;

// Win64 ABI: http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx
// Win64 ABI: https://docs.microsoft.com/en-us/cpp/build/parameter-passing

pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
let fixup = |a: &mut ArgAbi<'_, Ty>| {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_target/spec/i686_pc_windows_msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> TargetResult {

// Ensure the linker will only produce an image if it can also produce a table of
// the image's safe exception handlers.
// https://msdn.microsoft.com/en-us/library/9a89h429.aspx
// https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers
base.pre_link_args.get_mut(&LinkerFlavor::Msvc).unwrap().push("/SAFESEH".to_string());

Ok(Target {
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ impl Error for JoinPathsError {
/// (including to an empty string).
/// - If both do not exist, [`GetUserProfileDirectory`][msdn] is used to return the path.
///
/// [msdn]: https://msdn.microsoft.com/en-us/library/windows/desktop/bb762280(v=vs.85).aspx
/// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-getuserprofiledirectorya
///
/// # Examples
///
Expand Down Expand Up @@ -591,7 +591,7 @@ pub fn home_dir() -> Option<PathBuf> {
/// This behavior is identical to that of [`GetTempPath`][msdn], which this
/// function uses internally.
///
/// [msdn]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364992(v=vs.85).aspx
/// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha
///
/// ```no_run
/// use std::env;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ pub fn read_link<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
/// or written to a file another application may read).
///
/// [changes]: ../io/index.html#platform-specific-behavior
/// [path]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath
/// [path]: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
///
/// # Errors
///
Expand Down
Loading

0 comments on commit 7d1b419

Please sign in to comment.