Skip to content

Commit

Permalink
Auto merge of rust-lang#137900 - matthiaskrgr:rollup-rvan5ao, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#137375 (Minor internal comments fix for `BufRead::read_line`)
 - rust-lang#137641 (More precisely document `Global::deallocate()`'s safety.)
 - rust-lang#137755 (doc: update Wasmtime flags)
 - rust-lang#137851 (improve `simd_select` error message when used with invalid mask type)
 - rust-lang#137860 (rustc_target: Add msync target feature and enable it on powerpcspe targets)
 - rust-lang#137871 (fix `RangeBounds::is_empty` documentation)
 - rust-lang#137873 (Disable `f16` on Aarch64 without `neon`)
 - rust-lang#137876 (Adjust triagebot.toml entries for `rustc_mir_build/src/builder/`)
 - rust-lang#137883 (edit mailmap)
 - rust-lang#137886 (`name()` and `trimmed_name()` for `stable_mir::crate_def::DefId`)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Mar 3, 2025
2 parents daf5985 + 59fe0c7 commit 81d8edc
Show file tree
Hide file tree
Showing 20 changed files with 158 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ James Hinshelwood <jameshinshelwood1@gmail.com> <james.hinshelwood@bigpayme.com>
James Miller <bladeon@gmail.com> <james@aatch.net>
James Perry <james.austin.perry@gmail.com>
James Sanderson <zofrex@gmail.com>
Jana Dönszelmann <jana@donsz.nl>
Jana Dönszelmann <jana@donsz.nl> <jonathan@donsz.nl>
Jana Dönszelmann <jana@donsz.nl> <jonabent@gmail.com>
Jan-Erik Rediger <janerik@fnordig.de> <badboy@archlinux.us>
Jaro Fietz <jaro.fietz@gmx.de>
Jason Fager <jfager@gmail.com>
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_ssa/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ codegen_ssa_invalid_monomorphization_inserted_type = invalid monomorphization of
codegen_ssa_invalid_monomorphization_invalid_bitmask = invalid monomorphization of `{$name}` intrinsic: invalid bitmask `{$mask_ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`
codegen_ssa_invalid_monomorphization_mask_type = invalid monomorphization of `{$name}` intrinsic: mask element type is `{$ty}`, expected `i_`
codegen_ssa_invalid_monomorphization_mask_type = invalid monomorphization of `{$name}` intrinsic: found mask element type is `{$ty}`, expected a signed integer type
.note = the mask may be widened, which only has the correct behavior for signed integers
codegen_ssa_invalid_monomorphization_mismatched_lengths = invalid monomorphization of `{$name}` intrinsic: mismatched lengths: mask length `{$m_len}` != other vector length `{$v_len}`
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,7 @@ pub enum InvalidMonomorphization<'tcx> {
},

