Skip to content

Commit e94827e

Browse files
committed
Auto merge of #103188 - JohnTitor:rollup-pwilam1, r=JohnTitor
Rollup of 6 pull requests Successful merges: - #103023 (Adding `fuchsia-ignore` and `needs-unwind` to compiler test cases) - #103142 (Make diagnostic for unsatisfied `Termination` bounds more precise) - #103154 (Fix typo in `ReverseSearcher` docs) - #103159 (Remove the redundant `Some(try_opt!(..))` in `checked_pow`) - #103163 (Remove all uses of array_assume_init) - #103168 (Stabilize asm_sym) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 21b2465 + 6e7d206 commit e94827e

Some content is hidden

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

65 files changed

+161
-135
lines changed

compiler/rustc_ast_lowering/src/asm.rs

-10
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
192192
}
193193
}
194194
InlineAsmOperand::Sym { ref sym } => {
195-
if !self.tcx.features().asm_sym {
196-
feature_err(
197-
&sess.parse_sess,
198-
sym::asm_sym,
199-
*op_sp,
200-
"sym operands for inline assembly are unstable",
201-
)
202-
.emit();
203-
}
204-
205195
let static_def_id = self
206196
.resolver
207197
.get_partial_res(sym.id)

compiler/rustc_codegen_gcc/tests/run/asm.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
// Run-time:
44
// status: 0
55

6-
#![feature(asm_const, asm_sym)]
6+
#![feature(asm_const)]
77

88
use std::arch::{asm, global_asm};
99

10-
global_asm!("
10+
global_asm!(
11+
"
1112
.global add_asm
1213
add_asm:
1314
mov rax, rdi
@@ -132,7 +133,9 @@ fn main() {
132133
assert_eq!(x, 43);
133134

134135
// check sym fn
135-
extern "C" fn foo() -> u64 { 42 }
136+
extern "C" fn foo() -> u64 {
137+
42
138+
}
136139
let x: u64;
137140
unsafe {
138141
asm!("call {}", sym foo, lateout("rax") x);

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ declare_features! (
5353
(accepted, abi_sysv64, "1.24.0", Some(36167), None),
5454
/// Allows using ADX intrinsics from `core::arch::{x86, x86_64}`.
5555
(accepted, adx_target_feature, "1.61.0", Some(44839), None),
56+
/// Allows using `sym` operands in inline assembly.
57+
(accepted, asm_sym, "CURRENT_RUSTC_VERSION", Some(93333), None),
5658
/// Allows the definition of associated constants in `trait` or `impl` blocks.
5759
(accepted, associated_consts, "1.20.0", Some(29646), None),
5860
/// Allows using associated `type`s in `trait`s.

compiler/rustc_feature/src/active.rs

-2
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,6 @@ declare_features! (
300300
(active, asm_const, "1.58.0", Some(93332), None),
301301
/// Enables experimental inline assembly support for additional architectures.
302302
(active, asm_experimental_arch, "1.58.0", Some(93335), None),
303-
/// Allows using `sym` operands in inline assembly.
304-
(active, asm_sym, "1.58.0", Some(93333), None),
305303
/// Allows the `may_unwind` option in inline assembly.
306304
(active, asm_unwind, "1.58.0", Some(93334), None),
307305
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ symbols! {
451451
call_once,
452452
caller_location,
453453
capture_disjoint_fields,
454+
cause,
454455
cdylib,
455456
ceilf32,
456457
ceilf64,

compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs

+4
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
164164
flags.push((sym::from_desugaring, Some(format!("{:?}", k))));
165165
}
166166

167+
if let ObligationCauseCode::MainFunctionType = obligation.cause.code() {
168+
flags.push((sym::cause, Some("MainFunctionType".to_string())));
169+
}
170+
167171
// Add all types without trimmed paths.
168172
ty::print::with_no_trimmed_paths!({
169173
let generics = self.tcx.generics_of(def_id);

library/alloc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@
125125
#![feature(iter_advance_by)]
126126
#![feature(iter_next_chunk)]
127127
#![feature(layout_for_ptr)]
128-
#![feature(maybe_uninit_array_assume_init)]
129128
#![feature(maybe_uninit_slice)]
130129
#![feature(maybe_uninit_uninit_array)]
130+
#![feature(maybe_uninit_uninit_array_transpose)]
131131
#![cfg_attr(test, feature(new_uninit))]
132132
#![feature(nonnull_slice_from_raw_parts)]
133133
#![feature(pattern)]

library/alloc/src/vec/into_iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
223223

224224
self.ptr = self.ptr.wrapping_byte_add(N);
225225
// Safety: ditto
226-
return Ok(unsafe { MaybeUninit::array_assume_init(raw_ary) });
226+
return Ok(unsafe { raw_ary.transpose().assume_init() });
227227
}
228228

229229
if len < N {
@@ -241,7 +241,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
241241
return unsafe {
242242
ptr::copy_nonoverlapping(self.ptr, raw_ary.as_mut_ptr() as *mut T, N);
243243
self.ptr = self.ptr.add(N);
244-
Ok(MaybeUninit::array_assume_init(raw_ary))
244+
Ok(raw_ary.transpose().assume_init())
245245
};
246246
}
247247

library/core/src/array/iter.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ impl<T, const N: usize> IntoIter<T, N> {
104104
///
105105
/// ```
106106
/// #![feature(array_into_iter_constructors)]
107-
///
108-
/// #![feature(maybe_uninit_array_assume_init)]
107+
/// #![feature(maybe_uninit_uninit_array_transpose)]
109108
/// #![feature(maybe_uninit_uninit_array)]
110109
/// use std::array::IntoIter;
111110
/// use std::mem::MaybeUninit;
@@ -134,7 +133,7 @@ impl<T, const N: usize> IntoIter<T, N> {
134133
/// }
135134
///
136135
/// // SAFETY: We've initialized all N items
137-
/// unsafe { Ok(MaybeUninit::array_assume_init(buffer)) }
136+
/// unsafe { Ok(buffer.transpose().assume_init()) }
138137
/// }
139138
///
140139
/// let r: [_; 4] = next_chunk(&mut (10..16)).unwrap();

library/core/src/array/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ where
912912

913913
mem::forget(guard);
914914
// SAFETY: All elements of the array were populated in the loop above.
915-
let output = unsafe { MaybeUninit::array_assume_init(array) };
915+
let output = unsafe { array.transpose().assume_init() };
916916
Ok(Try::from_output(output))
917917
}
918918

library/core/src/num/int_macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ macro_rules! int_impl {
869869
// Deal with the final bit of the exponent separately, since
870870
// squaring the base afterwards is not necessary and may cause a
871871
// needless overflow.
872-
Some(try_opt!(acc.checked_mul(base)))
872+
acc.checked_mul(base)
873873
}
874874

875875
/// Saturating integer addition. Computes `self + rhs`, saturating at the numeric

library/core/src/num/uint_macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ macro_rules! uint_impl {
990990
// squaring the base afterwards is not necessary and may cause a
991991
// needless overflow.
992992

993-
Some(try_opt!(acc.checked_mul(base)))
993+
acc.checked_mul(base)
994994
}
995995

996996
/// Saturating integer addition. Computes `self + rhs`, saturating at

library/core/src/str/pattern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ pub unsafe trait Searcher<'a> {
267267
/// The index ranges returned by this trait are not required
268268
/// to exactly match those of the forward search in reverse.
269269
///
270-
/// For the reason why this trait is marked unsafe, see them
270+
/// For the reason why this trait is marked unsafe, see the
271271
/// parent trait [`Searcher`].
272272
pub unsafe trait ReverseSearcher<'a>: Searcher<'a> {
273273
/// Performs the next search step starting from the back.

library/core/tests/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
#![feature(slice_from_ptr_range)]
5050
#![feature(split_as_slice)]
5151
#![feature(maybe_uninit_uninit_array)]
52-
#![feature(maybe_uninit_array_assume_init)]
5352
#![feature(maybe_uninit_write_slice)]
53+
#![feature(maybe_uninit_uninit_array_transpose)]
5454
#![feature(min_specialization)]
5555
#![feature(numfmt)]
5656
#![feature(step_trait)]

library/core/tests/mem.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,18 @@ fn assume_init_good() {
163163

164164
#[test]
165165
fn uninit_array_assume_init() {
166-
let mut array: [MaybeUninit<i16>; 5] = MaybeUninit::uninit_array();
166+
let mut array = [MaybeUninit::<i16>::uninit(); 5];
167167
array[0].write(3);
168168
array[1].write(1);
169169
array[2].write(4);
170170
array[3].write(1);
171171
array[4].write(5);
172172

173-
let array = unsafe { MaybeUninit::array_assume_init(array) };
173+
let array = unsafe { array.transpose().assume_init() };
174174

175175
assert_eq!(array, [3, 1, 4, 1, 5]);
176176

177-
let [] = unsafe { MaybeUninit::<!>::array_assume_init([]) };
177+
let [] = unsafe { [MaybeUninit::<!>::uninit(); 0].transpose().assume_init() };
178178
}
179179

180180
#[test]

library/std/src/process.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -2154,8 +2154,16 @@ pub fn id() -> u32 {
21542154
#[cfg_attr(not(test), lang = "termination")]
21552155
#[stable(feature = "termination_trait_lib", since = "1.61.0")]
21562156
#[rustc_on_unimplemented(
2157-
message = "`main` has invalid return type `{Self}`",
2158-
label = "`main` can only return types that implement `{Termination}`"
2157+
on(
2158+
all(not(bootstrap), cause = "MainFunctionType"),
2159+
message = "`main` has invalid return type `{Self}`",
2160+
label = "`main` can only return types that implement `{Termination}`"
2161+
),
2162+
on(
2163+
bootstrap,
2164+
message = "`main` has invalid return type `{Self}`",
2165+
label = "`main` can only return types that implement `{Termination}`"
2166+
)
21592167
)]
21602168
pub trait Termination {
21612169
/// Is called to get the representation of the value as status code.

src/doc/unstable-book/src/language-features/asm-sym.md

-13
This file was deleted.

src/test/assembly/asm/aarch64-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// compile-flags: --target aarch64-unknown-linux-gnu
33
// needs-llvm-components: aarch64
44

5-
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)]
5+
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
66
#![crate_type = "rlib"]
77
#![no_core]
88
#![allow(asm_sub_register, non_camel_case_types)]

src/test/assembly/asm/arm-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// compile-flags: -C target-feature=+neon
44
// needs-llvm-components: arm
55

6-
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)]
6+
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
77
#![crate_type = "rlib"]
88
#![no_core]
99
#![allow(asm_sub_register, non_camel_case_types)]

src/test/assembly/asm/avr-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// compile-flags: --target avr-unknown-gnu-atmega328
33
// needs-llvm-components: avr
44

5-
#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
5+
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
66
#![crate_type = "rlib"]
77
#![no_core]
88
#![allow(non_camel_case_types)]

src/test/assembly/asm/bpf-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// compile-flags: --target bpfel-unknown-none -C target_feature=+alu32
33
// needs-llvm-components: bpf
44

5-
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
5+
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
66
#![crate_type = "rlib"]
77
#![no_core]
88
#![allow(asm_sub_register, non_camel_case_types)]

src/test/assembly/asm/global_asm.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
55
// compile-flags: -C symbol-mangling-version=v0
66

7-
#![feature(asm_const, asm_sym)]
7+
#![feature(asm_const)]
88
#![crate_type = "rlib"]
99

1010
use std::arch::global_asm;
@@ -28,4 +28,6 @@ global_asm!("lea rax, [rip + {}]", sym MY_STATIC);
2828
// CHECK: call _RNvCsiubXh4Yz005_10global_asm6foobar
2929
global_asm!("call {}", sym foobar);
3030
// CHECK: _RNvCsiubXh4Yz005_10global_asm6foobar:
31-
fn foobar() { loop {} }
31+
fn foobar() {
32+
loop {}
33+
}

src/test/assembly/asm/hexagon-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// compile-flags: --target hexagon-unknown-linux-musl
33
// needs-llvm-components: hexagon
44

5-
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
5+
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
66
#![crate_type = "rlib"]
77
#![no_core]
88
#![allow(asm_sub_register, non_camel_case_types)]

src/test/assembly/asm/mips-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64
66
//[mips64] needs-llvm-components: mips
77

8-
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
8+
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
99
#![crate_type = "rlib"]
1010
#![no_core]
1111
#![allow(asm_sub_register, non_camel_case_types)]

src/test/assembly/asm/msp430-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// compile-flags: --target msp430-none-elf
33
// needs-llvm-components: msp430
44

5-
#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch, asm_const)]
5+
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch, asm_const)]
66
#![crate_type = "rlib"]
77
#![no_core]
88
#![allow(non_camel_case_types)]

src/test/assembly/asm/nvptx-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// compile-flags: --crate-type cdylib
44
// needs-llvm-components: nvptx
55

6-
#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
6+
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
77
#![no_core]
88

99
#[rustc_builtin_macro]

src/test/assembly/asm/powerpc-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
66
//[powerpc64] needs-llvm-components: powerpc
77

8-
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
8+
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
99
#![crate_type = "rlib"]
1010
#![no_core]
1111
#![allow(asm_sub_register, non_camel_case_types)]

src/test/assembly/asm/riscv-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//[riscv32] needs-llvm-components: riscv
77
// compile-flags: -C target-feature=+d
88

9-
#![feature(no_core, lang_items, rustc_attrs, asm_sym)]
9+
#![feature(no_core, lang_items, rustc_attrs)]
1010
#![crate_type = "rlib"]
1111
#![no_core]
1212
#![allow(asm_sub_register)]

src/test/assembly/asm/s390x-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//[s390x] compile-flags: --target s390x-unknown-linux-gnu
44
//[s390x] needs-llvm-components: systemz
55

6-
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
6+
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
77
#![crate_type = "rlib"]
88
#![no_core]
99
#![allow(asm_sub_register, non_camel_case_types)]

src/test/assembly/asm/wasm-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// compile-flags: --crate-type cdylib
44
// needs-llvm-components: webassembly
55

6-
#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
6+
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
77
#![no_core]
88

99
#[rustc_builtin_macro]

src/test/assembly/asm/x86-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
88
// compile-flags: -C target-feature=+avx512bw
99

10-
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)]
10+
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
1111
#![crate_type = "rlib"]
1212
#![no_core]
1313
#![allow(asm_sub_register, non_camel_case_types)]

0 commit comments

Comments
 (0)