Skip to content

Commit 0206312

Browse files
committed
Auto merge of rust-lang#90934 - JohnTitor:rollup-5soqo0j, r=JohnTitor
Rollup of 10 pull requests Successful merges: - rust-lang#85766 (Stabilize File::options()) - rust-lang#88601 (Implement `Termination` for `Result<Infallible, E>`) - rust-lang#90058 (Stabilize -Z strip as -C strip) - rust-lang#90790 (Fix standard library test with read_link) - rust-lang#90834 (Android is not GNU) - rust-lang#90835 (Rename WASI's `is_character_device` to `is_char_device`.) - rust-lang#90837 (Move some tests to more reasonable directories - 9) - rust-lang#90848 (Remove bigint_helper_methods for *signed* types) - rust-lang#90892 (fix ICE on Miri/CTFE copy of half a pointer) - rust-lang#90909 (disable portable SIMD tests in Miri) Failed merges: - rust-lang#90128 (Stabilize -Z symbol-mangling-version=v0 as -C symbol-mangling-version=v0) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b053550 + 35dd1f6 commit 0206312

File tree

205 files changed

+121
-355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+121
-355
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -1034,15 +1034,25 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
10341034
SplitDebuginfo::Packed => link_dwarf_object(sess, &out_filename),
10351035
}
10361036

1037+
let strip = strip_value(sess);
1038+
10371039
if sess.target.is_like_osx {
1038-
match sess.opts.debugging_opts.strip {
1040+
match strip {
10391041
Strip::Debuginfo => strip_symbols_in_osx(sess, &out_filename, Some("-S")),
10401042
Strip::Symbols => strip_symbols_in_osx(sess, &out_filename, None),
10411043
Strip::None => {}
10421044
}
10431045
}
10441046
}
10451047

