Skip to content

Commit cf1817b

Browse files
committed
Auto merge of rust-lang#155634 - jhpratt:rollup-lo99oO5, r=jhpratt
Rollup of 7 pull requests Successful merges: - rust-lang#155589 (Forbid `check-pass`/`build-pass`/`run-pass` directives in incremental tests) - rust-lang#155610 (Add missing `dyn` keyword to `trait_alias` page of the Unstable Book) - rust-lang#155615 (test cleanups for `ui/derives` and `ui/deriving`) - rust-lang#154874 (Fix ICE for inherited const conditions on const closures) - rust-lang#155605 (std: Update support for `wasm32-wasip3`) - rust-lang#155613 (c-variadic: tweak `std` docs) - rust-lang#155619 (Remove a bunch of unnecessary explicit lifetimes from the ast validator)
2 parents 1bfcb28 + 6fa2b1d commit cf1817b

105 files changed

Lines changed: 3296 additions & 3324 deletions

File tree

Some content is hidden

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

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl<'a> AstValidator<'a> {
208208
}
209209

210210
// Mirrors `visit::walk_ty`, but tracks relevant state.
211-
fn walk_ty(&mut self, t: &'a Ty) {
211+
fn walk_ty(&mut self, t: &Ty) {
212212
match &t.kind {
213213
TyKind::ImplTrait(_, bounds) => {
214214
self.with_impl_trait(Some(t.span), |this| visit::walk_ty(this, t));
@@ -731,7 +731,7 @@ impl<'a> AstValidator<'a> {
731731
/// C-variadics must be:
732732
/// - Non-const
733733
/// - Either foreign, or free and `unsafe extern "C"` semantically
734-
fn check_c_variadic_type(&self, fk: FnKind<'a>, attrs: &'a AttrVec) {
734+
fn check_c_variadic_type(&self, fk: FnKind<'_>, attrs: &AttrVec) {
735735
// `...` is already rejected when it is not the final parameter.
736736
let variadic_param = match fk.decl().inputs.last() {
737737
Some(param) if matches!(param.ty.kind, TyKind::CVarArgs) => param,
@@ -806,7 +806,7 @@ impl<'a> AstValidator<'a> {
806806
fn check_c_variadic_abi(
807807
&self,
808808
abi: ExternAbi,
809-
attrs: &'a AttrVec,
809+
attrs: &AttrVec,
810810
dotdotdot_span: Span,
811811
sig: &FnSig,
812812
) {
@@ -976,7 +976,7 @@ impl<'a> AstValidator<'a> {
976976
});
977977
}
978978

979-
fn visit_ty_common(&mut self, ty: &'a Ty) {
979+
fn visit_ty_common(&mut self, ty: &Ty) {
980980
match &ty.kind {
981981
TyKind::FnPtr(bfty) => {
982982
self.check_fn_ptr_safety(bfty.decl_span, bfty.safety);
@@ -1039,13 +1039,13 @@ impl<'a> AstValidator<'a> {
10391039
}
10401040

10411041
// Used within `visit_item` for item kinds where we don't call `visit::walk_item`.
1042-
fn visit_attrs_vis(&mut self, attrs: &'a AttrVec, vis: &'a Visibility) {
1042+
fn visit_attrs_vis(&mut self, attrs: &AttrVec, vis: &Visibility) {
10431043
walk_list!(self, visit_attribute, attrs);
10441044
self.visit_vis(vis);
10451045
}
10461046

10471047
// Used within `visit_item` for item kinds where we don't call `visit::walk_item`.
1048-
fn visit_attrs_vis_ident(&mut self, attrs: &'a AttrVec, vis: &'a Visibility, ident: &'a Ident) {
1048+
fn visit_attrs_vis_ident(&mut self, attrs: &AttrVec, vis: &Visibility, ident: &Ident) {
10491049
walk_list!(self, visit_attribute, attrs);
10501050
self.visit_vis(vis);
10511051
self.visit_ident(ident);
@@ -1125,17 +1125,17 @@ fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericPara
11251125
}
11261126
}
11271127

1128-
impl<'a> Visitor<'a> for AstValidator<'a> {
1128+
impl Visitor<'_> for AstValidator<'_> {
11291129
fn visit_attribute(&mut self, attr: &Attribute) {
11301130
validate_attr::check_attr(&self.sess.psess, attr);
11311131
}
11321132

1133-
fn visit_ty(&mut self, ty: &'a Ty) {
1133+
fn visit_ty(&mut self, ty: &Ty) {
11341134
self.visit_ty_common(ty);
11351135
self.walk_ty(ty)
11361136
}
11371137

1138-
fn visit_item(&mut self, item: &'a Item) {
1138+
fn visit_item(&mut self, item: &Item) {
11391139
if item.attrs.iter().any(|attr| attr.is_proc_macro_attr()) {
11401140
self.has_proc_macro_decls = true;
11411141
}
@@ -1477,7 +1477,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
14771477
self.lint_node_id = previous_lint_node_id;
14781478
}
14791479

1480-
fn visit_foreign_item(&mut self, fi: &'a ForeignItem) {
1480+
fn visit_foreign_item(&mut self, fi: &ForeignItem) {
14811481
match &fi.kind {
14821482
ForeignItemKind::Fn(box Fn { defaultness, ident, sig, body, .. }) => {
14831483
self.check_defaultness(fi.span, *defaultness, AllowDefault::No, AllowFinal::No);
@@ -1527,7 +1527,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
15271527
}
15281528

15291529
// Mirrors `visit::walk_generic_args`, but tracks relevant state.
1530-
fn visit_generic_args(&mut self, generic_args: &'a GenericArgs) {
1530+
fn visit_generic_args(&mut self, generic_args: &GenericArgs) {
15311531
match generic_args {
15321532
GenericArgs::AngleBracketed(data) => {
15331533
self.check_generic_args_before_constraints(data);
@@ -1557,7 +1557,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
15571557
}
15581558
}
15591559

1560-
fn visit_generics(&mut self, generics: &'a Generics) {
1560+
fn visit_generics(&mut self, generics: &Generics) {
15611561
let mut prev_param_default = None;
15621562
for param in &generics.params {
15631563
match param.kind {
@@ -1613,7 +1613,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
16131613
}
16141614
}
16151615

1616-
fn visit_param_bound(&mut self, bound: &'a GenericBound, ctxt: BoundKind) {
1616+
fn visit_param_bound(&mut self, bound: &GenericBound, ctxt: BoundKind) {
16171617
match bound {
16181618
GenericBound::Trait(trait_ref) => {
16191619
match (ctxt, trait_ref.modifiers.constness, trait_ref.modifiers.polarity) {
@@ -1671,7 +1671,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
16711671
visit::walk_param_bound(self, bound)
16721672
}
16731673

1674-
fn visit_fn(&mut self, fk: FnKind<'a>, attrs: &AttrVec, span: Span, id: NodeId) {
1674+
fn visit_fn(&mut self, fk: FnKind<'_>, attrs: &AttrVec, span: Span, id: NodeId) {
16751675
// Only associated `fn`s can have `self` parameters.
16761676
let self_semantic = match fk.ctxt() {
16771677
Some(FnCtxt::Assoc(_)) => SelfSemantic::Yes,
@@ -1784,7 +1784,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
17841784
self.with_tilde_const(disallowed, |this| visit::walk_fn(this, fk));
17851785
}
17861786

1787-
fn visit_assoc_item(&mut self, item: &'a AssocItem, ctxt: AssocCtxt) {
1787+
fn visit_assoc_item(&mut self, item: &AssocItem, ctxt: AssocCtxt) {
17881788
if let Some(ident) = item.kind.ident()
17891789
&& attr::contains_name(&item.attrs, sym::no_mangle)
17901790
{
@@ -1931,7 +1931,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
19311931
}
19321932
}
19331933

1934-
fn visit_anon_const(&mut self, anon_const: &'a AnonConst) {
1934+
fn visit_anon_const(&mut self, anon_const: &AnonConst) {
19351935
self.with_tilde_const(
19361936
Some(TildeConstReason::AnonConst { span: anon_const.value.span }),
19371937
|this| visit::walk_anon_const(this, anon_const),

compiler/rustc_trait_selection/src/traits/effects.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -556,15 +556,8 @@ fn evaluate_host_effect_for_fn_goal<'tcx>(
556556

557557
ty::Closure(def, args) => {
558558
// For now we limit ourselves to closures without binders. The next solver can handle them.
559-
let sig =
560-
args.as_closure().sig().no_bound_vars().ok_or(EvaluationFailure::NoSolution)?;
561-
(
562-
def,
563-
tcx.mk_args_from_iter(
564-
[ty::GenericArg::from(*sig.inputs().get(0).unwrap()), sig.output().into()]
565-
.into_iter(),
566-
),
567-
)
559+
args.as_closure().sig().no_bound_vars().ok_or(EvaluationFailure::NoSolution)?;
560+
(def, args)
568561
}
569562

570563
// Everything else needs explicit impls or cannot have an impl

library/Cargo.lock

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ dependencies = [
346346
"vex-sdk",
347347
"wasip1",
348348
"wasip2",
349+
"wasip3",
349350
"windows-link 0.0.0",
350351
]
351352

@@ -418,9 +419,20 @@ dependencies = [
418419

419420
[[package]]
420421
name = "wasip2"
421-
version = "1.0.2+wasi-0.2.9"
422+
version = "1.0.3+wasi-0.2.9"
422423
source = "registry+https://github.com/rust-lang/crates.io-index"
423-
checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5"
424+
checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6"
425+
dependencies = [
426+
"rustc-std-workspace-alloc",
427+
"rustc-std-workspace-core",
428+
"wit-bindgen",
429+
]
430+
431+
[[package]]
432+
name = "wasip3"
433+
version = "0.6.0+wasi-0.3.0-rc-2026-03-15"
434+
source = "registry+https://github.com/rust-lang/crates.io-index"
435+
checksum = "ed83456dd6a0b8581998c0365e4651fa2997e5093b49243b7f35391afaa7a3d9"
424436
dependencies = [
425437
"rustc-std-workspace-alloc",
426438
"rustc-std-workspace-core",
@@ -513,9 +525,9 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
513525

514526
[[package]]
515527
name = "wit-bindgen"
516-
version = "0.51.0"
528+
version = "0.57.1"
517529
source = "registry+https://github.com/rust-lang/crates.io-index"
518-
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
530+
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
519531
dependencies = [
520532
"rustc-std-workspace-alloc",
521533
"rustc-std-workspace-core",

library/core/src/ffi/va_list.rs

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,15 @@ crate::cfg_select! {
213213
/// assert_eq!(unsafe { my_func(3, 42i32, -7i32, 20i32) }, 55);
214214
/// ```
215215
///
216-
/// The [`VaList::arg`] method can be used to read an argument from the list. This method
217-
/// automatically advances the `VaList` to the next argument. The C equivalent is `va_arg`.
216+
/// The [`VaList::arg`] method reads the next argument from the variable argument list,
217+
/// and is equivalent to C `va_arg`.
218218
///
219219
/// Cloning a `VaList` performs the equivalent of C `va_copy`, producing an independent cursor
220220
/// that arguments can be read from without affecting the original. Dropping a `VaList` performs
221221
/// the equivalent of C `va_end`.
222222
///
223-
/// This can be used across an FFI boundary, and fully matches the platform's `va_list`.
223+
/// A `VaList` can be used across an FFI boundary, and fully matches the platform's `va_list` in
224+
/// terms of layout and ABI.
224225
#[repr(transparent)]
225226
#[lang = "va_list"]
226227
pub struct VaList<'a> {
@@ -285,17 +286,33 @@ mod sealed {
285286

286287
/// Types that are valid to read using [`VaList::arg`].
287288
///
288-
/// # Safety
289+
/// This trait is implemented for primitive types that have a variable argument application-binary
290+
/// interface (ABI) on the current platform. It is always implemented for:
291+
///
292+
/// - [`c_int`], [`c_long`] and [`c_longlong`]
293+
/// - [`c_uint`], [`c_ulong`] and [`c_ulonglong`]
294+
/// - [`c_double`]
295+
/// - `*const T` and `*mut T`
289296
///
290-
/// The standard library implements this trait for primitive types that are
291-
/// expected to have a variable argument application-binary interface (ABI) on all
292-
/// platforms.
297+
/// Implementations for e.g. `i32` or `usize` shouldn't be relied upon directly,
298+
/// because they may not be available on all platforms.
299+
///
300+
/// # Safety
293301
///
294-
/// When C passes variable arguments, integers smaller than [`c_int`] and floats smaller
295-
/// than [`c_double`] are implicitly promoted to [`c_int`] and [`c_double`] respectively.
296-
/// Implementing this trait for types that are subject to this promotion rule is invalid.
302+
/// When C passes variable arguments, signed integers smaller than [`c_int`] are promoted
303+
/// to [`c_int`], unsigned integers smaller than [`c_uint`] are promoted to [`c_uint`],
304+
/// and [`c_float`] is promoted to [`c_double`]. Implementing this trait for types that are
305+
/// subject to this promotion rule is invalid.
297306
///
298307
/// [`c_int`]: core::ffi::c_int
308+
/// [`c_long`]: core::ffi::c_long
309+
/// [`c_longlong`]: core::ffi::c_longlong
310+
///
311+
/// [`c_uint`]: core::ffi::c_uint
312+
/// [`c_ulong`]: core::ffi::c_ulong
313+
/// [`c_ulonglong`]: core::ffi::c_ulonglong
314+
///
315+
/// [`c_float`]: core::ffi::c_float
299316
/// [`c_double`]: core::ffi::c_double
300317
// We may unseal this trait in the future, but currently our `va_arg` implementations don't support
301318
// types with an alignment larger than 8, or with a non-scalar layout. Inline assembly can be used
@@ -352,14 +369,16 @@ const _: () = {
352369
va_arg_safe_check::<crate::ffi::c_int>();
353370
va_arg_safe_check::<crate::ffi::c_uint>();
354371
va_arg_safe_check::<crate::ffi::c_long>();
372+
355373
va_arg_safe_check::<crate::ffi::c_ulong>();
356374
va_arg_safe_check::<crate::ffi::c_longlong>();
357375
va_arg_safe_check::<crate::ffi::c_ulonglong>();
376+
358377
va_arg_safe_check::<crate::ffi::c_double>();
359378
};
360379

361380
impl<'f> VaList<'f> {
362-
/// Read an argument from the variable argument list, and advance to the next argument.
381+
/// Read the next argument from the variable argument list.
363382
///
364383
/// Only types that implement [`VaArgSafe`] can be read from a variable argument list.
365384
///

library/std/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ wasip1 = { version = "1.0.0", features = [
8484
], default-features = false }
8585

8686
[target.'cfg(all(target_os = "wasi", target_env = "p2"))'.dependencies]
87-
wasip2 = { version = '1.0.2', features = [
87+
wasip2 = { version = '1.0.3', features = [
8888
'rustc-dep-of-std',
8989
], default-features = false }
9090

9191
[target.'cfg(all(target_os = "wasi", target_env = "p3"))'.dependencies]
92-
wasip2 = { version = '1.0.2', features = [
92+
wasip3 = { version = '0.6.0', features = [
9393
'rustc-dep-of-std',
9494
], default-features = false }
9595

library/std/src/sys/args/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ cfg_select! {
4242
pub use wasip1::*;
4343
}
4444
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
45-
mod wasip2;
46-
pub use wasip2::*;
45+
mod wasi;
46+
pub use wasi::*;
4747
}
4848
target_os = "xous" => {
4949
mod xous;

library/std/src/sys/args/wasi.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#[cfg(target_env = "p2")]
2+
use wasip2 as wasi;
3+
#[cfg(target_env = "p3")]
4+
use wasip3 as wasi;
5+
6+
pub use super::common::Args;
7+
8+
/// Returns the command line arguments
9+
pub fn args() -> Args {
10+
Args::new(wasi::cli::environment::get_arguments().into_iter().map(|arg| arg.into()).collect())
11+
}

library/std/src/sys/args/wasip2.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

library/std/src/sys/random/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ cfg_select! {
9595
pub use wasip1::fill_bytes;
9696
}
9797
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
98-
mod wasip2;
99-
pub use wasip2::{fill_bytes, hashmap_random_keys};
98+
mod wasi;
99+
pub use wasi::{fill_bytes, hashmap_random_keys};
100100
}
101101
target_os = "zkvm" => {
102102
mod zkvm;

library/std/src/sys/random/wasi.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#[cfg(target_env = "p2")]
2+
use wasip2::random::{insecure_seed::insecure_seed as get_insecure_seed, random::get_random_bytes};
3+
#[cfg(target_env = "p3")]
4+
use wasip3::random::{insecure_seed::get_insecure_seed, random::get_random_bytes};
5+
6+
pub fn fill_bytes(bytes: &mut [u8]) {
7+
bytes.copy_from_slice(&get_random_bytes(u64::try_from(bytes.len()).unwrap()));
8+
}
9+
10+
pub fn hashmap_random_keys() -> (u64, u64) {
11+
get_insecure_seed()
12+
}

0 commit comments

Comments
 (0)