Skip to content

Commit ecf2d1f

Browse files
committed
Auto merge of rust-lang#131635 - tgross35:rollup-df8il2t, r=tgross35
Rollup of 7 pull requests Successful merges: - rust-lang#131120 (Stabilize `const_option`) - rust-lang#131334 (Enable sanitizers for loongarch64-unknown-*) - rust-lang#131358 (force "HEAD" for non-CI and `git_upstream_merge_base` for CI environment) - rust-lang#131418 (Use throw intrinsic from stdarch in wasm libunwind) - rust-lang#131579 (Remap path prefix in the panic message of `tests/ui/meta/revision-bad.rs`) - rust-lang#131591 (add latest crash tests) - rust-lang#131626 (remove a couple of redundant String to String conversion) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ef4e825 + 39071fd commit ecf2d1f

File tree

35 files changed

+160
-55
lines changed

35 files changed

+160
-55
lines changed

.github/workflows/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ jobs:
122122
# which then uses log commands to actually set them.
123123
EXTRA_VARIABLES: ${{ toJson(matrix.env) }}
124124

125+
- name: setup upstream remote
126+
run: src/ci/scripts/setup-upstream-remote.sh
127+
125128
- name: ensure the channel matches the target branch
126129
run: src/ci/scripts/verify-channel.sh
127130

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
706706
suggestions.push((
707707
pat_span,
708708
format!("consider removing the {to_remove}"),
709-
suggestion.to_string(),
709+
suggestion,
710710
));
711711
}
712712
}

compiler/rustc_codegen_llvm/src/asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
154154
// We prefer the latter because it matches the behavior of
155155
// Clang.
156156
if late && matches!(reg, InlineAsmRegOrRegClass::Reg(_)) {
157-
constraints.push(reg_to_llvm(reg, Some(&in_value.layout)).to_string());
157+
constraints.push(reg_to_llvm(reg, Some(&in_value.layout)));
158158
} else {
159159
constraints.push(format!("{}", op_idx[&idx]));
160160
}

compiler/rustc_middle/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#![feature(box_as_ptr)]
3838
#![feature(box_patterns)]
3939
#![feature(closure_track_caller)]
40-
#![feature(const_option)]
4140
#![feature(const_type_name)]
4241
#![feature(core_intrinsics)]
4342
#![feature(coroutines)]

compiler/rustc_middle/src/ty/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ pub fn suggest_constraining_type_params<'a>(
325325
let suggestion = if span_to_replace.is_some() {
326326
constraint.clone()
327327
} else if constraint.starts_with('<') {
328-
constraint.to_string()
328+
constraint.clone()
329329
} else if bound_list_non_empty {
330330
format!(" + {constraint}")
331331
} else {

compiler/rustc_serialize/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
test(attr(allow(unused_variables), deny(warnings)))
1111
)]
1212
#![doc(rust_logo)]
13-
#![feature(const_option)]
1413
#![feature(core_intrinsics)]
1514
#![feature(min_specialization)]
1615
#![feature(never_type)]

