Skip to content

Commit 81d8edc

Browse files
committed
Auto merge of #137900 - matthiaskrgr:rollup-rvan5ao, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #137375 (Minor internal comments fix for `BufRead::read_line`) - #137641 (More precisely document `Global::deallocate()`'s safety.) - #137755 (doc: update Wasmtime flags) - #137851 (improve `simd_select` error message when used with invalid mask type) - #137860 (rustc_target: Add msync target feature and enable it on powerpcspe targets) - #137871 (fix `RangeBounds::is_empty` documentation) - #137873 (Disable `f16` on Aarch64 without `neon`) - #137876 (Adjust triagebot.toml entries for `rustc_mir_build/src/builder/`) - #137883 (edit mailmap) - #137886 (`name()` and `trimmed_name()` for `stable_mir::crate_def::DefId`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents daf5985 + 59fe0c7 commit 81d8edc

File tree

20 files changed

+158
-31
lines changed

20 files changed

+158
-31
lines changed

.mailmap

+3
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ James Hinshelwood <[email protected]> <[email protected]>
292292
293293
James Perry <[email protected]>
294294
James Sanderson <[email protected]>
295+
Jana Dönszelmann <[email protected]>
296+
297+
295298
296299
Jaro Fietz <[email protected]>
297300
Jason Fager <[email protected]>

compiler/rustc_codegen_ssa/messages.ftl

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ codegen_ssa_invalid_monomorphization_inserted_type = invalid monomorphization of
119119
120120
codegen_ssa_invalid_monomorphization_invalid_bitmask = invalid monomorphization of `{$name}` intrinsic: invalid bitmask `{$mask_ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`
121121
122-
codegen_ssa_invalid_monomorphization_mask_type = invalid monomorphization of `{$name}` intrinsic: mask element type is `{$ty}`, expected `i_`
122+
codegen_ssa_invalid_monomorphization_mask_type = invalid monomorphization of `{$name}` intrinsic: found mask element type is `{$ty}`, expected a signed integer type
123+
.note = the mask may be widened, which only has the correct behavior for signed integers
123124
124125
codegen_ssa_invalid_monomorphization_mismatched_lengths = invalid monomorphization of `{$name}` intrinsic: mismatched lengths: mask length `{$m_len}` != other vector length `{$v_len}`
125126

compiler/rustc_codegen_ssa/src/errors.rs

+1
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,7 @@ pub enum InvalidMonomorphization<'tcx> {
957957
},
958958