1048+
// Temporarily support both -Z strip and -C strip
1049+
fn strip_value(sess: &Session) -> Strip {
1050+
match (sess.opts.debugging_opts.strip, sess.opts.cg.strip) {
1051+
(s, Strip::None) => s,
1052+
(_, s) => s,
1053+
}
1054+
}
1055+
10461056
fn strip_symbols_in_osx<'a>(sess: &'a Session, out_filename: &Path, option: Option<&str>) {
10471057
let mut cmd = Command::new("strip");
10481058
if let Some(option) = option {
@@ -2014,7 +2024,7 @@ fn add_order_independent_options(
20142024
cmd.optimize();
20152025

20162026
// Pass debuginfo and strip flags down to the linker.
2017-
cmd.debuginfo(sess.opts.debugging_opts.strip);
2027+
cmd.debuginfo(strip_value(sess));
20182028

20192029
// We want to prevent the compiler from accidentally leaking in any system libraries,
20202030
// so by default we tell linkers not to link to any default libraries.

compiler/rustc_const_eval/src/interpret/memory.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1057,20 +1057,19 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
10571057
Some(dest_ptr) => dest_ptr,
10581058
};
10591059

1060+
// This checks relocation edges on the src, which needs to happen before
1061+
// `prepare_relocation_copy`.
1062+
let src_bytes = src_alloc
1063+
.get_bytes_with_uninit_and_ptr(&tcx, src_range)
1064+
.map_err(|e| e.to_interp_error(src_alloc_id))?
1065+
.as_ptr(); // raw ptr, so we can also get a ptr to the destination allocation
10601066
// first copy the relocations to a temporary buffer, because
10611067
// `get_bytes_mut` will clear the relocations, which is correct,
10621068
// since we don't want to keep any relocations at the target.
1063-
// (`get_bytes_with_uninit_and_ptr` below checks that there are no
1064-
// relocations overlapping the edges; those would not be handled correctly).
10651069
let relocations =
10661070
src_alloc.prepare_relocation_copy(self, src_range, dest_offset, num_copies);
10671071
// Prepare a copy of the initialization mask.
10681072
let compressed = src_alloc.compress_uninit_range(src_range);
1069-
// This checks relocation edges on the src.
1070-
let src_bytes = src_alloc
1071-
.get_bytes_with_uninit_and_ptr(&tcx, src_range)
1072-
.map_err(|e| e.to_interp_error(src_alloc_id))?
1073-
.as_ptr(); // raw ptr, so we can also get a ptr to the destination allocation
10741073

10751074
// Destination alloc preparations and access hooks.
10761075
let (dest_alloc, extra) = self.get_raw_mut(dest_alloc_id)?;

compiler/rustc_interface/src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ fn test_codegen_options_tracking_hash() {
551551
untracked!(remark, Passes::Some(vec![String::from("pass1"), String::from("pass2")]));
552552
untracked!(rpath, true);
553553
untracked!(save_temps, true);
554+
untracked!(strip, Strip::Debuginfo);
554555

555556
macro_rules! tracked {
556557
($name: ident, $non_default_value: expr) => {
@@ -684,7 +685,6 @@ fn test_debugging_options_tracking_hash() {
684685
untracked!(self_profile_events, Some(vec![String::new()]));
685686
untracked!(span_debug, true);
686687
untracked!(span_free_formats, true);
687-
untracked!(strip, Strip::Debuginfo);
688688
untracked!(temps_dir, Some(String::from("abc")));
689689
untracked!(terminal_width, Some(80));
690690
untracked!(threads, 99);

compiler/rustc_session/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use std::iter::{self, FromIterator};
3737
use std::path::{Path, PathBuf};
3838
use std::str::{self, FromStr};
3939

40-
/// The different settings that the `-Z strip` flag can have.
40+
/// The different settings that the `-C strip` flag can have.
4141
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
4242
pub enum Strip {
4343
/// Do not strip at all.

compiler/rustc_session/src/options.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ top_level_options!(
219219
/// generated code to parse an option into its respective field in the struct. There are a few
220220
/// hand-written parsers for parsing specific types of values in this module.
221221
macro_rules! options {
222-
($struct_name:ident, $stat:ident, $prefix:expr, $outputname:expr,
222+
($struct_name:ident, $stat:ident, $optmod:ident, $prefix:expr, $outputname:expr,
223223
$($( #[$attr:meta] )* $opt:ident : $t:ty = (
224224
$init:expr,
225225
$parse:ident,
@@ -264,13 +264,15 @@ macro_rules! options {
264264
}
265265

266266
pub const $stat: OptionDescrs<$struct_name> =
267-
&[ $( (stringify!($opt), $opt, desc::$parse, $desc) ),* ];
267+
&[ $( (stringify!($opt), $optmod::$opt, desc::$parse, $desc) ),* ];
268268

269+
mod $optmod {
269270
$(
270-
fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
271-
parse::$parse(&mut redirect_field!(cg.$opt), v)
271+
pub(super) fn $opt(cg: &mut super::$struct_name, v: Option<&str>) -> bool {
272+
super::parse::$parse(&mut redirect_field!(cg.$opt), v)
272273
}
273274
)*
275+
}
274276

275277
) }
276278

@@ -918,7 +920,7 @@ mod parse {
918920
}
919921

920922
options! {
921-
CodegenOptions, CG_OPTIONS, "C", "codegen",
923+
CodegenOptions, CG_OPTIONS, cgopts, "C", "codegen",
922924

923925
// This list is in alphabetical order.
924926
//
@@ -1013,6 +1015,8 @@ options! {
10131015
"use soft float ABI (*eabihf targets only) (default: no)"),
10141016
split_debuginfo: Option<SplitDebuginfo> = (None, parse_split_debuginfo, [TRACKED],
10151017
"how to handle split-debuginfo, a platform-specific option"),
1018+
strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
1019+
"tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
10161020
target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
10171021
"select target processor (`rustc --print target-cpus` for details)"),
10181022
target_feature: String = (String::new(), parse_target_feature, [TRACKED],
@@ -1027,7 +1031,7 @@ options! {
10271031
}
10281032

10291033
options! {
1030-
DebuggingOptions, DB_OPTIONS, "Z", "debugging",
1034+
DebuggingOptions, DB_OPTIONS, dbopts, "Z", "debugging",
10311035

10321036
// This list is in alphabetical order.
10331037
//

compiler/rustc_target/src/spec/android_base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::spec::{LinkerFlavor, TargetOptions};
22

33
pub fn opts() -> TargetOptions {
4-
let mut base = super::linux_gnu_base::opts();
4+
let mut base = super::linux_base::opts();
55
base.os = "android".to_string();
66
// Many of the symbols defined in compiler-rt are also defined in libgcc.
77
// Android's linker doesn't like that by default.

library/core/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,13 @@ pub mod arch {
402402
#[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)]
403403
#[allow(rustdoc::bare_urls)]
404404
#[unstable(feature = "portable_simd", issue = "86656")]
405+
#[cfg(not(all(miri, doctest)))] // Miri does not support all SIMD intrinsics
405406
#[cfg(not(bootstrap))]
406407
mod core_simd;
407408

408409
#[doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")]
409410
#[unstable(feature = "portable_simd", issue = "86656")]
411+
#[cfg(not(all(miri, doctest)))] // Miri does not support all SIMD intrinsics
410412
#[cfg(not(bootstrap))]
411413
pub mod simd {
412414
#[unstable(feature = "portable_simd", issue = "86656")]

library/core/src/num/int_macros.rs

-54
Original file line numberDiff line numberDiff line change
@@ -1511,33 +1511,6 @@ macro_rules! int_impl {
15111511
(a as Self, b)
15121512
}
15131513

1514-
/// Calculates `self + rhs + carry` without the ability to overflow.
1515-
///
1516-
/// Performs "ternary addition" which takes in an extra bit to add, and may return an
1517-
/// additional bit of overflow. This allows for chaining together multiple additions
1518-
/// to create "big integers" which represent larger values.
1519-
///
1520-
/// # Examples
1521-
///
1522-
/// Basic usage
1523-
///
1524-
/// ```
1525-
/// #![feature(bigint_helper_methods)]
1526-
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".carrying_add(2, false), (7, false));")]
1527-
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".carrying_add(2, true), (8, false));")]
1528-
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(1, false), (", stringify!($SelfT), "::MIN, false));")]
1529-
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(1, true), (", stringify!($SelfT), "::MIN + 1, false));")]
1530-
/// ```
1531-
#[unstable(feature = "bigint_helper_methods", issue = "85532")]
1532-
#[rustc_const_unstable(feature = "const_bigint_helper_methods", issue = "85532")]
1533-
#[must_use = "this returns the result of the operation, \
1534-
without modifying the original"]
1535-
#[inline]
1536-
pub const fn carrying_add(self, rhs: Self, carry: bool) -> (Self, bool) {
1537-
let (sum, carry) = (self as $UnsignedT).carrying_add(rhs as $UnsignedT, carry);
1538-
(sum as $SelfT, carry)
1539-
}
1540-
15411514
/// Calculates `self` + `rhs` with an unsigned `rhs`
15421515
///
15431516
/// Returns a tuple of the addition along with a boolean indicating
@@ -1589,33 +1562,6 @@ macro_rules! int_impl {
15891562
(a as Self, b)
15901563
}
15911564

1592-
/// Calculates `self - rhs - borrow` without the ability to overflow.
1593-
///
1594-
/// Performs "ternary subtraction" which takes in an extra bit to subtract, and may return
1595-
/// an additional bit of overflow. This allows for chaining together multiple subtractions
1596-
/// to create "big integers" which represent larger values.
1597-
///
1598-
/// # Examples
1599-
///
1600-
/// Basic usage
1601-
///
1602-
/// ```
1603-
/// #![feature(bigint_helper_methods)]
1604-
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".borrowing_sub(2, false), (3, false));")]
1605-
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".borrowing_sub(2, true), (2, false));")]
1606-
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.borrowing_sub(1, false), (", stringify!($SelfT), "::MAX, false));")]
1607-
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.borrowing_sub(1, true), (", stringify!($SelfT), "::MAX - 1, false));")]
1608-
/// ```
1609-
#[unstable(feature = "bigint_helper_methods", issue = "85532")]
1610-
#[rustc_const_unstable(feature = "const_bigint_helper_methods", issue = "85532")]
1611-
#[must_use = "this returns the result of the operation, \
1612-
without modifying the original"]
1613-
#[inline]
1614-
pub const fn borrowing_sub(self, rhs: Self, borrow: bool) -> (Self, bool) {
1615-
let (sum, borrow) = (self as $UnsignedT).borrowing_sub(rhs as $UnsignedT, borrow);
1616-
(sum as $SelfT, borrow)
1617-
}
1618-
16191565
/// Calculates `self` - `rhs` with an unsigned `rhs`
16201566
///
16211567
/// Returns a tuple of the subtraction along with a boolean indicating

library/core/src/num/mod.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,6 @@ depending on the target pointer size.
9595

9696
macro_rules! widening_impl {
9797
($SelfT:ty, $WideT:ty, $BITS:literal, unsigned) => {
98-
widening_impl!($SelfT, $WideT, $BITS, "");
99-
};
100-
($SelfT:ty, $WideT:ty, $BITS:literal, signed) => {
101-
widening_impl!($SelfT, $WideT, $BITS, "# //");
102-
};
103-
($SelfT:ty, $WideT:ty, $BITS:literal, $AdaptiveTestPrefix:literal) => {
10498
/// Calculates the complete product `self * rhs` without the possibility to overflow.
10599
///
106100
/// This returns the low-order (wrapping) bits and the high-order (overflow) bits
@@ -154,7 +148,7 @@ macro_rules! widening_impl {
154148
/// assert_eq!(5u32.carrying_mul(2, 10), (20, 0));
155149
/// assert_eq!(1_000_000_000u32.carrying_mul(10, 0), (1410065408, 2));
156150
/// assert_eq!(1_000_000_000u32.carrying_mul(10, 10), (1410065418, 2));
157-
#[doc = concat!($AdaptiveTestPrefix, "assert_eq!(",
151+
#[doc = concat!("assert_eq!(",
158152
stringify!($SelfT), "::MAX.carrying_mul(", stringify!($SelfT), "::MAX, ", stringify!($SelfT), "::MAX), ",
159153
"(0, ", stringify!($SelfT), "::MAX));"
160154
)]
@@ -203,22 +197,19 @@ macro_rules! widening_impl {
203197
impl i8 {
204198
int_impl! { i8, i8, u8, 8, 7, -128, 127, 2, "-0x7e", "0xa", "0x12", "0x12", "0x48",
205199
"[0x12]", "[0x12]", "", "" }
206-
widening_impl! { i8, i16, 8, signed }
207200
}
208201

209202
#[lang = "i16"]
210203
impl i16 {
211204
int_impl! { i16, i16, u16, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234", "0x3412",
212205
"0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", "", "" }
213-
widening_impl! { i16, i32, 16, signed }
214206
}
215207

216208
#[lang = "i32"]
217209
impl i32 {
218210
int_impl! { i32, i32, u32, 32, 31, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
219211
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
220212
"[0x12, 0x34, 0x56, 0x78]", "", "" }
221-
widening_impl! { i32, i64, 32, signed }
222213
}
223214

224215
#[lang = "i64"]
@@ -227,7 +218,6 @@ impl i64 {
227218
"0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
228219
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
229220
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]", "", "" }
230-
widening_impl! { i64, i128, 64, signed }
231221
}
232222

233223
#[lang = "i128"]
@@ -248,7 +238,6 @@ impl isize {
248238
int_impl! { isize, i16, usize, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234",
249239
"0x3412", "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]",
250240
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
251-
widening_impl! { isize, i32, 16, signed }
252241
}
253242

254243
#[cfg(target_pointer_width = "32")]
@@ -258,7 +247,6 @@ impl isize {
258247
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
259248
"[0x12, 0x34, 0x56, 0x78]",
260249
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
261-
widening_impl! { isize, i64, 32, signed }
262250
}
263251

264252
#[cfg(target_pointer_width = "64")]
@@ -269,7 +257,6 @@ impl isize {
269257
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
270258
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]",
271259
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
272-
widening_impl! { isize, i128, 64, signed }
273260
}
274261

275262
/// If 6th bit set ascii is upper case.

library/core/tests/simd.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(miri))] // Miri does not support all SIMD intrinsics
2+
13
use core::simd::f32x4;
24

35
#[test]

library/std/src/fs.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -358,25 +358,24 @@ impl File {
358358
///
359359
/// It is equivalent to `OpenOptions::new()` but allows you to write more
360360
/// readable code. Instead of `OpenOptions::new().read(true).open("foo.txt")`
361-
/// you can write `File::with_options().read(true).open("foo.txt")`. This
361+
/// you can write `File::options().read(true).open("foo.txt")`. This
362362
/// also avoids the need to import `OpenOptions`.
363363
///
364364
/// See the [`OpenOptions::new`] function for more details.
365365
///
366366
/// # Examples
367367
///
368368
/// ```no_run
369-
/// #![feature(with_options)]
370369
/// use std::fs::File;
371370
///
372371
/// fn main() -> std::io::Result<()> {
373-
/// let mut f = File::with_options().read(true).open("foo.txt")?;
372+
/// let mut f = File::options().read(true).open("foo.txt")?;
374373
/// Ok(())
375374
/// }
376375
/// ```
377376
#[must_use]
378-
#[unstable(feature = "with_options", issue = "65439")]
379-
pub fn with_options() -> OpenOptions {
377+
#[stable(feature = "with_options", since = "1.58.0")]
378+
pub fn options() -> OpenOptions {
380379
OpenOptions::new()
381380
}
382381

library/std/src/fs/tests.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -833,20 +833,11 @@ fn symlink_noexist() {
833833
fn read_link() {
834834
if cfg!(windows) {
835835
// directory symlink
836-
assert_eq!(
837-
check!(fs::read_link(r"C:\Users\All Users")).to_str().unwrap(),
838-
r"C:\ProgramData"
839-
);
836+
assert_eq!(check!(fs::read_link(r"C:\Users\All Users")), Path::new(r"C:\ProgramData"));
840837
// junction
841-
assert_eq!(
842-
check!(fs::read_link(r"C:\Users\Default User")).to_str().unwrap(),
843-
r"C:\Users\Default"
844-
);
838+
assert_eq!(check!(fs::read_link(r"C:\Users\Default User")), Path::new(r"C:\Users\Default"));
845839
// junction with special permissions
846-
assert_eq!(
847-
check!(fs::read_link(r"C:\Documents and Settings\")).to_str().unwrap(),
848-
r"C:\Users"
849-
);
840+
assert_eq!(check!(fs::read_link(r"C:\Documents and Settings\")), Path::new(r"C:\Users"));
850841
}
851842
let tmpdir = tmpdir();
852843
let link = tmpdir.join("link");

library/std/src/os/wasi/fs.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -444,18 +444,22 @@ pub trait FileTypeExt {
444444
/// Returns `true` if this file type is a block device.
445445
fn is_block_device(&self) -> bool;
446446
/// Returns `true` if this file type is a character device.
447-
fn is_character_device(&self) -> bool;
447+
fn is_char_device(&self) -> bool;
448448
/// Returns `true` if this file type is a socket datagram.
449449
fn is_socket_dgram(&self) -> bool;
450450
/// Returns `true` if this file type is a socket stream.
451451
fn is_socket_stream(&self) -> bool;
452+
/// Returns `true` if this file type is any type of socket.
453+
fn is_socket(&self) -> bool {
454+
self.is_socket_stream() || self.is_socket_dgram()
455+
}
452456
}
453457

454458
impl FileTypeExt for fs::FileType {
455459
fn is_block_device(&self) -> bool {
456460
self.as_inner().bits() == wasi::FILETYPE_BLOCK_DEVICE
457461
}
458-
fn is_character_device(&self) -> bool {
462+
fn is_char_device(&self) -> bool {
459463
self.as_inner().bits() == wasi::FILETYPE_CHARACTER_DEVICE
460464
}
461465
fn is_socket_dgram(&self) -> bool {

0 commit comments

Comments
 (0)