#[diag(codegen_ssa_invalid_monomorphization_mask_type, code = E0511)]
#[note]
MaskType {
#[primary_span]
span: Span,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
abi: "spe".into(),
endian: Endian::Big,
features: "+secure-plt".into(),
features: "+secure-plt,+msync".into(),
mcount: "_mcount".into(),
..base
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
abi: "spe".into(),
endian: Endian::Big,
features: "+msync".into(),
mcount: "_mcount".into(),
..base
},
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
static POWERPC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start
("altivec", Unstable(sym::powerpc_target_feature), &[]),
("msync", Unstable(sym::powerpc_target_feature), &[]),
("partword-atomics", Unstable(sym::powerpc_target_feature), &[]),
("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]),
Expand Down
38 changes: 26 additions & 12 deletions compiler/stable_mir/src/crate_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@ use crate::{Crate, Symbol, with};
#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize)]
pub struct DefId(pub(crate) usize);

impl DefId {
/// Return fully qualified name of this definition
pub fn name(&self) -> Symbol {
with(|cx| cx.def_name(*self, false))
}

/// Return a trimmed name of this definition.
///
/// This can be used to print more user friendly diagnostic messages.
///
/// If a symbol name can only be imported from one place for a type, and as
/// long as it was not glob-imported anywhere in the current crate, we trim its
/// path and print only the name.
///
/// For example, this function may shorten `std::vec::Vec` to just `Vec`,
/// as long as there is no other `Vec` importable anywhere.
pub fn trimmed_name(&self) -> Symbol {
with(|cx| cx.def_name(*self, true))
}
}

/// A trait for retrieving information about a particular definition.
///
/// Implementors must provide the implementation of `def_id` which will be used to retrieve
Expand All @@ -19,24 +40,17 @@ pub trait CrateDef {
fn def_id(&self) -> DefId;

/// Return the fully qualified name of the current definition.
///
/// See [`DefId::name`] for more details
fn name(&self) -> Symbol {
let def_id = self.def_id();
with(|cx| cx.def_name(def_id, false))
self.def_id().name()
}

/// Return a trimmed name of this definition.
///
/// This can be used to print more user friendly diagnostic messages.
///
/// If a symbol name can only be imported from one place for a type, and as
/// long as it was not glob-imported anywhere in the current crate, we trim its
/// path and print only the name.
///
/// For example, this function may shorten `std::vec::Vec` to just `Vec`,
/// as long as there is no other `Vec` importable anywhere.
/// See [`DefId::trimmed_name`] for more details
fn trimmed_name(&self) -> Symbol {
let def_id = self.def_id();
with(|cx| cx.def_name(def_id, true))
self.def_id().trimmed_name()
}

/// Return information about the crate where this definition is declared.
Expand Down
5 changes: 1 addition & 4 deletions compiler/stable_mir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ pub type CrateNum = usize;

impl Debug for DefId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DefId")
.field("id", &self.0)
.field("name", &with(|cx| cx.def_name(*self, false)))
.finish()
f.debug_struct("DefId").field("id", &self.0).field("name", &self.name()).finish()
}
}

Expand Down
10 changes: 8 additions & 2 deletions library/alloc/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,14 @@ unsafe impl Allocator for Global {
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
if layout.size() != 0 {
// SAFETY: `layout` is non-zero in size,
// other conditions must be upheld by the caller
// SAFETY:
// * We have checked that `layout` is non-zero in size.
// * The caller is obligated to provide a layout that "fits", and in this case,
// "fit" always means a layout that is equal to the original, because our
// `allocate()`, `grow()`, and `shrink()` implementations never returns a larger
// allocation than requested.
// * Other conditions must be upheld by the caller, as per `Allocator::deallocate()`'s
// safety documentation.
unsafe { dealloc(ptr.as_ptr(), layout) }
}
}
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ops/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ pub trait RangeBounds<T: ?Sized> {
}