compiler/rustc_session/src/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
137137
let content = if arg.len() == a.len() {
138138
// A space-separated option, like `-C incremental=foo` or `--crate-type rlib`
139139
match args.next() {
140-
Some(arg) => arg.to_string(),
140+
Some(arg) => arg,
141141
None => continue,
142142
}
143143
} else if arg.get(a.len()..a.len() + 1) == Some("=") {

compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::spec::{CodeModel, Target, TargetOptions, base};
1+
use crate::spec::{CodeModel, SanitizerSet, Target, TargetOptions, base};
22

33
pub(crate) fn target() -> Target {
44
Target {
@@ -18,6 +18,11 @@ pub(crate) fn target() -> Target {
1818
features: "+f,+d".into(),
1919
llvm_abiname: "lp64d".into(),
2020
max_atomic_width: Some(64),
21+
supported_sanitizers: SanitizerSet::ADDRESS
22+
| SanitizerSet::CFI
23+
| SanitizerSet::LEAK
24+
| SanitizerSet::MEMORY
25+
| SanitizerSet::THREAD,
2126
direct_access_external_data: Some(false),
2227
..base::linux_gnu::opts()
2328
},

compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_musl.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::spec::{CodeModel, Target, TargetOptions, base};
1+
use crate::spec::{CodeModel, SanitizerSet, Target, TargetOptions, base};
22

33
pub(crate) fn target() -> Target {
44
Target {
@@ -19,6 +19,11 @@ pub(crate) fn target() -> Target {
1919
llvm_abiname: "lp64d".into(),
2020
max_atomic_width: Some(64),
2121
crt_static_default: false,
22+
supported_sanitizers: SanitizerSet::ADDRESS
23+
| SanitizerSet::CFI
24+
| SanitizerSet::LEAK
25+
| SanitizerSet::MEMORY
26+
| SanitizerSet::THREAD,
2227
..base::linux_musl::opts()
2328
},
2429
}

compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_ohos.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::spec::{Target, TargetOptions, base};
1+
use crate::spec::{SanitizerSet, Target, TargetOptions, base};
22

33
pub(crate) fn target() -> Target {
44
Target {
@@ -17,6 +17,11 @@ pub(crate) fn target() -> Target {
1717
features: "+f,+d".into(),
1818
llvm_abiname: "lp64d".into(),
1919
max_atomic_width: Some(64),
20+
supported_sanitizers: SanitizerSet::ADDRESS
21+
| SanitizerSet::CFI
22+
| SanitizerSet::LEAK
23+
| SanitizerSet::MEMORY
24+
| SanitizerSet::THREAD,
2025
..base::linux_ohos::opts()
2126
},
2227
}

library/alloc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111
#![feature(const_eval_select)]
112112
#![feature(const_heap)]
113113
#![feature(const_maybe_uninit_write)]
114-
#![feature(const_option)]
115114
#![feature(const_pin)]
116115
#![feature(const_size_of_val)]
117116
#![feature(const_vec_string_slice)]

library/core/src/array/ascii.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ impl<const N: usize> [u8; N] {
99
///
1010
/// ```
1111
/// #![feature(ascii_char)]
12-
/// #![feature(const_option)]
1312
///
1413
/// const HEX_DIGITS: [std::ascii::Char; 16] =
1514
/// *b"0123456789abcdef".as_ascii().unwrap();

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@
131131
#![feature(const_maybe_uninit_assume_init)]
132132
#![feature(const_nonnull_new)]
133133
#![feature(const_num_midpoint)]
134-
#![feature(const_option)]
135134
#![feature(const_option_ext)]
136135
#![feature(const_pin)]
137136
#![feature(const_pointer_is_aligned)]

library/core/src/option.rs

+19-11
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,8 @@ impl<T> Option<T> {
723723
/// ```
724724
#[inline]
725725
#[stable(feature = "rust1", since = "1.0.0")]
726-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
726+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
727+
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
727728
pub const fn as_mut(&mut self) -> Option<&mut T> {
728729
match *self {
729730
Some(ref mut x) => Some(x),
@@ -924,7 +925,8 @@ impl<T> Option<T> {
924925
#[track_caller]
925926
#[stable(feature = "rust1", since = "1.0.0")]
926927
#[cfg_attr(not(test), rustc_diagnostic_item = "option_expect")]
927-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
928+
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
929+
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
928930
pub const fn expect(self, msg: &str) -> T {
929931
match self {
930932
Some(val) => val,
@@ -962,7 +964,8 @@ impl<T> Option<T> {
962964
#[track_caller]
963965
#[stable(feature = "rust1", since = "1.0.0")]
964966
#[cfg_attr(not(test), rustc_diagnostic_item = "option_unwrap")]
965-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
967+
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
968+
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
966969
pub const fn unwrap(self) -> T {
967970
match self {
968971
Some(val) => val,
@@ -1069,7 +1072,8 @@ impl<T> Option<T> {
10691072
#[inline]
10701073
#[track_caller]
10711074
#[stable(feature = "option_result_unwrap_unchecked", since = "1.58.0")]
1072-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
1075+
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
1076+
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
10731077
pub const unsafe fn unwrap_unchecked(self) -> T {
10741078
match self {
10751079
Some(val) => val,
@@ -1712,7 +1716,8 @@ impl<T> Option<T> {
17121716
/// ```
17131717
#[inline]
17141718
#[stable(feature = "rust1", since = "1.0.0")]
1715-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
1719+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
1720+
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
17161721
pub const fn take(&mut self) -> Option<T> {
17171722
// FIXME(const-hack) replace `mem::replace` by `mem::take` when the latter is const ready
17181723
mem::replace(self, None)
@@ -1769,8 +1774,9 @@ impl<T> Option<T> {
17691774
/// assert_eq!(old, None);
17701775
/// ```
17711776
#[inline]
1772-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
17731777
#[stable(feature = "option_replace", since = "1.31.0")]
1778+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
1779+
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
17741780
pub const fn replace(&mut self, value: T) -> Option<T> {
17751781
mem::replace(self, Some(value))
17761782
}
@@ -1878,7 +1884,7 @@ impl<T> Option<&T> {
18781884
/// ```
18791885
#[must_use = "`self` will be dropped if the result is not used"]
18801886
#[stable(feature = "copied", since = "1.35.0")]
1881-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
1887+
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
18821888
pub const fn copied(self) -> Option<T>
18831889
where
18841890
T: Copy,
@@ -1931,7 +1937,8 @@ impl<T> Option<&mut T> {
19311937
/// ```
19321938
#[must_use = "`self` will be dropped if the result is not used"]
19331939
#[stable(feature = "copied", since = "1.35.0")]
1934-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
1940+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
1941+
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
19351942
pub const fn copied(self) -> Option<T>
19361943
where
19371944
T: Copy,
@@ -1986,7 +1993,8 @@ impl<T, E> Option<Result<T, E>> {
19861993
/// ```
19871994
#[inline]
19881995
#[stable(feature = "transpose_result", since = "1.33.0")]
1989-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
1996+
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
1997+
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
19901998
pub const fn transpose(self) -> Result<Option<T>, E> {
19911999
match self {
19922000
Some(Ok(x)) => Ok(Some(x)),
@@ -2009,7 +2017,6 @@ const fn unwrap_failed() -> ! {
20092017
#[cfg_attr(feature = "panic_immediate_abort", inline)]
20102018
#[cold]
20112019
#[track_caller]
2012-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
20132020
const fn expect_failed(msg: &str) -> ! {
20142021
panic_display(&msg)
20152022
}
@@ -2534,7 +2541,8 @@ impl<T> Option<Option<T>> {
25342541
/// ```
25352542
#[inline]
25362543
#[stable(feature = "option_flattening", since = "1.40.0")]
2537-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
2544+
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
2545+
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
25382546
pub const fn flatten(self) -> Option<T> {
25392547
// FIXME(const-hack): could be written with `and_then`
25402548
match self {

library/core/src/ptr/non_null.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,6 @@ impl<T: ?Sized> NonNull<T> {
12111211
///
12121212
/// ```
12131213
/// #![feature(const_nonnull_new)]
1214-
/// #![feature(const_option)]
12151214
/// #![feature(const_pointer_is_aligned)]
12161215
/// use std::ptr::NonNull;
12171216
///
@@ -1264,7 +1263,6 @@ impl<T: ?Sized> NonNull<T> {
12641263
///
12651264
/// ```
12661265
/// #![feature(const_pointer_is_aligned)]
1267-
/// #![feature(const_option)]
12681266
/// #![feature(const_nonnull_new)]
12691267
/// use std::ptr::NonNull;
12701268
///

library/core/src/time.rs

-1
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,6 @@ impl Duration {
626626
/// ```
627627
#[stable(feature = "duration_abs_diff", since = "1.81.0")]
628628
#[rustc_const_stable(feature = "duration_abs_diff", since = "1.81.0")]
629-
#[rustc_allow_const_fn_unstable(const_option)]
630629
#[must_use = "this returns the result of the operation, \
631630
without modifying the original"]
632631
#[inline]

library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#![feature(const_ipv6)]
2525
#![feature(const_likely)]
2626
#![feature(const_nonnull_new)]
27-
#![feature(const_option)]
2827
#![feature(const_option_ext)]
2928
#![feature(const_pin)]
3029
#![feature(const_pointer_is_aligned)]

library/unwind/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
#![feature(link_cfg)]
44
#![feature(staged_api)]
55
#![feature(strict_provenance)]
6-
#![cfg_attr(target_arch = "wasm64", feature(simd_wasm64))]
76
#![cfg_attr(not(target_env = "msvc"), feature(libc))]
87
#![cfg_attr(
98
all(target_family = "wasm", not(target_os = "emscripten")),
10-
feature(link_llvm_intrinsics)
9+
feature(simd_wasm64, wasm_exception_handling_intrinsics)
1110
)]
1211
#![allow(internal_features)]
1312

library/unwind/src/wasm.rs

+10-14
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,25 @@ pub unsafe fn _Unwind_DeleteException(exception: *mut _Unwind_Exception) {
4040
}
4141

4242
pub unsafe fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code {
43-
#[cfg(panic = "unwind")]
44-
extern "C" {
45-
/// LLVM lowers this intrinsic to the `throw` instruction.
46-
// FIXME(coolreader18): move to stdarch
47-
#[link_name = "llvm.wasm.throw"]
48-
fn wasm_throw(tag: i32, ptr: *mut u8) -> !;
49-
}
50-
5143
// The wasm `throw` instruction takes a "tag", which differentiates certain
5244
// types of exceptions from others. LLVM currently just identifies these
5345
// via integers, with 0 corresponding to C++ exceptions and 1 to C setjmp()/longjmp().
5446
// Ideally, we'd be able to choose something unique for Rust, but for now,
5547
// we pretend to be C++ and implement the Itanium exception-handling ABI.
5648
cfg_if::cfg_if! {
57-
// for now, unless we're -Zbuild-std with panic=unwind, never codegen a throw.
49+
// panic=abort is default for wasm targets. Because an unknown instruction is a load-time
50+
// error on wasm, instead of a runtime error like on traditional architectures, we never
51+
// want to codegen a `throw` instruction, as that would break users using runtimes that
52+
// don't yet support exceptions. The only time this first branch would be selected is if
53+
// the user explicitly opts in to wasm exceptions, via -Zbuild-std with -Cpanic=unwind.
5854
if #[cfg(panic = "unwind")] {
59-
wasm_throw(0, exception.cast())
55+
// corresponds with llvm::WebAssembly::Tag::CPP_EXCEPTION
56+
// in llvm-project/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h
57+
const CPP_EXCEPTION_TAG: i32 = 0;
58+
core::arch::wasm::throw::<CPP_EXCEPTION_TAG>(exception.cast())
6059
} else {
6160
let _ = exception;
62-
#[cfg(target_arch = "wasm32")]
63-
core::arch::wasm32::unreachable();
64-
#[cfg(target_arch = "wasm64")]
65-
core::arch::wasm64::unreachable();
61+
core::arch::wasm::unreachable()
6662
}
6763
}
6864
}

src/bootstrap/src/core/build_steps/llvm.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,9 @@ fn supported_sanitizers(
12281228
"aarch64-unknown-linux-ohos" => {
12291229
common_libs("linux", "aarch64", &["asan", "lsan", "msan", "tsan", "hwasan"])
12301230
}
1231+
"loongarch64-unknown-linux-gnu" | "loongarch64-unknown-linux-musl" => {
1232+
common_libs("linux", "loongarch64", &["asan", "lsan", "msan", "tsan"])
1233+
}
12311234
"x86_64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]),
12321235
"x86_64-unknown-fuchsia" => common_libs("fuchsia", "x86_64", &["asan"]),
12331236
"x86_64-apple-ios" => darwin_libs("iossim", &["asan", "tsan"]),

src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ ENV RUST_CONFIGURE_ARGS \
4747
--enable-extended \
4848
--enable-full-tools \
4949
--enable-profiler \
50+
--enable-sanitizers \
5051
--disable-docs
5152

5253
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $TARGETS

src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ ENV RUST_CONFIGURE_ARGS \
2929
--enable-extended \
3030
--enable-full-tools \
3131
--enable-profiler \
32+
--enable-sanitizers \
3233
--disable-docs \
3334
--set target.loongarch64-unknown-linux-musl.crt-static=false \
3435
--musl-root-loongarch64=/x-tools/loongarch64-unknown-linux-musl/loongarch64-unknown-linux-musl/sysroot/usr
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# In CI environments, bootstrap is forced to use the remote upstream based
3+
# on "git_repository" and "nightly_branch" values from src/stage0 file.
4+
# This script configures the remote as it may not exist by default.
5+
6+
set -euo pipefail
7+
IFS=$'\n\t'
8+
9+
ci_dir=$(cd $(dirname $0) && pwd)/..
10+
source "$ci_dir/shared.sh"
11+
12+
git_repository=$(parse_stage0_file_by_key "git_repository")
13+
nightly_branch=$(parse_stage0_file_by_key "nightly_branch")
14+
15+
# Configure "rust-lang/rust" upstream remote only when it's not origin.
16+
if [ -z "$(git config remote.origin.url | grep $git_repository)" ]; then
17+
echo "Configuring https://github.com/$git_repository remote as upstream."
18+
git remote add upstream "https://github.com/$git_repository"
19+
REMOTE_NAME="upstream"
20+
else
21+
REMOTE_NAME="origin"
22+
fi
23+
24+
git fetch $REMOTE_NAME $nightly_branch

src/ci/shared.sh

+12
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,15 @@ function releaseChannel {
136136
echo $RUST_CI_OVERRIDE_RELEASE_CHANNEL
137137
fi
138138
}
139+
140+
# Parse values from src/stage0 file by key
141+
function parse_stage0_file_by_key {
142+
local key="$1"
143+
local file="$ci_dir/../stage0"
144+
local value=$(awk -F= '{a[$1]=$2} END {print(a["'$key'"])}' $file)
145+
if [ -z "$value" ]; then
146+
echo "ERROR: Key '$key' not found in '$file'."
147+
exit 1
148+
fi
149+
echo "$value"
150+
}

0 commit comments

Comments
 (0)