Skip to content

Commit 7d1b419

Browse files
committed
Auto merge of #67626 - JohnTitor:rollup-bt8kv3i, r=JohnTitor
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
2 parents c0b16b4 + e5aa687 commit 7d1b419

File tree

23 files changed

+147
-104
lines changed

23 files changed

+147
-104
lines changed

Diff for: src/doc/unstable-book/src/language-features/lang-items.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,7 @@ pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
188188

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

197193
## More about the language items
198194

Diff for: src/doc/unstable-book/src/library-features/compiler-builtins-lib.md

-35
This file was deleted.

Diff for: src/etc/installer/msi/rust.wxs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
<Property Id="ARPPRODUCTICON" Value="rust.ico" />
8686
<Property Id="ARPURLINFOABOUT" Value="https://www.rust-lang.org/" />
8787
<Property Id="ARPCOMMENTS" Value="$(env.CFG_RELEASE_INFO)" />
88-
<!-- This is a dual-mode package. http://msdn.microsoft.com/en-us/library/windows/desktop/dd408068.aspx -->
88+
<!-- This is a dual-mode package. https://docs.microsoft.com/en-us/windows/win32/msi/single-package-authoring -->
8989
<Property Id="ALLUSERS" Value="2" Secure="yes" />
9090
<Property Id="MSIINSTALLPERUSER" Secure="yes" />
9191
<!-- The actual install location (initialized below) -->

Diff for: src/liballoc/slice.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,8 @@ impl<T> [T] {
450450
// and `rem` is the remaining part of `n`.
451451

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

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

477478
// `rem` (`= n - 2^expn`) repetition is done by copying
478479
// first `rem` repetitions from `buf` itself.
479-
let rem_len = self.len() * n - buf.len(); // `self.len() * rem`
480+
let rem_len = capacity - buf.len(); // `self.len() * rem`
480481
if rem_len > 0 {
481482
// `buf.extend(buf[0 .. rem_len])`:
482483
unsafe {
@@ -487,8 +488,7 @@ impl<T> [T] {
487488
rem_len,
488489
);
489490
// `buf.len() + rem_len` equals to `buf.capacity()` (`= self.len() * n`).
490-
let buf_cap = buf.capacity();
491-
buf.set_len(buf_cap);
491+
buf.set_len(capacity);
492492
}
493493
}
494494
buf

Diff for: src/libcore/intrinsics.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ extern "rust-intrinsic" {
697697

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

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

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

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

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

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

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

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

14021402
/// Internal hook used by Miri to implement unwinding.

Diff for: src/libpanic_unwind/seh.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
//! are then recovered in the filter function to be written to the stack frame
4242
//! of the `try` intrinsic.
4343
//!
44-
//! [win64]: http://msdn.microsoft.com/en-us/library/1eyas8tf.aspx
44+
//! [win64]: https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64
4545
//! [llvm]: http://llvm.org/docs/ExceptionHandling.html#background-on-windows-exceptions
4646
4747
#![allow(nonstandard_style)]

Diff for: src/librustc/mir/interpret/value.rs

+35-21
Original file line numberDiff line numberDiff line change
@@ -415,48 +415,62 @@ impl<'tcx, Tag> Scalar<Tag> {
415415
}
416416
}
417417

418+
#[inline]
419+
fn to_unsigned_with_bit_width(self, bits: u64) -> InterpResult<'static, u128> {
420+
let sz = Size::from_bits(bits);
421+
self.to_bits(sz)
422+
}
423+
424+
/// Converts the scalar to produce an `u8`. Fails if the scalar is a pointer.
418425
pub fn to_u8(self) -> InterpResult<'static, u8> {
419-
let sz = Size::from_bits(8);
420-
let b = self.to_bits(sz)?;
421-
Ok(b as u8)
426+
self.to_unsigned_with_bit_width(8).map(|v| v as u8)
427+
}
428+
429+
/// Converts the scalar to produce an `u16`. Fails if the scalar is a pointer.
430+
pub fn to_u16(self) -> InterpResult<'static, u16> {
431+
self.to_unsigned_with_bit_width(16).map(|v| v as u16)
422432
}
423433

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

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

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

