Skip to content
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
58 changes: 30 additions & 28 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,6 @@ dependencies = [
"allocator-api2",
"equivalent",
"foldhash 0.1.5",
"serde",
]

[[package]]
Expand All @@ -1675,6 +1674,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
dependencies = [
"foldhash 0.2.0",
"serde",
"serde_core",
]

[[package]]
Expand Down Expand Up @@ -1898,9 +1899,9 @@ dependencies = [

[[package]]
name = "id-arena"
version = "2.2.1"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"

[[package]]
name = "ident_case"
Expand Down Expand Up @@ -6152,9 +6153,9 @@ dependencies = [

[[package]]
name = "wasm-component-ld"
version = "0.5.20"
version = "0.5.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "846d20ed66ae37b7a237e36dfcd2fdc979eae82a46cdb0586f9bba80782fd789"
checksum = "59dcd765f510df84d1677a502c49057761486597a95950b4c92153e5707af091"
dependencies = [
"anyhow",
"clap",
Expand All @@ -6163,7 +6164,7 @@ dependencies = [
"libc",
"tempfile",
"wasi-preview1-component-adapter-provider",
"wasmparser 0.243.0",
"wasmparser 0.245.1",
"wat",
"windows-sys 0.61.2",
"winsplit",
Expand All @@ -6190,24 +6191,24 @@ dependencies = [

[[package]]
name = "wasm-encoder"
version = "0.243.0"
version = "0.245.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c55db9c896d70bd9fa535ce83cd4e1f2ec3726b0edd2142079f594fc3be1cb35"
checksum = "3f9dca005e69bf015e45577e415b9af8c67e8ee3c0e38b5b0add5aa92581ed5c"
dependencies = [
"leb128fmt",
"wasmparser 0.243.0",
"wasmparser 0.245.1",
]

[[package]]
name = "wasm-metadata"
version = "0.243.0"
version = "0.245.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eae05bf9579f45a62e8d0a4e3f52eaa8da518883ac5afa482ec8256c329ecd56"
checksum = "da55e60097e8b37b475a0fa35c3420dd71d9eb7bd66109978ab55faf56a57efb"
dependencies = [
"anyhow",
"indexmap",
"wasm-encoder 0.243.0",
"wasmparser 0.243.0",
"wasm-encoder 0.245.1",
"wasmparser 0.245.1",
]

[[package]]
Expand All @@ -6232,35 +6233,35 @@ dependencies = [

[[package]]
name = "wasmparser"
version = "0.243.0"
version = "0.245.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6d8db401b0528ec316dfbe579e6ab4152d61739cfe076706d2009127970159d"
checksum = "4f08c9adee0428b7bddf3890fc27e015ac4b761cc608c822667102b8bfd6995e"
dependencies = [
"bitflags",
"hashbrown 0.15.5",
"hashbrown 0.16.1",
"indexmap",
"semver",
"serde",
]

[[package]]
name = "wast"
version = "243.0.0"
version = "245.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df21d01c2d91e46cb7a221d79e58a2d210ea02020d57c092e79255cc2999ca7f"
checksum = "28cf1149285569120b8ce39db8b465e8a2b55c34cbb586bd977e43e2bc7300bf"
dependencies = [
"bumpalo",
"leb128fmt",
"memchr",
"unicode-width 0.2.2",
"wasm-encoder 0.243.0",
"wasm-encoder 0.245.1",
]

[[package]]
name = "wat"
version = "1.243.0"
version = "1.245.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "226a9a91cd80a50449312fef0c75c23478fcecfcc4092bdebe1dc8e760ef521b"
checksum = "cd48d1679b6858988cb96b154dda0ec5bbb09275b71db46057be37332d5477be"
dependencies = [
"wast",
]
Expand Down Expand Up @@ -6707,9 +6708,9 @@ dependencies = [

[[package]]
name = "wit-component"
version = "0.243.0"
version = "0.245.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36f9fc53513e461ce51dcf17a3e331752cb829f1d187069e54af5608fc998fe4"
checksum = "4894f10d2d5cbc17c77e91f86a1e48e191a788da4425293b55c98b44ba3fcac9"
dependencies = [
"anyhow",
"bitflags",
Expand All @@ -6718,19 +6719,20 @@ dependencies = [
"serde",
"serde_derive",
"serde_json",
"wasm-encoder 0.243.0",
"wasm-encoder 0.245.1",
"wasm-metadata",
"wasmparser 0.243.0",
"wasmparser 0.245.1",
"wit-parser",
]

[[package]]
name = "wit-parser"
version = "0.243.0"
version = "0.245.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df983a8608e513d8997f435bb74207bf0933d0e49ca97aa9d8a6157164b9b7fc"
checksum = "330698718e82983499419494dd1e3d7811a457a9bf9f69734e8c5f07a2547929"
dependencies = [
"anyhow",
"hashbrown 0.16.1",
"id-arena",
"indexmap",
"log",
Expand All @@ -6739,7 +6741,7 @@ dependencies = [
"serde_derive",
"serde_json",
"unicode-xid",
"wasmparser 0.243.0",
"wasmparser 0.245.1",
]

[[package]]
Expand Down
13 changes: 13 additions & 0 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,19 @@ impl Align {
// LLVM has a maximal supported alignment of 2^29, we inherit that.
pub const MAX: Align = Align { pow2: 29 };

/// Either `1 << (pointer_bits - 1)` or [`Align::MAX`], whichever is smaller.
#[inline]
pub fn max_for_target(tdl: &TargetDataLayout) -> Align {
let pointer_bits = tdl.pointer_size().bits();
if let Ok(pointer_bits) = u8::try_from(pointer_bits)
&& pointer_bits <= Align::MAX.pow2
{
Align { pow2: pointer_bits - 1 }
} else {
Align::MAX
}
}

#[inline]
pub fn from_bits(bits: u64) -> Result<Align, AlignFromBytesError> {
Align::from_bytes(Size::from_bits(bits).bytes())
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_abi::WrappingRange;
use rustc_abi::{Align, WrappingRange};
use rustc_middle::mir::SourceInfo;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::{bug, span_bug};
Expand Down Expand Up @@ -179,9 +179,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let size_bound = bx.data_layout().ptr_sized_integer().signed_max() as u128;
bx.range_metadata(value, WrappingRange { start: 0, end: size_bound });
}
// Alignment is always nonzero.
// Alignment is always a power of two, thus 1..=0x800…000,
// but also bounded by the maximum we support in type layout.
sym::vtable_align => {
bx.range_metadata(value, WrappingRange { start: 1, end: !0 })
let align_bound = Align::max_for_target(bx.data_layout()).bytes().into();
bx.range_metadata(value, WrappingRange { start: 1, end: align_bound })
}
_ => {}
}
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_codegen_ssa/src/size_of_val.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Computing the size and alignment of a value.

use rustc_abi::WrappingRange;
use rustc_abi::{Align, WrappingRange};
use rustc_hir::LangItem;
use rustc_middle::bug;
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
Expand Down Expand Up @@ -36,8 +36,10 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
// Size is always <= isize::MAX.
let size_bound = bx.data_layout().ptr_sized_integer().signed_max() as u128;
bx.range_metadata(size, WrappingRange { start: 0, end: size_bound });
// Alignment is always nonzero.
bx.range_metadata(align, WrappingRange { start: 1, end: !0 });
// Alignment is always a power of two, thus 1..=0x800…000,
// but also bounded by the maximum we support in type layout.
let align_bound = Align::max_for_target(bx.data_layout()).bytes().into();
bx.range_metadata(align, WrappingRange { start: 1, end: align_bound });

(size, align)
}
Expand Down
22 changes: 22 additions & 0 deletions compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => { /* cannot have a non-rust abi */ }
}

if self.is_scalable_vector_ctor(autoderef.final_ty()) {
let mut err = self.dcx().create_err(errors::ScalableVectorCtor {
span: callee_expr.span,
ty: autoderef.final_ty(),
});
err.span_label(callee_expr.span, "you can create scalable vectors using intrinsics");
Ty::new_error(self.tcx, err.emit());
}

self.register_predicates(autoderef.into_obligations());

let output = match result {
Expand Down Expand Up @@ -420,6 +429,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
None
}

fn is_scalable_vector_ctor(&self, callee_ty: Ty<'_>) -> bool {
if let ty::FnDef(def_id, _) = callee_ty.kind()
&& let def::DefKind::Ctor(def::CtorOf::Struct, _) = self.tcx.def_kind(def_id)
{
self.tcx
.opt_parent(*def_id)
.and_then(|id| self.tcx.adt_def(id).repr().scalable)
.is_some()
} else {
false
}
}

/// Give appropriate suggestion when encountering `||{/* not callable */}()`, where the
/// likely intention is to call the closure, suggest `(||{})()`. (#55851)
fn identify_bad_closure_def_and_call(
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_hir_typeck/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,14 @@ pub(crate) struct InvalidCallee<'tcx> {
pub found: String,
}

#[derive(Diagnostic)]
#[diag("scalable vector types cannot be initialised using their constructor")]
pub(crate) struct ScalableVectorCtor<'tcx> {
#[primary_span]
pub span: Span,
pub ty: Ty<'tcx>,
}

#[derive(Diagnostic)]
#[diag("cannot cast `{$expr_ty}` to a pointer that {$known_wide ->
[true] is
Expand Down
1 change: 0 additions & 1 deletion library/alloctests/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#![feature(thin_box)]
#![feature(drain_keep_rest)]
#![feature(local_waker)]
#![feature(str_as_str)]
#![feature(strict_provenance_lints)]
#![feature(string_replace_in_place)]
#![feature(vec_deque_truncate_front)]
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/bstr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ impl ByteStr {
/// it helps dereferencing other "container" types,
/// for example `Box<ByteStr>` or `Arc<ByteStr>`.
#[inline]
// #[unstable(feature = "str_as_str", issue = "130366")]
#[unstable(feature = "bstr", issue = "134915")]
pub const fn as_byte_str(&self) -> &ByteStr {
self
Expand All @@ -86,7 +85,6 @@ impl ByteStr {
/// it helps dereferencing other "container" types,
/// for example `Box<ByteStr>` or `MutexGuard<ByteStr>`.
#[inline]
// #[unstable(feature = "str_as_str", issue = "130366")]
#[unstable(feature = "bstr", issue = "134915")]
pub const fn as_mut_byte_str(&mut self) -> &mut ByteStr {
self
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,8 @@ impl CStr {
/// it helps dereferencing other string-like types to string slices,
/// for example references to `Box<CStr>` or `Arc<CStr>`.
#[inline]
#[unstable(feature = "str_as_str", issue = "130366")]
#[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_c_str(&self) -> &CStr {
self
}
Expand Down
6 changes: 4 additions & 2 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5337,7 +5337,8 @@ impl<T> [T] {
/// it helps dereferencing other "container" types to slices,
/// for example `Box<[T]>` or `Arc<[T]>`.
#[inline]
#[unstable(feature = "str_as_str", issue = "130366")]
#[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_slice(&self) -> &[T] {
self
}
Expand All @@ -5348,7 +5349,8 @@ impl<T> [T] {
/// it helps dereferencing other "container" types to slices,
/// for example `Box<[T]>` or `MutexGuard<[T]>`.
#[inline]
#[unstable(feature = "str_as_str", issue = "130366")]
#[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_mut_slice(&mut self) -> &mut [T] {
self
}
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3137,7 +3137,8 @@ impl str {
/// it helps dereferencing other string-like types to string slices,
/// for example references to `Box<str>` or `Arc<str>`.
#[inline]
#[unstable(feature = "str_as_str", issue = "130366")]
#[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_str(&self) -> &str {
self
}
Expand Down
3 changes: 2 additions & 1 deletion library/std/src/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,8 @@ impl OsStr {
/// it helps dereferencing other string-like types to string slices,
/// for example references to `Box<OsStr>` or `Arc<OsStr>`.
#[inline]
#[unstable(feature = "str_as_str", issue = "130366")]
#[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_os_str(&self) -> &OsStr {
self
}
Expand Down
3 changes: 2 additions & 1 deletion library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3235,7 +3235,8 @@ impl Path {
/// it helps dereferencing other `PathBuf`-like types to `Path`s,
/// for example references to `Box<Path>` or `Arc<Path>`.
#[inline]
#[unstable(feature = "str_as_str", issue = "130366")]
#[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_path(&self) -> &Path {
self
}
Expand Down
10 changes: 8 additions & 2 deletions library/std/tests/sync/oneshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ fn recv_deadline_passed() {
}

assert!(start.elapsed() >= timeout);
assert!(start.elapsed() < timeout * 3);
// FIXME(#152878): An upper-bound assertion on the elapsed time was removed,
// because CI runners can starve individual threads for a surprisingly long
// time, leading to flaky failures.
}

#[test]
Expand All @@ -252,12 +254,16 @@ fn recv_time_passed() {

let start = Instant::now();
let timeout = Duration::from_millis(100);

match receiver.recv_timeout(timeout) {
Err(RecvTimeoutError::Timeout(_)) => {}
_ => panic!("expected timeout error"),
}

assert!(start.elapsed() >= timeout);
assert!(start.elapsed() < timeout * 3);
// FIXME(#152878): An upper-bound assertion on the elapsed time was removed,
// because CI runners can starve individual threads for a surprisingly long
// time, leading to flaky failures.
}

#[test]
Expand Down
Loading
Loading