/// Returns `true` if the range contains no items.
/// One-sided ranges (`RangeFrom`, etc) always return `true`.
/// One-sided ranges (`RangeFrom`, etc) always return `false`.
///
/// # Examples
///
Expand Down
7 changes: 7 additions & 0 deletions library/std/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ fn main() {
.expect("CARGO_CFG_TARGET_POINTER_WIDTH was not set")
.parse()
.unwrap();
let target_features: Vec<_> = env::var("CARGO_CFG_TARGET_FEATURE")
.unwrap_or_default()
.split(",")
.map(ToOwned::to_owned)
.collect();
let is_miri = env::var_os("CARGO_CFG_MIRI").is_some();

println!("cargo:rustc-check-cfg=cfg(netbsd10)");
Expand Down Expand Up @@ -101,6 +106,8 @@ fn main() {
("s390x", _) => false,
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
("arm64ec", _) => false,
// LLVM crash <https://github.com/llvm/llvm-project/issues/129394>
("aarch64", _) if !target_features.iter().any(|f| f == "neon") => false,
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2534,7 +2534,7 @@ pub trait BufRead: Read {
fn read_line(&mut self, buf: &mut String) -> Result<usize> {
// Note that we are not calling the `.read_until` method here, but
// rather our hardcoded implementation. For more details as to why, see
// the comments in `read_to_end`.
// the comments in `default_read_to_string`.
unsafe { append_to_string(buf, |b| read_until(self, b'\n', b)) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ This target is not a stable target. This means that there are a few engines
which implement the `wasi-threads` feature and if they do they're likely behind a
flag, for example:

* Wasmtime - `--wasm-features=threads --wasi-modules=experimental-wasi-threads`
* Wasmtime - `--wasi threads`
* [WAMR](https://github.com/bytecodealliance/wasm-micro-runtime) - needs to be built with WAMR_BUILD_LIB_WASI_THREADS=1

## Building the target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ which implement the `memory64` feature and if they do they're likely behind a
flag, for example:

* Nodejs - `--experimental-wasm-memory64`
* Wasmtime - `--wasm-features memory64`
* Wasmtime - `--wasm memory64`

Also note that at this time the `wasm64-unknown-unknown` target assumes the
presence of other merged wasm proposals such as (with their LLVM feature flags):
Expand Down
1 change: 1 addition & 0 deletions tests/ui/check-cfg/target_feature.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`mp`
`mp1e2`
`msa`
`msync`
`mte`
`multivalue`
`mutable-globals`
Expand Down
52 changes: 52 additions & 0 deletions tests/ui/simd/intrinsic/generic-gather.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//@ build-fail
//@ ignore-emscripten

// Test that the simd_{gather,scatter} intrinsics produce ok-ish error
// messages when misused.

#![feature(repr_simd, core_intrinsics)]
#![allow(non_camel_case_types)]

use std::intrinsics::simd::{simd_gather, simd_scatter};

#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
struct x4<T>(pub [T; 4]);

fn main() {
let mut x = [0_f32, 1., 2., 3., 4., 5., 6., 7.];

let default = x4([-3_f32, -3., -3., -3.]);
let s_strided = x4([0_f32, 2., -3., 6.]);

let mask = x4([-1_i32, -1, 0, -1]);
let umask = x4([0u16; 4]);
let fmask = x4([0_f32; 4]);

let pointer = x.as_mut_ptr();
let pointers =
unsafe { x4([pointer.offset(0), pointer.offset(2), pointer.offset(4), pointer.offset(6)]) };

unsafe {
simd_gather(default, mask, mask);
//~^ ERROR expected element type `i32` of second argument `x4<i32>` to be a pointer to the element type `f32`

simd_gather(default, pointers, umask);
//~^ ERROR expected element type `u16` of third argument `x4<u16>` to be a signed integer type

simd_gather(default, pointers, fmask);
//~^ ERROR expected element type `f32` of third argument `x4<f32>` to be a signed integer type
}

unsafe {
let values = x4([42_f32, 43_f32, 44_f32, 45_f32]);
simd_scatter(values, mask, mask);
//~^ ERROR expected element type `i32` of second argument `x4<i32>` to be a pointer to the element type `f32` of the first argument `x4<f32>`, found `i32` != `*mut f32`

simd_scatter(values, pointers, umask);
//~^ ERROR expected element type `u16` of third argument `x4<u16>` to be a signed integer type

simd_scatter(values, pointers, fmask);
//~^ ERROR expected element type `f32` of third argument `x4<f32>` to be a signed integer type
}
}
39 changes: 39 additions & 0 deletions tests/ui/simd/intrinsic/generic-gather.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
error[E0511]: invalid monomorphization of `simd_gather` intrinsic: expected element type `i32` of second argument `x4<i32>` to be a pointer to the element type `f32` of the first argument `x4<f32>`, found `i32` != `*_ f32`
--> $DIR/generic-gather.rs:31:9
|
LL | simd_gather(default, mask, mask);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_gather` intrinsic: expected element type `u16` of third argument `x4<u16>` to be a signed integer type
--> $DIR/generic-gather.rs:34:9
|
LL | simd_gather(default, pointers, umask);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_gather` intrinsic: expected element type `f32` of third argument `x4<f32>` to be a signed integer type
--> $DIR/generic-gather.rs:37:9
|
LL | simd_gather(default, pointers, fmask);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_scatter` intrinsic: expected element type `i32` of second argument `x4<i32>` to be a pointer to the element type `f32` of the first argument `x4<f32>`, found `i32` != `*mut f32`
--> $DIR/generic-gather.rs:43:9
|
LL | simd_scatter(values, mask, mask);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_scatter` intrinsic: expected element type `u16` of third argument `x4<u16>` to be a signed integer type
--> $DIR/generic-gather.rs:46:9
|
LL | simd_scatter(values, pointers, umask);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_scatter` intrinsic: expected element type `f32` of third argument `x4<f32>` to be a signed integer type
--> $DIR/generic-gather.rs:49:9
|
LL | simd_scatter(values, pointers, fmask);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0511`.
4 changes: 2 additions & 2 deletions tests/ui/simd/intrinsic/generic-select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ fn main() {
//~^ ERROR mismatched lengths: mask length `8` != other vector length `4`

simd_select(x, x, x);
//~^ ERROR mask element type is `u32`, expected `i_`
//~^ ERROR mask element type is `u32`, expected a signed integer type

simd_select(z, z, z);
//~^ ERROR mask element type is `f32`, expected `i_`
//~^ ERROR mask element type is `f32`, expected a signed integer type

simd_select(m4, 0u32, 1u32);
//~^ ERROR found non-SIMD `u32`
Expand Down
8 changes: 6 additions & 2 deletions tests/ui/simd/intrinsic/generic-select.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ error[E0511]: invalid monomorphization of `simd_select` intrinsic: mismatched le
LL | simd_select(m8, x, x);
| ^^^^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `u32`, expected `i_`
error[E0511]: invalid monomorphization of `simd_select` intrinsic: found mask element type is `u32`, expected a signed integer type
--> $DIR/generic-select.rs:39:9
|
LL | simd_select(x, x, x);
| ^^^^^^^^^^^^^^^^^^^^
|
= note: the mask may be widened, which only has the correct behavior for signed integers

error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `f32`, expected `i_`
error[E0511]: invalid monomorphization of `simd_select` intrinsic: found mask element type is `f32`, expected a signed integer type
--> $DIR/generic-select.rs:42:9
|
LL | simd_select(z, z, z);
| ^^^^^^^^^^^^^^^^^^^^
|
= note: the mask may be widened, which only has the correct behavior for signed integers

error[E0511]: invalid monomorphization of `simd_select` intrinsic: expected SIMD argument type, found non-SIMD `u32`
--> $DIR/generic-select.rs:45:9
Expand Down
6 changes: 3 additions & 3 deletions triagebot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ cc = ["@fmease"]
message = "Some changes occurred in diagnostic error codes"
cc = ["@GuillaumeGomez"]

[mentions."compiler/rustc_mir_build/src/build/matches"]
[mentions."compiler/rustc_mir_build/src/builder/matches"]
message = "Some changes occurred in match lowering"
cc = ["@Nadrieril"]

Expand Down Expand Up @@ -1035,7 +1035,7 @@ cc = ["@rust-lang/project-exploit-mitigations", "@rcvalle"]
message = "Some changes occurred in coverage instrumentation."
cc = ["@Zalathar"]

[mentions."compiler/rustc_mir_build/src/build/coverageinfo.rs"]
[mentions."compiler/rustc_mir_build/src/builder/coverageinfo.rs"]
message = "Some changes occurred in coverage instrumentation."
cc = ["@Zalathar"]

Expand Down Expand Up @@ -1264,7 +1264,7 @@ project-exploit-mitigations = [
"/compiler/rustc_middle/src/ty" = ["compiler", "types"]
"/compiler/rustc_const_eval/src/interpret" = ["compiler", "mir"]
"/compiler/rustc_const_eval/src/transform" = ["compiler", "mir-opt"]
"/compiler/rustc_mir_build/src/build" = ["compiler", "mir"]
"/compiler/rustc_mir_build/src/builder" = ["compiler", "mir"]
"/compiler/rustc_mir_transform" = ["compiler", "mir", "mir-opt"]
"/compiler/rustc_smir" = ["project-stable-mir"]
"/compiler/rustc_parse" = ["compiler", "parser"]
Expand Down

0 comments on commit 81d8edc

Please sign in to comment.