Skip to content

Commit 82a8cf2

Browse files
committed
Auto merge of #152934 - matthiaskrgr:rollup-lcy7ROk, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #152929 (Tighten the `!range` bounds on alignments in vtables) - #151603 (Stabilize `str_as_str`) - #152878 (Remove two more flaky assertions from `oneshot` tests) - #152915 (Error on attempt to construct scalable vector type) - #152925 (Improve runtest revision redundant cfg check) - #152928 (Update wasm-component-ld)
2 parents 99246f4 + cc0b9d5 commit 82a8cf2

File tree

20 files changed

+128
-54
lines changed

20 files changed

+128
-54
lines changed

Cargo.lock

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,6 @@ dependencies = [
16651665
"allocator-api2",
16661666
"equivalent",
16671667
"foldhash 0.1.5",
1668-
"serde",
16691668
]
16701669

16711670
[[package]]
@@ -1675,6 +1674,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
16751674
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
16761675
dependencies = [
16771676
"foldhash 0.2.0",
1677+
"serde",
1678+
"serde_core",
16781679
]
16791680

16801681
[[package]]
@@ -1898,9 +1899,9 @@ dependencies = [
18981899

18991900
[[package]]
19001901
name = "id-arena"
1901-
version = "2.2.1"
1902+
version = "2.3.0"
19021903
source = "registry+https://github.com/rust-lang/crates.io-index"
1903-
checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
1904+
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
19041905

19051906
[[package]]
19061907
name = "ident_case"
@@ -6152,9 +6153,9 @@ dependencies = [
61526153

61536154
[[package]]
61546155
name = "wasm-component-ld"
6155-
version = "0.5.20"
6156+
version = "0.5.21"
61566157
source = "registry+https://github.com/rust-lang/crates.io-index"
6157-
checksum = "846d20ed66ae37b7a237e36dfcd2fdc979eae82a46cdb0586f9bba80782fd789"
6158+
checksum = "59dcd765f510df84d1677a502c49057761486597a95950b4c92153e5707af091"
61586159
dependencies = [
61596160
"anyhow",
61606161
"clap",
@@ -6163,7 +6164,7 @@ dependencies = [
61636164
"libc",
61646165
"tempfile",
61656166
"wasi-preview1-component-adapter-provider",
6166-
"wasmparser 0.243.0",
6167+
"wasmparser 0.245.1",
61676168
"wat",
61686169
"windows-sys 0.61.2",
61696170
"winsplit",
@@ -6190,24 +6191,24 @@ dependencies = [
61906191

61916192
[[package]]
61926193
name = "wasm-encoder"
6193-
version = "0.243.0"
6194+
version = "0.245.1"
61946195
source = "registry+https://github.com/rust-lang/crates.io-index"
6195-
checksum = "c55db9c896d70bd9fa535ce83cd4e1f2ec3726b0edd2142079f594fc3be1cb35"
6196+
checksum = "3f9dca005e69bf015e45577e415b9af8c67e8ee3c0e38b5b0add5aa92581ed5c"
61966197
dependencies = [
61976198
"leb128fmt",
6198-
"wasmparser 0.243.0",
6199+
"wasmparser 0.245.1",
61996200
]
62006201

62016202
[[package]]
62026203
name = "wasm-metadata"
6203-
version = "0.243.0"
6204+
version = "0.245.1"
62046205
source = "registry+https://github.com/rust-lang/crates.io-index"
6205-
checksum = "eae05bf9579f45a62e8d0a4e3f52eaa8da518883ac5afa482ec8256c329ecd56"
6206+
checksum = "da55e60097e8b37b475a0fa35c3420dd71d9eb7bd66109978ab55faf56a57efb"
62066207
dependencies = [
62076208
"anyhow",
62086209
"indexmap",
6209-
"wasm-encoder 0.243.0",
6210-
"wasmparser 0.243.0",
6210+
"wasm-encoder 0.245.1",
6211+
"wasmparser 0.245.1",
62116212
]
62126213

62136214
[[package]]
@@ -6232,35 +6233,35 @@ dependencies = [
62326233

62336234
[[package]]
62346235
name = "wasmparser"
6235-
version = "0.243.0"
6236+
version = "0.245.1"
62366237
source = "registry+https://github.com/rust-lang/crates.io-index"
6237-
checksum = "f6d8db401b0528ec316dfbe579e6ab4152d61739cfe076706d2009127970159d"
6238+
checksum = "4f08c9adee0428b7bddf3890fc27e015ac4b761cc608c822667102b8bfd6995e"
62386239
dependencies = [
62396240
"bitflags",
6240-
"hashbrown 0.15.5",
6241+
"hashbrown 0.16.1",
62416242
"indexmap",
62426243
"semver",
62436244
"serde",
62446245
]
62456246

62466247
[[package]]
62476248
name = "wast"
6248-
version = "243.0.0"
6249+
version = "245.0.1"
62496250
source = "registry+https://github.com/rust-lang/crates.io-index"
6250-
checksum = "df21d01c2d91e46cb7a221d79e58a2d210ea02020d57c092e79255cc2999ca7f"
6251+
checksum = "28cf1149285569120b8ce39db8b465e8a2b55c34cbb586bd977e43e2bc7300bf"
62516252
dependencies = [
62526253
"bumpalo",
62536254
"leb128fmt",
62546255
"memchr",
62556256
"unicode-width 0.2.2",
6256-
"wasm-encoder 0.243.0",
6257+
"wasm-encoder 0.245.1",
62576258
]
62586259

62596260
[[package]]
62606261
name = "wat"
6261-
version = "1.243.0"
6262+
version = "1.245.1"
62626263
source = "registry+https://github.com/rust-lang/crates.io-index"
6263-
checksum = "226a9a91cd80a50449312fef0c75c23478fcecfcc4092bdebe1dc8e760ef521b"
6264+
checksum = "cd48d1679b6858988cb96b154dda0ec5bbb09275b71db46057be37332d5477be"
62646265
dependencies = [
62656266
"wast",
62666267
]
@@ -6707,9 +6708,9 @@ dependencies = [
67076708

67086709
[[package]]
67096710
name = "wit-component"
6710-
version = "0.243.0"
6711+
version = "0.245.1"
67116712
source = "registry+https://github.com/rust-lang/crates.io-index"
6712-
checksum = "36f9fc53513e461ce51dcf17a3e331752cb829f1d187069e54af5608fc998fe4"
6713+
checksum = "4894f10d2d5cbc17c77e91f86a1e48e191a788da4425293b55c98b44ba3fcac9"
67136714
dependencies = [
67146715
"anyhow",
67156716
"bitflags",
@@ -6718,19 +6719,20 @@ dependencies = [
67186719
"serde",
67196720
"serde_derive",
67206721
"serde_json",
6721-
"wasm-encoder 0.243.0",
6722+
"wasm-encoder 0.245.1",
67226723
"wasm-metadata",
6723-
"wasmparser 0.243.0",
6724+
"wasmparser 0.245.1",
67246725
"wit-parser",
67256726
]
67266727

67276728
[[package]]
67286729
name = "wit-parser"
6729-
version = "0.243.0"
6730+
version = "0.245.1"
67306731
source = "registry+https://github.com/rust-lang/crates.io-index"
6731-
checksum = "df983a8608e513d8997f435bb74207bf0933d0e49ca97aa9d8a6157164b9b7fc"
6732+
checksum = "330698718e82983499419494dd1e3d7811a457a9bf9f69734e8c5f07a2547929"
67326733
dependencies = [
67336734
"anyhow",
6735+
"hashbrown 0.16.1",
67346736
"id-arena",
67356737
"indexmap",
67366738
"log",
@@ -6739,7 +6741,7 @@ dependencies = [
67396741
"serde_derive",
67406742
"serde_json",
67416743
"unicode-xid",
6742-
"wasmparser 0.243.0",
6744+
"wasmparser 0.245.1",
67436745
]
67446746

67456747
[[package]]

compiler/rustc_abi/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,19 @@ impl Align {
10361036
// LLVM has a maximal supported alignment of 2^29, we inherit that.
10371037
pub const MAX: Align = Align { pow2: 29 };
10381038

1039+
/// Either `1 << (pointer_bits - 1)` or [`Align::MAX`], whichever is smaller.
1040+
#[inline]
1041+
pub fn max_for_target(tdl: &TargetDataLayout) -> Align {
1042+
let pointer_bits = tdl.pointer_size().bits();
1043+
if let Ok(pointer_bits) = u8::try_from(pointer_bits)
1044+
&& pointer_bits <= Align::MAX.pow2
1045+
{
1046+
Align { pow2: pointer_bits - 1 }
1047+
} else {
1048+
Align::MAX
1049+
}
1050+
}
1051+
10391052
#[inline]
10401053
pub fn from_bits(bits: u64) -> Result<Align, AlignFromBytesError> {
10411054
Align::from_bytes(Size::from_bits(bits).bytes())

compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_abi::WrappingRange;
1+
use rustc_abi::{Align, WrappingRange};
22
use rustc_middle::mir::SourceInfo;
33
use rustc_middle::ty::{self, Ty, TyCtxt};
44
use rustc_middle::{bug, span_bug};
@@ -179,9 +179,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
179179
let size_bound = bx.data_layout().ptr_sized_integer().signed_max() as u128;
180180
bx.range_metadata(value, WrappingRange { start: 0, end: size_bound });
181181
}
182-
// Alignment is always nonzero.
182+
// Alignment is always a power of two, thus 1..=0x800…000,
183+
// but also bounded by the maximum we support in type layout.
183184
sym::vtable_align => {
184-
bx.range_metadata(value, WrappingRange { start: 1, end: !0 })
185+
let align_bound = Align::max_for_target(bx.data_layout()).bytes().into();
186+
bx.range_metadata(value, WrappingRange { start: 1, end: align_bound })
185187
}
186188
_ => {}
187189
}

compiler/rustc_codegen_ssa/src/size_of_val.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Computing the size and alignment of a value.
22
3-
use rustc_abi::WrappingRange;
3+
use rustc_abi::{Align, WrappingRange};
44
use rustc_hir::LangItem;
55
use rustc_middle::bug;
66
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
@@ -36,8 +36,10 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
3636
// Size is always <= isize::MAX.
3737
let size_bound = bx.data_layout().ptr_sized_integer().signed_max() as u128;
3838
bx.range_metadata(size, WrappingRange { start: 0, end: size_bound });
39-
// Alignment is always nonzero.
40-
bx.range_metadata(align, WrappingRange { start: 1, end: !0 });
39+
// Alignment is always a power of two, thus 1..=0x800…000,
40+
// but also bounded by the maximum we support in type layout.
41+
let align_bound = Align::max_for_target(bx.data_layout()).bytes().into();
42+
bx.range_metadata(align, WrappingRange { start: 1, end: align_bound });
4143

4244
(size, align)
4345
}

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
9898
_ => { /* cannot have a non-rust abi */ }
9999
}
100100

101+
if self.is_scalable_vector_ctor(autoderef.final_ty()) {
102+
let mut err = self.dcx().create_err(errors::ScalableVectorCtor {
103+
span: callee_expr.span,
104+
ty: autoderef.final_ty(),
105+
});
106+
err.span_label(callee_expr.span, "you can create scalable vectors using intrinsics");
107+
Ty::new_error(self.tcx, err.emit());
108+
}
109+
101110
self.register_predicates(autoderef.into_obligations());
102111

103112
let output = match result {
@@ -420,6 +429,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
420429
None
421430
}
422431

432+
fn is_scalable_vector_ctor(&self, callee_ty: Ty<'_>) -> bool {
433+
if let ty::FnDef(def_id, _) = callee_ty.kind()
434+
&& let def::DefKind::Ctor(def::CtorOf::Struct, _) = self.tcx.def_kind(def_id)
435+
{
436+
self.tcx
437+
.opt_parent(*def_id)
438+
.and_then(|id| self.tcx.adt_def(id).repr().scalable)
439+
.is_some()
440+
} else {
441+
false
442+
}
443+
}
444+
423445
/// Give appropriate suggestion when encountering `||{/* not callable */}()`, where the
424446
/// likely intention is to call the closure, suggest `(||{})()`. (#55851)
425447
fn identify_bad_closure_def_and_call(

compiler/rustc_hir_typeck/src/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,14 @@ pub(crate) struct InvalidCallee<'tcx> {
569569
pub found: String,
570570
}
571571

572+
#[derive(Diagnostic)]
573+
#[diag("scalable vector types cannot be initialised using their constructor")]
574+
pub(crate) struct ScalableVectorCtor<'tcx> {
575+
#[primary_span]
576+
pub span: Span,
577+
pub ty: Ty<'tcx>,
578+
}
579+
572580
#[derive(Diagnostic)]
573581
#[diag("cannot cast `{$expr_ty}` to a pointer that {$known_wide ->
574582
[true] is

library/alloctests/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#![feature(thin_box)]
3434
#![feature(drain_keep_rest)]
3535
#![feature(local_waker)]
36-
#![feature(str_as_str)]
3736
#![feature(strict_provenance_lints)]
3837
#![feature(string_replace_in_place)]
3938
#![feature(vec_deque_truncate_front)]

library/core/src/bstr/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ impl ByteStr {
7474
/// it helps dereferencing other "container" types,
7575
/// for example `Box<ByteStr>` or `Arc<ByteStr>`.
7676
#[inline]
77-
// #[unstable(feature = "str_as_str", issue = "130366")]
7877
#[unstable(feature = "bstr", issue = "134915")]
7978
pub const fn as_byte_str(&self) -> &ByteStr {
8079
self
@@ -86,7 +85,6 @@ impl ByteStr {
8685
/// it helps dereferencing other "container" types,
8786
/// for example `Box<ByteStr>` or `MutexGuard<ByteStr>`.
8887
#[inline]
89-
// #[unstable(feature = "str_as_str", issue = "130366")]
9088
#[unstable(feature = "bstr", issue = "134915")]
9189
pub const fn as_mut_byte_str(&mut self) -> &mut ByteStr {
9290
self

library/core/src/ffi/c_str.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,8 @@ impl CStr {
655655
/// it helps dereferencing other string-like types to string slices,
656656
/// for example references to `Box<CStr>` or `Arc<CStr>`.
657657
#[inline]
658-
#[unstable(feature = "str_as_str", issue = "130366")]
658+
#[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
659+
#[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
659660
pub const fn as_c_str(&self) -> &CStr {
660661
self
661662
}

library/core/src/slice/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5337,7 +5337,8 @@ impl<T> [T] {
53375337
/// it helps dereferencing other "container" types to slices,
53385338
/// for example `Box<[T]>` or `Arc<[T]>`.
53395339
#[inline]
5340-
#[unstable(feature = "str_as_str", issue = "130366")]
5340+
#[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
5341+
#[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
53415342
pub const fn as_slice(&self) -> &[T] {
53425343
self
53435344
}
@@ -5348,7 +5349,8 @@ impl<T> [T] {
53485349
/// it helps dereferencing other "container" types to slices,
53495350
/// for example `Box<[T]>` or `MutexGuard<[T]>`.
53505351
#[inline]
5351-
#[unstable(feature = "str_as_str", issue = "130366")]
5352+
#[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
5353+
#[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
53525354
pub const fn as_mut_slice(&mut self) -> &mut [T] {
53535355
self
53545356
}

0 commit comments

Comments
 (0)