959959
#[diag(codegen_ssa_invalid_monomorphization_mask_type, code = E0511)]
960+
#[note]
960961
MaskType {
961962
#[primary_span]
962963
span: Span,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(crate) fn target() -> Target {
2424
options: TargetOptions {
2525
abi: "spe".into(),
2626
endian: Endian::Big,
27-
features: "+secure-plt".into(),
27+
features: "+secure-plt,+msync".into(),
2828
mcount: "_mcount".into(),
2929
..base
3030
},

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

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub(crate) fn target() -> Target {
2626
options: TargetOptions {
2727
abi: "spe".into(),
2828
endian: Endian::Big,
29+
features: "+msync".into(),
2930
mcount: "_mcount".into(),
3031
..base
3132
},

compiler/rustc_target/src/target_features.rs

+1
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
461461
static POWERPC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
462462
// tidy-alphabetical-start
463463
("altivec", Unstable(sym::powerpc_target_feature), &[]),
464+
("msync", Unstable(sym::powerpc_target_feature), &[]),
464465
("partword-atomics", Unstable(sym::powerpc_target_feature), &[]),
465466
("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
466467
("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]),

compiler/stable_mir/src/crate_def.rs

+26-12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@ use crate::{Crate, Symbol, with};
1010
#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize)]
1111
pub struct DefId(pub(crate) usize);
1212

13+
impl DefId {
14+
/// Return fully qualified name of this definition
15+
pub fn name(&self) -> Symbol {
16+
with(|cx| cx.def_name(*self, false))
17+
}
18+
19+
/// Return a trimmed name of this definition.
20+
///
21+
/// This can be used to print more user friendly diagnostic messages.
22+
///
23+
/// If a symbol name can only be imported from one place for a type, and as
24+
/// long as it was not glob-imported anywhere in the current crate, we trim its
25+
/// path and print only the name.
26+
///
27+
/// For example, this function may shorten `std::vec::Vec` to just `Vec`,
28+
/// as long as there is no other `Vec` importable anywhere.
29+
pub fn trimmed_name(&self) -> Symbol {
30+
with(|cx| cx.def_name(*self, true))
31+
}
32+
}
33+
1334
/// A trait for retrieving information about a particular definition.
1435
///
1536
/// Implementors must provide the implementation of `def_id` which will be used to retrieve
@@ -19,24 +40,17 @@ pub trait CrateDef {
1940
fn def_id(&self) -> DefId;
2041

2142
/// Return the fully qualified name of the current definition.
43+
///
44+
/// See [`DefId::name`] for more details
2245
fn name(&self) -> Symbol {
23-
let def_id = self.def_id();
24-
with(|cx| cx.def_name(def_id, false))
46+
self.def_id().name()
2547
}
2648

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

4256
/// Return information about the crate where this definition is declared.

compiler/stable_mir/src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ pub type CrateNum = usize;
4848

4949
impl Debug for DefId {
5050
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
51-
f.debug_struct("DefId")
52-
.field("id", &self.0)
53-
.field("name", &with(|cx| cx.def_name(*self, false)))
54-
.finish()
51+
f.debug_struct("DefId").field("id", &self.0).field("name", &self.name()).finish()
5552
}
5653
}
5754

library/alloc/src/alloc.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,14 @@ unsafe impl Allocator for Global {
264264
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
265265
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
266266
if layout.size() != 0 {
267-
// SAFETY: `layout` is non-zero in size,
268-
// other conditions must be upheld by the caller
267+
// SAFETY:
268+
// * We have checked that `layout` is non-zero in size.
269+
// * The caller is obligated to provide a layout that "fits", and in this case,
270+
// "fit" always means a layout that is equal to the original, because our
271+
// `allocate()`, `grow()`, and `shrink()` implementations never returns a larger
272+
// allocation than requested.
273+
// * Other conditions must be upheld by the caller, as per `Allocator::deallocate()`'s
274+
// safety documentation.
269275
unsafe { dealloc(ptr.as_ptr(), layout) }
270276
}
271277
}

library/core/src/ops/range.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ pub trait RangeBounds<T: ?Sized> {
827827
}
828828

829829
/// Returns `true` if the range contains no items.
830-
/// One-sided ranges (`RangeFrom`, etc) always return `true`.
830+
/// One-sided ranges (`RangeFrom`, etc) always return `false`.
831831
///
832832
/// # Examples
833833
///

library/std/build.rs

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ fn main() {
1212
.expect("CARGO_CFG_TARGET_POINTER_WIDTH was not set")
1313
.parse()
1414
.unwrap();
15+
let target_features: Vec<_> = env::var("CARGO_CFG_TARGET_FEATURE")
16+
.unwrap_or_default()
17+
.split(",")
18+
.map(ToOwned::to_owned)
19+
.collect();
1520
let is_miri = env::var_os("CARGO_CFG_MIRI").is_some();
1621

1722
println!("cargo:rustc-check-cfg=cfg(netbsd10)");
@@ -101,6 +106,8 @@ fn main() {
101106
("s390x", _) => false,
102107
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
103108
("arm64ec", _) => false,
109+
// LLVM crash <https://github.com/llvm/llvm-project/issues/129394>
110+
("aarch64", _) if !target_features.iter().any(|f| f == "neon") => false,
104111
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
105112
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
106113
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>

library/std/src/io/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2534,7 +2534,7 @@ pub trait BufRead: Read {
25342534
fn read_line(&mut self, buf: &mut String) -> Result<usize> {
25352535
// Note that we are not calling the `.read_until` method here, but
25362536
// rather our hardcoded implementation. For more details as to why, see
2537-
// the comments in `read_to_end`.
2537+
// the comments in `default_read_to_string`.
25382538
unsafe { append_to_string(buf, |b| read_until(self, b'\n', b)) }
25392539
}
25402540

src/doc/rustc/src/platform-support/wasm32-wasip1-threads.md

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

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

106106
## Building the target

src/doc/rustc/src/platform-support/wasm64-unknown-unknown.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ which implement the `memory64` feature and if they do they're likely behind a
3636
flag, for example:
3737

3838
* Nodejs - `--experimental-wasm-memory64`
39-
* Wasmtime - `--wasm-features memory64`
39+
* Wasmtime - `--wasm memory64`
4040

4141
Also note that at this time the `wasm64-unknown-unknown` target assumes the
4242
presence of other merged wasm proposals such as (with their LLVM feature flags):

tests/ui/check-cfg/target_feature.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
151151
`mp`
152152
`mp1e2`
153153
`msa`
154+
`msync`
154155
`mte`
155156
`multivalue`
156157
`mutable-globals`
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//@ build-fail
2+
//@ ignore-emscripten
3+
4+
// Test that the simd_{gather,scatter} intrinsics produce ok-ish error
5+
// messages when misused.
6+
7+
#![feature(repr_simd, core_intrinsics)]
8+
#![allow(non_camel_case_types)]
9+
10+
use std::intrinsics::simd::{simd_gather, simd_scatter};
11+
12+
#[repr(simd)]
13+
#[derive(Copy, Clone, PartialEq, Debug)]
14+
struct x4<T>(pub [T; 4]);
15+
16+
fn main() {
17+
let mut x = [0_f32, 1., 2., 3., 4., 5., 6., 7.];
18+
19+
let default = x4([-3_f32, -3., -3., -3.]);
20+
let s_strided = x4([0_f32, 2., -3., 6.]);
21+
22+
let mask = x4([-1_i32, -1, 0, -1]);
23+
let umask = x4([0u16; 4]);
24+
let fmask = x4([0_f32; 4]);
25+
26+
let pointer = x.as_mut_ptr();
27+
let pointers =
28+
unsafe { x4([pointer.offset(0), pointer.offset(2), pointer.offset(4), pointer.offset(6)]) };
29+
30+
unsafe {
31+
simd_gather(default, mask, mask);
32+
//~^ ERROR expected element type `i32` of second argument `x4<i32>` to be a pointer to the element type `f32`
33+
34+
simd_gather(default, pointers, umask);
35+
//~^ ERROR expected element type `u16` of third argument `x4<u16>` to be a signed integer type
36+
37+
simd_gather(default, pointers, fmask);
38+
//~^ ERROR expected element type `f32` of third argument `x4<f32>` to be a signed integer type
39+
}
40+
41+
unsafe {
42+
let values = x4([42_f32, 43_f32, 44_f32, 45_f32]);
43+
simd_scatter(values, mask, mask);
44+
//~^ 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`
45+
46+
simd_scatter(values, pointers, umask);
47+
//~^ ERROR expected element type `u16` of third argument `x4<u16>` to be a signed integer type
48+
49+
simd_scatter(values, pointers, fmask);
50+
//~^ ERROR expected element type `f32` of third argument `x4<f32>` to be a signed integer type
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
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`
2+
--> $DIR/generic-gather.rs:31:9
3+
|
4+
LL | simd_gather(default, mask, mask);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error[E0511]: invalid monomorphization of `simd_gather` intrinsic: expected element type `u16` of third argument `x4<u16>` to be a signed integer type
8+
--> $DIR/generic-gather.rs:34:9
9+
|
10+
LL | simd_gather(default, pointers, umask);
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error[E0511]: invalid monomorphization of `simd_gather` intrinsic: expected element type `f32` of third argument `x4<f32>` to be a signed integer type
14+
--> $DIR/generic-gather.rs:37:9
15+
|
16+
LL | simd_gather(default, pointers, fmask);
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
19+
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`
20+
--> $DIR/generic-gather.rs:43:9
21+
|
22+
LL | simd_scatter(values, mask, mask);
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
25+
error[E0511]: invalid monomorphization of `simd_scatter` intrinsic: expected element type `u16` of third argument `x4<u16>` to be a signed integer type
26+
--> $DIR/generic-gather.rs:46:9
27+
|
28+
LL | simd_scatter(values, pointers, umask);
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30+
31+
error[E0511]: invalid monomorphization of `simd_scatter` intrinsic: expected element type `f32` of third argument `x4<f32>` to be a signed integer type
32+
--> $DIR/generic-gather.rs:49:9
33+
|
34+
LL | simd_scatter(values, pointers, fmask);
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
36+
37+
error: aborting due to 6 previous errors
38+
39+
For more information about this error, try `rustc --explain E0511`.

tests/ui/simd/intrinsic/generic-select.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ fn main() {
3737
//~^ ERROR mismatched lengths: mask length `8` != other vector length `4`
3838

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

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

4545
simd_select(m4, 0u32, 1u32);
4646
//~^ ERROR found non-SIMD `u32`

tests/ui/simd/intrinsic/generic-select.stderr

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@ error[E0511]: invalid monomorphization of `simd_select` intrinsic: mismatched le
44
LL | simd_select(m8, x, x);
55
| ^^^^^^^^^^^^^^^^^^^^^
66

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

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

1923
error[E0511]: invalid monomorphization of `simd_select` intrinsic: expected SIMD argument type, found non-SIMD `u32`
2024
--> $DIR/generic-select.rs:45:9

triagebot.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ cc = ["@fmease"]
775775
message = "Some changes occurred in diagnostic error codes"
776776
cc = ["@GuillaumeGomez"]
777777

778-
[mentions."compiler/rustc_mir_build/src/build/matches"]
778+
[mentions."compiler/rustc_mir_build/src/builder/matches"]
779779
message = "Some changes occurred in match lowering"
780780
cc = ["@Nadrieril"]
781781

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

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

@@ -1264,7 +1264,7 @@ project-exploit-mitigations = [
12641264
"/compiler/rustc_middle/src/ty" = ["compiler", "types"]
12651265
"/compiler/rustc_const_eval/src/interpret" = ["compiler", "mir"]
12661266
"/compiler/rustc_const_eval/src/transform" = ["compiler", "mir-opt"]
1267-
"/compiler/rustc_mir_build/src/build" = ["compiler", "mir"]
1267+
"/compiler/rustc_mir_build/src/builder" = ["compiler", "mir"]
12681268
"/compiler/rustc_mir_transform" = ["compiler", "mir", "mir-opt"]
12691269
"/compiler/rustc_smir" = ["project-stable-mir"]
12701270
"/compiler/rustc_parse" = ["compiler", "parser"]

0 commit comments

Comments
 (0)