441-
pub fn to_i8(self) -> InterpResult<'static, i8> {
442-
let sz = Size::from_bits(8);
449+
#[inline]
450+
fn to_signed_with_bit_width(self, bits: u64) -> InterpResult<'static, i128> {
451+
let sz = Size::from_bits(bits);
443452
let b = self.to_bits(sz)?;
444-
let b = sign_extend(b, sz) as i128;
445-
Ok(b as i8)
453+
Ok(sign_extend(b, sz) as i128)
454+
}
455+
456+
/// Converts the scalar to produce an `i8`. Fails if the scalar is a pointer.
457+
pub fn to_i8(self) -> InterpResult<'static, i8> {
458+
self.to_signed_with_bit_width(8).map(|v| v as i8)
459+
}
460+
461+
/// Converts the scalar to produce an `i16`. Fails if the scalar is a pointer.
462+
pub fn to_i16(self) -> InterpResult<'static, i16> {
463+
self.to_signed_with_bit_width(16).map(|v| v as i16)
446464
}
447465

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

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

462476
pub fn to_machine_isize(self, cx: &impl HasDataLayout) -> InterpResult<'static, i64> {

Diff for: src/librustc_codegen_llvm/metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn metadata_section_name(target: &Target) -> &'static str {
9797
// > Executable images do not use a string table and do not support
9898
// > section names longer than 8 characters
9999
//
100-
// https://msdn.microsoft.com/en-us/library/windows/hardware/gg463119.aspx
100+
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
101101
//
102102
// As a result, we choose a slightly shorter name! As to why
103103
// `.note.rustc` works on MinGW, that's another good question...

Diff for: src/librustc_codegen_ssa/back/command.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ impl Command {
168168
// error code if we fail to spawn and automatically re-spawning the
169169
// linker with smaller arguments.
170170
//
171-
// [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
172-
// [2]: https://blogs.msdn.microsoft.com/oldnewthing/20031210-00/?p=41553
171+
// [1]: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa
172+
// [2]: https://devblogs.microsoft.com/oldnewthing/?p=41553
173173

174174
let estimated_command_line_len = self.args.iter().map(|a| a.len()).sum::<usize>();
175175
estimated_command_line_len > 1024 * 6

Diff for: src/librustc_codegen_ssa/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ pub fn exec_linker(
10441044
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10451045
if self.is_like_msvc {
10461046
// This is "documented" at
1047-
// https://msdn.microsoft.com/en-us/library/4xdcbak7.aspx
1047+
// https://docs.microsoft.com/en-us/cpp/build/reference/at-specify-a-linker-response-file
10481048
//
10491049
// Unfortunately there's not a great specification of the
10501050
// syntax I could find online (at least) but some local

Diff for: src/librustc_codegen_ssa/mir/block.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -618,14 +618,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
618618
if let mir::PlaceRef {
619619
base:
620620
&PlaceBase::Static(box Static {
621-
kind: StaticKind::Promoted(promoted, _),
621+
kind: StaticKind::Promoted(promoted, substs),
622622
ty,
623-
def_id: _,
623+
def_id,
624624
}),
625625
projection: &[],
626626
} = place.as_ref()
627627
{
628-
let c = bx.tcx().const_eval_promoted(self.instance, promoted);
628+
let c = bx.tcx().const_eval_promoted(
629+
Instance::new(def_id, self.monomorphize(&substs)),
630+
promoted,
631+
);
629632
let (llval, ty) = self.simd_shuffle_indices(
630633
&bx,
631634
terminator.source_info.span,

Diff for: src/librustc_target/abi/call/x86_win64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::abi::call::{ArgAbi, FnAbi, Reg};
22
use crate::abi::Abi;
33

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

66
pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
77
let fixup = |a: &mut ArgAbi<'_, Ty>| {

Diff for: src/librustc_target/spec/i686_pc_windows_msvc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> TargetResult {
1111

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

1717
Ok(Target {

Diff for: src/libstd/env.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ impl Error for JoinPathsError {
552552
/// (including to an empty string).
553553
/// - If both do not exist, [`GetUserProfileDirectory`][msdn] is used to return the path.
554554
///
555-
/// [msdn]: https://msdn.microsoft.com/en-us/library/windows/desktop/bb762280(v=vs.85).aspx
555+
/// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-getuserprofiledirectorya
556556
///
557557
/// # Examples
558558
///
@@ -591,7 +591,7 @@ pub fn home_dir() -> Option<PathBuf> {
591591
/// This behavior is identical to that of [`GetTempPath`][msdn], which this
592592
/// function uses internally.
593593
///
594-
/// [msdn]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364992(v=vs.85).aspx
594+
/// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha
595595
///
596596
/// ```no_run
597597
/// use std::env;

Diff for: src/libstd/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ pub fn read_link<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
18411841
/// or written to a file another application may read).
18421842
///
18431843
/// [changes]: ../io/index.html#platform-specific-behavior
1844-
/// [path]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath
1844+
/// [path]: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
18451845
///
18461846
/// # Errors
18471847
///

0 commit comments

Comments
 (0)