Skip to content

Commit 328779c

Browse files
committed
Auto merge of #148692 - matthiaskrgr:rollup-hryk71f, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #145656 (Stabilize s390x `vector` target feature and `is_s390x_feature_detected!` macro) - #147024 (std_detect: Support run-time detection on OpenBSD using elf_aux_info) - #147534 (Implement SIMD funnel shifts in const-eval/Miri) - #147540 (Stabilise `as_array` in `[_]` and `*const [_]`; stabilise `as_mut_array` in `[_]` and `*mut [_]`.) - #147686 (update isolate_highest_one for NonZero<T>) - #148230 (rustdoc: Properly highlight shebang, frontmatter & weak keywords in source code pages and code blocks) - #148555 (Fix rust-by-example spanish translation) - #148556 (Fix suggestion for returning async closures) - #148585 ([rustdoc] Replace `print` methods with functions to improve code readability) - #148600 (re-use `self.get_all_attrs` result for pass indirectly attribute) r? `@ghost` `@rustbot` modify labels: rollup
2 parents fb23dd3 + bbd3ab8 commit 328779c

File tree

57 files changed

+1362
-911
lines changed

Some content is hidden

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

57 files changed

+1362
-911
lines changed

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
//! This API is completely unstable and subject to change.
66
77
// tidy-alphabetical-start
8+
#![cfg_attr(bootstrap, feature(slice_as_array))]
89
#![feature(assert_matches)]
910
#![feature(extern_types)]
1011
#![feature(file_buffered)]
1112
#![feature(if_let_guard)]
1213
#![feature(impl_trait_in_assoc_type)]
1314
#![feature(iter_intersperse)]
1415
#![feature(macro_derive)]
15-
#![feature(slice_as_array)]
1616
#![feature(trim_prefix_suffix)]
1717
#![feature(try_blocks)]
1818
// tidy-alphabetical-end

compiler/rustc_const_eval/src/interpret/intrinsics/simd.rs

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_abi::{BackendRepr, Endian};
33
use rustc_apfloat::ieee::{Double, Half, Quad, Single};
44
use rustc_apfloat::{Float, Round};
55
use rustc_middle::mir::interpret::{InterpErrorKind, Pointer, UndefinedBehaviorInfo};
6-
use rustc_middle::ty::{FloatTy, SimdAlign};
6+
use rustc_middle::ty::{FloatTy, ScalarInt, SimdAlign};
77
use rustc_middle::{bug, err_ub_format, mir, span_bug, throw_unsup_format, ty};
88
use rustc_span::{Symbol, sym};
99
use tracing::trace;
@@ -744,6 +744,58 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
744744
self.write_scalar(val, &dest)?;
745745
}
746746
}
747+
sym::simd_funnel_shl | sym::simd_funnel_shr => {
748+
let (left, _) = self.project_to_simd(&args[0])?;
749+
let (right, _) = self.project_to_simd(&args[1])?;
750+
let (shift, _) = self.project_to_simd(&args[2])?;
751+
let (dest, _) = self.project_to_simd(&dest)?;
752+
753+
let (len, elem_ty) = args[0].layout.ty.simd_size_and_type(*self.tcx);
754+
let (elem_size, _signed) = elem_ty.int_size_and_signed(*self.tcx);
755+
let elem_size_bits = u128::from(elem_size.bits());
756+
757+
let is_left = intrinsic_name == sym::simd_funnel_shl;
758+
759+
for i in 0..len {
760+
let left =
761+
self.read_scalar(&self.project_index(&left, i)?)?.to_bits(elem_size)?;
762+
let right =
763+
self.read_scalar(&self.project_index(&right, i)?)?.to_bits(elem_size)?;
764+
let shift_bits =
765+
self.read_scalar(&self.project_index(&shift, i)?)?.to_bits(elem_size)?;
766+
767+
if shift_bits >= elem_size_bits {
768+
throw_ub_format!(
769+
"overflowing shift by {shift_bits} in `{intrinsic_name}` in lane {i}"
770+
);
771+
}
772+
let inv_shift_bits = u32::try_from(elem_size_bits - shift_bits).unwrap();
773+
774+
// A funnel shift left by S can be implemented as `(x << S) | y.unbounded_shr(SIZE - S)`.
775+
// The `unbounded_shr` is needed because otherwise if `S = 0`, it would be `x | y`
776+
// when it should be `x`.
777+
//
778+
// This selects the least-significant `SIZE - S` bits of `x`, followed by the `S` most
779+
// significant bits of `y`. As `left` and `right` both occupy the lower `SIZE` bits,
780+
// we can treat the lower `SIZE` bits as an integer of the right width and use
781+
// the same implementation, but on a zero-extended `x` and `y`. This works because
782+
// `x << S` just pushes the `SIZE-S` MSBs out, and `y >> (SIZE - S)` shifts in
783+
// zeros, as it is zero-extended. To the lower `SIZE` bits, this looks just like a
784+
// funnel shift left.
785+
//
786+
// Note that the `unbounded_sh{l,r}`s are needed only in case we are using this on
787+
// `u128xN` and `inv_shift_bits == 128`.
788+
let result_bits = if is_left {
789+
(left << shift_bits) | right.unbounded_shr(inv_shift_bits)
790+
} else {
791+
left.unbounded_shl(inv_shift_bits) | (right >> shift_bits)
792+
};
793+
let (result, _overflow) = ScalarInt::truncate_from_uint(result_bits, elem_size);
794+
795+
let dest = self.project_index(&dest, i)?;
796+
self.write_scalar(result, &dest)?;
797+
}
798+
}
747799

