Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #103188

Merged
merged 12 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}
InlineAsmOperand::Sym { ref sym } => {
if !self.tcx.features().asm_sym {
feature_err(
&sess.parse_sess,
sym::asm_sym,
*op_sp,
"sym operands for inline assembly are unstable",
)
.emit();
}

let static_def_id = self
.resolver
.get_partial_res(sym.id)
Expand Down
9 changes: 6 additions & 3 deletions compiler/rustc_codegen_gcc/tests/run/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
// Run-time:
// status: 0

#![feature(asm_const, asm_sym)]
#![feature(asm_const)]

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

global_asm!("
global_asm!(
"
.global add_asm
add_asm:
mov rax, rdi
Expand Down Expand Up @@ -132,7 +133,9 @@ fn main() {
assert_eq!(x, 43);

// check sym fn
extern "C" fn foo() -> u64 { 42 }
extern "C" fn foo() -> u64 {
42
}
let x: u64;
unsafe {
asm!("call {}", sym foo, lateout("rax") x);
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ declare_features! (
(accepted, abi_sysv64, "1.24.0", Some(36167), None),
/// Allows using ADX intrinsics from `core::arch::{x86, x86_64}`.
(accepted, adx_target_feature, "1.61.0", Some(44839), None),
/// Allows using `sym` operands in inline assembly.
(accepted, asm_sym, "CURRENT_RUSTC_VERSION", Some(93333), None),
/// Allows the definition of associated constants in `trait` or `impl` blocks.
(accepted, associated_consts, "1.20.0", Some(29646), None),
/// Allows using associated `type`s in `trait`s.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ declare_features! (
(active, asm_const, "1.58.0", Some(93332), None),
/// Enables experimental inline assembly support for additional architectures.
(active, asm_experimental_arch, "1.58.0", Some(93335), None),
/// Allows using `sym` operands in inline assembly.
(active, asm_sym, "1.58.0", Some(93333), None),
/// Allows the `may_unwind` option in inline assembly.
(active, asm_unwind, "1.58.0", Some(93334), None),
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ symbols! {
call_once,
caller_location,
capture_disjoint_fields,
cause,
cdylib,
ceilf32,
ceilf64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
flags.push((sym::from_desugaring, Some(format!("{:?}", k))));
}

if let ObligationCauseCode::MainFunctionType = obligation.cause.code() {
flags.push((sym::cause, Some("MainFunctionType".to_string())));
}

// Add all types without trimmed paths.
ty::print::with_no_trimmed_paths!({
let generics = self.tcx.generics_of(def_id);
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@
#![feature(iter_advance_by)]
#![feature(iter_next_chunk)]
#![feature(layout_for_ptr)]
#![feature(maybe_uninit_array_assume_init)]
#![feature(maybe_uninit_slice)]
#![feature(maybe_uninit_uninit_array)]
#![feature(maybe_uninit_uninit_array_transpose)]
#![cfg_attr(test, feature(new_uninit))]
#![feature(nonnull_slice_from_raw_parts)]
#![feature(pattern)]
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/vec/into_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {

self.ptr = self.ptr.wrapping_byte_add(N);
// Safety: ditto
return Ok(unsafe { MaybeUninit::array_assume_init(raw_ary) });
return Ok(unsafe { raw_ary.transpose().assume_init() });
}

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

Expand Down
5 changes: 2 additions & 3 deletions library/core/src/array/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ impl<T, const N: usize> IntoIter<T, N> {
///
/// ```
/// #![feature(array_into_iter_constructors)]
///
/// #![feature(maybe_uninit_array_assume_init)]
/// #![feature(maybe_uninit_uninit_array_transpose)]
/// #![feature(maybe_uninit_uninit_array)]
/// use std::array::IntoIter;
/// use std::mem::MaybeUninit;
Expand Down Expand Up @@ -134,7 +133,7 @@ impl<T, const N: usize> IntoIter<T, N> {
/// }
///
/// // SAFETY: We've initialized all N items
/// unsafe { Ok(MaybeUninit::array_assume_init(buffer)) }
/// unsafe { Ok(buffer.transpose().assume_init()) }
/// }
///
/// let r: [_; 4] = next_chunk(&mut (10..16)).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ where

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

Expand Down
2 changes: 1 addition & 1 deletion library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ macro_rules! int_impl {
// Deal with the final bit of the exponent separately, since
// squaring the base afterwards is not necessary and may cause a
// needless overflow.
Some(try_opt!(acc.checked_mul(base)))
acc.checked_mul(base)
}

/// Saturating integer addition. Computes `self + rhs`, saturating at the numeric
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ macro_rules! uint_impl {
// squaring the base afterwards is not necessary and may cause a
// needless overflow.

Some(try_opt!(acc.checked_mul(base)))
acc.checked_mul(base)
}

/// Saturating integer addition. Computes `self + rhs`, saturating at
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ pub unsafe trait Searcher<'a> {
/// The index ranges returned by this trait are not required
/// to exactly match those of the forward search in reverse.
///
/// For the reason why this trait is marked unsafe, see them
/// For the reason why this trait is marked unsafe, see the
/// parent trait [`Searcher`].
pub unsafe trait ReverseSearcher<'a>: Searcher<'a> {
/// Performs the next search step starting from the back.
Expand Down
2 changes: 1 addition & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
#![feature(slice_from_ptr_range)]
#![feature(split_as_slice)]
#![feature(maybe_uninit_uninit_array)]
#![feature(maybe_uninit_array_assume_init)]
#![feature(maybe_uninit_write_slice)]
#![feature(maybe_uninit_uninit_array_transpose)]
#![feature(min_specialization)]
#![feature(numfmt)]
#![feature(step_trait)]
Expand Down
6 changes: 3 additions & 3 deletions library/core/tests/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,18 @@ fn assume_init_good() {

#[test]
fn uninit_array_assume_init() {
let mut array: [MaybeUninit<i16>; 5] = MaybeUninit::uninit_array();
let mut array = [MaybeUninit::<i16>::uninit(); 5];
array[0].write(3);
array[1].write(1);
array[2].write(4);
array[3].write(1);
array[4].write(5);

let array = unsafe { MaybeUninit::array_assume_init(array) };
let array = unsafe { array.transpose().assume_init() };

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

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

#[test]
Expand Down
12 changes: 10 additions & 2 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2154,8 +2154,16 @@ pub fn id() -> u32 {
#[cfg_attr(not(test), lang = "termination")]
#[stable(feature = "termination_trait_lib", since = "1.61.0")]
#[rustc_on_unimplemented(
message = "`main` has invalid return type `{Self}`",
label = "`main` can only return types that implement `{Termination}`"
on(
all(not(bootstrap), cause = "MainFunctionType"),
message = "`main` has invalid return type `{Self}`",
label = "`main` can only return types that implement `{Termination}`"
),
on(
bootstrap,
message = "`main` has invalid return type `{Self}`",
label = "`main` can only return types that implement `{Termination}`"
)
)]
pub trait Termination {
/// Is called to get the representation of the value as status code.
Expand Down
13 changes: 0 additions & 13 deletions src/doc/unstable-book/src/language-features/asm-sym.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/assembly/asm/aarch64-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target aarch64-unknown-linux-gnu
// needs-llvm-components: aarch64

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/arm-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// compile-flags: -C target-feature=+neon
// needs-llvm-components: arm

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/avr-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target avr-unknown-gnu-atmega328
// needs-llvm-components: avr

#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/bpf-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target bpfel-unknown-none -C target_feature=+alu32
// needs-llvm-components: bpf

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
6 changes: 4 additions & 2 deletions src/test/assembly/asm/global_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
// compile-flags: -C symbol-mangling-version=v0

#![feature(asm_const, asm_sym)]
#![feature(asm_const)]
#![crate_type = "rlib"]

use std::arch::global_asm;
Expand All @@ -28,4 +28,6 @@ global_asm!("lea rax, [rip + {}]", sym MY_STATIC);
// CHECK: call _RNvCsiubXh4Yz005_10global_asm6foobar
global_asm!("call {}", sym foobar);
// CHECK: _RNvCsiubXh4Yz005_10global_asm6foobar:
fn foobar() { loop {} }
fn foobar() {
loop {}
}
2 changes: 1 addition & 1 deletion src/test/assembly/asm/hexagon-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target hexagon-unknown-linux-musl
// needs-llvm-components: hexagon

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/mips-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64
//[mips64] needs-llvm-components: mips

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/msp430-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target msp430-none-elf
// needs-llvm-components: msp430

#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch, asm_const)]
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch, asm_const)]
#![crate_type = "rlib"]
#![no_core]
#![allow(non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/nvptx-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// compile-flags: --crate-type cdylib
// needs-llvm-components: nvptx

#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
#![no_core]

#[rustc_builtin_macro]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/powerpc-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
//[powerpc64] needs-llvm-components: powerpc

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/riscv-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//[riscv32] needs-llvm-components: riscv
// compile-flags: -C target-feature=+d

#![feature(no_core, lang_items, rustc_attrs, asm_sym)]
#![feature(no_core, lang_items, rustc_attrs)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/s390x-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//[s390x] compile-flags: --target s390x-unknown-linux-gnu
//[s390x] needs-llvm-components: systemz

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/wasm-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// compile-flags: --crate-type cdylib
// needs-llvm-components: webassembly

#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
#![no_core]

#[rustc_builtin_macro]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/x86-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
// compile-flags: -C target-feature=+avx512bw

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
Loading