748800
// Unsupported intrinsic: skip the return_to_block below.
749801
_ => return interp_ok(false),

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ declare_features! (
387387
(accepted, return_position_impl_trait_in_trait, "1.75.0", Some(91611)),
388388
/// Allows code like `let x: &'static u32 = &42` to work (RFC 1414).
389389
(accepted, rvalue_static_promotion, "1.21.0", Some(38865)),
390+
/// Allows use of the `vector` and related s390x target features.
391+
(accepted, s390x_target_feature_vector, "CURRENT_RUSTC_VERSION", Some(145649)),
390392
/// Allows `Self` in type definitions (RFC 2300).
391393
(accepted, self_in_typedefs, "1.32.0", Some(49303)),
392394
/// Allows `Self` struct constructor (RFC 2302).

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,21 @@ pub fn suggest_impl_trait<'tcx>(
12631263
infcx.tcx.lang_items().future_output(),
12641264
format_as_assoc,
12651265
),
1266+
(
1267+
infcx.tcx.lang_items().async_fn_trait(),
1268+
infcx.tcx.lang_items().async_fn_once_output(),
1269+
format_as_parenthesized,
1270+
),
1271+
(
1272+
infcx.tcx.lang_items().async_fn_mut_trait(),
1273+
infcx.tcx.lang_items().async_fn_once_output(),
1274+
format_as_parenthesized,
1275+
),
1276+
(
1277+
infcx.tcx.lang_items().async_fn_once_trait(),
1278+
infcx.tcx.lang_items().async_fn_once_output(),
1279+
format_as_parenthesized,
1280+
),
12661281
(
12671282
infcx.tcx.lang_items().fn_trait(),
12681283
infcx.tcx.lang_items().fn_once_output(),

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,9 +1512,8 @@ impl<'tcx> TyCtxt<'tcx> {
15121512
field_shuffle_seed ^= user_seed;
15131513
}
15141514

1515-
if let Some(reprs) =
1516-
find_attr!(self.get_all_attrs(did), AttributeKind::Repr { reprs, .. } => reprs)
1517-
{
1515+
let attributes = self.get_all_attrs(did);
1516+
if let Some(reprs) = find_attr!(attributes, AttributeKind::Repr { reprs, .. } => reprs) {
15181517
for (r, _) in reprs {
15191518
flags.insert(match *r {
15201519
attr::ReprRust => ReprFlags::empty(),
@@ -1574,10 +1573,7 @@ impl<'tcx> TyCtxt<'tcx> {
15741573
}
15751574

15761575
// See `TyAndLayout::pass_indirectly_in_non_rustic_abis` for details.
1577-
if find_attr!(
1578-
self.get_all_attrs(did),
1579-
AttributeKind::RustcPassIndirectlyInNonRusticAbis(..)
1580-
) {
1576+
if find_attr!(attributes, AttributeKind::RustcPassIndirectlyInNonRusticAbis(..)) {
15811577
flags.insert(ReprFlags::PASS_INDIRECTLY_IN_NON_RUSTIC_ABIS);
15821578
}
15831579

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,6 +2006,7 @@ symbols! {
20062006
s,
20072007
s390x,
20082008
s390x_target_feature,
2009+
s390x_target_feature_vector,
20092010
safety,
20102011
sanitize,
20112012
sanitizer_cfi_generalize_pointers,

compiler/rustc_target/src/target_features.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -844,20 +844,20 @@ const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
844844
("message-security-assist-extension8", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3"]),
845845
("message-security-assist-extension9", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3", "message-security-assist-extension4"]),
846846
("message-security-assist-extension12", Unstable(sym::s390x_target_feature), &[]),
847-
("miscellaneous-extensions-2", Unstable(sym::s390x_target_feature), &[]),
848-
("miscellaneous-extensions-3", Unstable(sym::s390x_target_feature), &[]),
849-
("miscellaneous-extensions-4", Unstable(sym::s390x_target_feature), &[]),
850-
("nnp-assist", Unstable(sym::s390x_target_feature), &["vector"]),
847+
("miscellaneous-extensions-2", Stable, &[]),
848+
("miscellaneous-extensions-3", Stable, &[]),
849+
("miscellaneous-extensions-4", Stable, &[]),
850+
("nnp-assist", Stable, &["vector"]),
851851
("soft-float", Forbidden { reason: "currently unsupported ABI-configuration feature" }, &[]),
852852
("transactional-execution", Unstable(sym::s390x_target_feature), &[]),
853-
("vector", Unstable(sym::s390x_target_feature), &[]),
854-
("vector-enhancements-1", Unstable(sym::s390x_target_feature), &["vector"]),
855-
("vector-enhancements-2", Unstable(sym::s390x_target_feature), &["vector-enhancements-1"]),
856-
("vector-enhancements-3", Unstable(sym::s390x_target_feature), &["vector-enhancements-2"]),
857-
("vector-packed-decimal", Unstable(sym::s390x_target_feature), &["vector"]),
858-
("vector-packed-decimal-enhancement", Unstable(sym::s390x_target_feature), &["vector-packed-decimal"]),
859-
("vector-packed-decimal-enhancement-2", Unstable(sym::s390x_target_feature), &["vector-packed-decimal-enhancement"]),
860-
("vector-packed-decimal-enhancement-3", Unstable(sym::s390x_target_feature), &["vector-packed-decimal-enhancement-2"]),
853+
("vector", Stable, &[]),
854+
("vector-enhancements-1", Stable, &["vector"]),
855+
("vector-enhancements-2", Stable, &["vector-enhancements-1"]),
856+
("vector-enhancements-3", Stable, &["vector-enhancements-2"]),
857+
("vector-packed-decimal", Stable, &["vector"]),
858+
("vector-packed-decimal-enhancement", Stable, &["vector-packed-decimal"]),
859+
("vector-packed-decimal-enhancement-2", Stable, &["vector-packed-decimal-enhancement"]),
860+
("vector-packed-decimal-enhancement-3", Stable, &["vector-packed-decimal-enhancement-2"]),
861861
// tidy-alphabetical-end
862862
];
863863

library/alloc/src/boxed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ impl<T> Box<[T]> {
850850
/// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type.
851851
///
852852
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
853-
#[unstable(feature = "slice_as_array", issue = "133508")]
853+
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
854854
#[inline]
855855
#[must_use]
856856
pub fn into_array<const N: usize>(self) -> Option<Box<[T; N]>> {

library/alloc/src/rc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ impl<T> Rc<[T]> {
11661166
/// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type.
11671167
///
11681168
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
1169-
#[unstable(feature = "slice_as_array", issue = "133508")]
1169+
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
11701170
#[inline]
11711171
#[must_use]
11721172
pub fn into_array<const N: usize>(self) -> Option<Rc<[T; N]>> {

library/alloc/src/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ impl<T> Arc<[T]> {
13141314
/// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type.
13151315
///
13161316
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
1317-
#[unstable(feature = "slice_as_array", issue = "133508")]
1317+
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
13181318
#[inline]
13191319
#[must_use]
13201320
pub fn into_array<const N: usize>(self) -> Option<Arc<[T; N]>> {

0 commit comments

Comments
 (0)