diff --git a/library/core/src/hint.rs b/library/core/src/hint.rs index 976a6c04ca6fa..b3e36e6fbc4ac 100644 --- a/library/core/src/hint.rs +++ b/library/core/src/hint.rs @@ -189,7 +189,7 @@ pub const unsafe fn unreachable_unchecked() -> ! { /// ``` /// /// This example is quite unlike anything that would be used in the real world: it is redundant -/// to put an an assertion right next to code that checks the same thing, and dereferencing a +/// to put an assertion right next to code that checks the same thing, and dereferencing a /// pointer already has the builtin assumption that it is nonnull. However, it illustrates the /// kind of changes the optimizer can make even when the behavior is less obviously related. #[track_caller] diff --git a/library/core/src/slice/sort/stable/drift.rs b/library/core/src/slice/sort/stable/drift.rs index 4008639095bde..2d9c4ac9fcf7c 100644 --- a/library/core/src/slice/sort/stable/drift.rs +++ b/library/core/src/slice/sort/stable/drift.rs @@ -200,7 +200,7 @@ fn logical_merge bool>( // If one or both of the runs are sorted do a physical merge, using // quicksort to sort the unsorted run if present. We also *need* to // physically merge if the combined runs would not fit in the scratch space - // anymore (as this would mean we are no longer able to to quicksort them). + // anymore (as this would mean we are no longer able to quicksort them). let len = v.len(); let can_fit_in_scratch = len <= scratch.len(); if !can_fit_in_scratch || left.sorted() || right.sorted() { diff --git a/library/portable-simd/crates/core_simd/src/swizzle_dyn.rs b/library/portable-simd/crates/core_simd/src/swizzle_dyn.rs index 8a1079042f076..3b6388d0f2759 100644 --- a/library/portable-simd/crates/core_simd/src/swizzle_dyn.rs +++ b/library/portable-simd/crates/core_simd/src/swizzle_dyn.rs @@ -30,6 +30,8 @@ where use core::arch::arm::{uint8x8_t, vtbl1_u8}; #[cfg(target_arch = "wasm32")] use core::arch::wasm32 as wasm; + #[cfg(target_arch = "wasm64")] + use core::arch::wasm64 as wasm; #[cfg(target_arch = "x86")] use core::arch::x86; #[cfg(target_arch = "x86_64")] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 6f9ac3d4acbbd..66aeb35aceec0 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -266,6 +266,7 @@ )] #![cfg_attr(any(windows, target_os = "uefi"), feature(round_char_boundary))] #![cfg_attr(target_family = "wasm", feature(stdarch_wasm_atomic_wait))] +#![cfg_attr(target_arch = "wasm64", feature(simd_wasm64))] #![cfg_attr( all(any(target_arch = "x86_64", target_arch = "x86"), target_os = "uefi"), feature(stdarch_x86_has_cpuid) diff --git a/library/std/src/sys/pal/unix/fs.rs b/library/std/src/sys/pal/unix/fs.rs index 92c76ec4303fe..f9d6b5fbc86a4 100644 --- a/library/std/src/sys/pal/unix/fs.rs +++ b/library/std/src/sys/pal/unix/fs.rs @@ -1976,13 +1976,14 @@ pub fn chroot(dir: &Path) -> io::Result<()> { pub use remove_dir_impl::remove_dir_all; -// Fallback for REDOX, ESP-ID, Horizon, Vita and Miri +// Fallback for REDOX, ESP-ID, Horizon, Vita, Vxworks and Miri #[cfg(any( target_os = "redox", target_os = "espidf", target_os = "horizon", target_os = "vita", target_os = "nto", + target_os = "vxworks", miri ))] mod remove_dir_impl { @@ -1996,6 +1997,7 @@ mod remove_dir_impl { target_os = "horizon", target_os = "vita", target_os = "nto", + target_os = "vxworks", miri )))] mod remove_dir_impl { diff --git a/library/std/src/sys/pal/unix/process/process_vxworks.rs b/library/std/src/sys/pal/unix/process/process_vxworks.rs index 76179e0910d9e..5007dbd34b4ab 100644 --- a/library/std/src/sys/pal/unix/process/process_vxworks.rs +++ b/library/std/src/sys/pal/unix/process/process_vxworks.rs @@ -1,5 +1,5 @@ use crate::fmt; -use crate::io::{self, Error, ErrorKind}; +use crate::io::{self, ErrorKind}; use crate::num::NonZero; use crate::sys; use crate::sys::cvt; diff --git a/library/std/src/sys/pal/wasm/atomics/futex.rs b/library/std/src/sys/pal/wasm/atomics/futex.rs index f4fbe9f48554b..a21b71efbbc69 100644 --- a/library/std/src/sys/pal/wasm/atomics/futex.rs +++ b/library/std/src/sys/pal/wasm/atomics/futex.rs @@ -1,4 +1,8 @@ -use crate::arch::wasm32; +#[cfg(target_arch = "wasm32")] +use core::arch::wasm32 as wasm; +#[cfg(target_arch = "wasm64")] +use core::arch::wasm64 as wasm; + use crate::sync::atomic::AtomicU32; use crate::time::Duration; @@ -10,11 +14,8 @@ use crate::time::Duration; pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option) -> bool { let timeout = timeout.and_then(|t| t.as_nanos().try_into().ok()).unwrap_or(-1); unsafe { - wasm32::memory_atomic_wait32( - futex as *const AtomicU32 as *mut i32, - expected as i32, - timeout, - ) < 2 + wasm::memory_atomic_wait32(futex as *const AtomicU32 as *mut i32, expected as i32, timeout) + < 2 } } @@ -23,12 +24,12 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option) - /// Returns true if this actually woke up such a thread, /// or false if no thread was waiting on this futex. pub fn futex_wake(futex: &AtomicU32) -> bool { - unsafe { wasm32::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, 1) > 0 } + unsafe { wasm::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, 1) > 0 } } /// Wake up all threads that are waiting on futex_wait on this futex. pub fn futex_wake_all(futex: &AtomicU32) { unsafe { - wasm32::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, i32::MAX as u32); + wasm::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, i32::MAX as u32); } } diff --git a/library/std/src/sys/pal/wasm/atomics/thread.rs b/library/std/src/sys/pal/wasm/atomics/thread.rs index 484bd08495eef..afdb159fe6f8b 100644 --- a/library/std/src/sys/pal/wasm/atomics/thread.rs +++ b/library/std/src/sys/pal/wasm/atomics/thread.rs @@ -19,7 +19,11 @@ impl Thread { pub fn set_name(_name: &CStr) {} pub fn sleep(dur: Duration) { - use crate::arch::wasm32; + #[cfg(target_arch = "wasm32")] + use core::arch::wasm32 as wasm; + #[cfg(target_arch = "wasm64")] + use core::arch::wasm64 as wasm; + use crate::cmp; // Use an atomic wait to block the current thread artificially with a @@ -31,7 +35,7 @@ impl Thread { while nanos > 0 { let amt = cmp::min(i64::MAX as u128, nanos); let mut x = 0; - let val = unsafe { wasm32::memory_atomic_wait32(&mut x, 0, amt as i64) }; + let val = unsafe { wasm::memory_atomic_wait32(&mut x, 0, amt as i64) }; debug_assert_eq!(val, 2); nanos -= amt; } diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 3b1a8830e1cdc..fe01d17b08a8c 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1286,7 +1286,7 @@ impl GenericBound { } } -#[derive(Clone, PartialEq, Eq, Debug, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] pub(crate) struct Lifetime(pub Symbol); impl Lifetime { diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index b965ab019cc4f..5111e363c522e 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -10,6 +10,7 @@ use rustc_ast::ast; use rustc_attr::DeprecatedSince; use rustc_hir::{def::CtorKind, def::DefKind, def_id::DefId}; use rustc_metadata::rendered_const; +use rustc_middle::bug; use rustc_middle::ty::{self, TyCtxt}; use rustc_span::symbol::sym; use rustc_span::{Pos, Symbol}; @@ -512,9 +513,15 @@ impl FromWithTcx for WherePredicate { }) .collect(), }, - RegionPredicate { lifetime, bounds } => WherePredicate::RegionPredicate { + RegionPredicate { lifetime, bounds } => WherePredicate::LifetimePredicate { lifetime: convert_lifetime(lifetime), - bounds: bounds.into_tcx(tcx), + outlives: bounds + .iter() + .map(|bound| match bound { + clean::GenericBound::Outlives(lt) => convert_lifetime(*lt), + _ => bug!("found non-outlives-bound on lifetime predicate"), + }) + .collect(), }, EqPredicate { lhs, rhs } => { WherePredicate::EqPredicate { lhs: lhs.into_tcx(tcx), rhs: rhs.into_tcx(tcx) } diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs index 68030493e9cfd..89115d4d7d667 100644 --- a/src/rustdoc-json-types/lib.rs +++ b/src/rustdoc-json-types/lib.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; use std::path::PathBuf; /// rustdoc format-version. -pub const FORMAT_VERSION: u32 = 30; +pub const FORMAT_VERSION: u32 = 31; /// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information /// about the language items in the local crate, as well as info about external items to allow @@ -511,9 +511,9 @@ pub enum WherePredicate { /// ``` generic_params: Vec, }, - RegionPredicate { + LifetimePredicate { lifetime: String, - bounds: Vec, + outlives: Vec, }, EqPredicate { lhs: Type, diff --git a/src/tools/jsondocck/src/main.rs b/src/tools/jsondocck/src/main.rs index 688b403bf0e0a..429c6151796fe 100644 --- a/src/tools/jsondocck/src/main.rs +++ b/src/tools/jsondocck/src/main.rs @@ -56,6 +56,8 @@ pub enum CommandKind { impl CommandKind { fn validate(&self, args: &[String], lineno: usize) -> bool { + // FIXME(adotinthevoid): We should "parse, don't validate" here, so we avoid ad-hoc + // indexing in check_command. let count = match self { CommandKind::Has => (1..=2).contains(&args.len()), CommandKind::IsMany => args.len() >= 2, @@ -71,7 +73,7 @@ impl CommandKind { if let CommandKind::Count = self { if args[1].parse::().is_err() { print_err( - &format!("Second argument to @count must be a valid usize (got `{}`)", args[2]), + &format!("Second argument to @count must be a valid usize (got `{}`)", args[1]), lineno, ); return false; diff --git a/src/tools/jsondoclint/src/validator.rs b/src/tools/jsondoclint/src/validator.rs index 1713a4d812c4b..cd011dce7844e 100644 --- a/src/tools/jsondoclint/src/validator.rs +++ b/src/tools/jsondoclint/src/validator.rs @@ -374,8 +374,8 @@ impl<'a> Validator<'a> { bounds.iter().for_each(|b| self.check_generic_bound(b)); generic_params.iter().for_each(|gpd| self.check_generic_param_def(gpd)); } - WherePredicate::RegionPredicate { lifetime: _, bounds } => { - bounds.iter().for_each(|b| self.check_generic_bound(b)); + WherePredicate::LifetimePredicate { lifetime: _, outlives: _ } => { + // nop, all strings. } WherePredicate::EqPredicate { lhs, rhs } => { self.check_type(lhs); diff --git a/tests/rustdoc-json/lifetime/outlives_in_param.rs b/tests/rustdoc-json/lifetime/outlives_in_param.rs new file mode 100644 index 0000000000000..f6db93c918329 --- /dev/null +++ b/tests/rustdoc-json/lifetime/outlives_in_param.rs @@ -0,0 +1,8 @@ +// ignore-tidy-linelength + +// @count '$.index[*][?(@.name=="outlives")].inner.function.generics.params[*]' 2 +// @is '$.index[*][?(@.name=="outlives")].inner.function.generics.params[0].name' \"\'a\" +// @is '$.index[*][?(@.name=="outlives")].inner.function.generics.params[0].kind.lifetime.outlives' [] +// @is '$.index[*][?(@.name=="outlives")].inner.function.generics.params[1].name' '"T"' +// @is '$.index[*][?(@.name=="outlives")].inner.function.generics.params[1].kind.type.bounds' '[{"outlives": "'\''a"}]' +pub fn outlives<'a, T: 'a>() {} diff --git a/tests/rustdoc-json/lifetime/outlives_in_where.rs b/tests/rustdoc-json/lifetime/outlives_in_where.rs new file mode 100644 index 0000000000000..ca3e1a150ce8e --- /dev/null +++ b/tests/rustdoc-json/lifetime/outlives_in_where.rs @@ -0,0 +1,24 @@ +// ignore-tidy-linelength + +// @is '$.index[*][?(@.name=="on_lifetimes")].inner.function.generics.where_predicates' '[{"lifetime_predicate": {"lifetime": "'\''all", "outlives": ["'\''a", "'\''b", "'\''c"]}}]' +pub fn on_lifetimes<'a, 'b, 'c, 'all>() +where + 'all: 'a + 'b + 'c, +{ +} + +// @count '$.index[*][?(@.name=="on_trait")].inner.function.generics.params[*]' 2 +// @is '$.index[*][?(@.name=="on_trait")].inner.function.generics.params[0].name' \"\'a\" +// @is '$.index[*][?(@.name=="on_trait")].inner.function.generics.params[0].kind.lifetime.outlives' [] +// @is '$.index[*][?(@.name=="on_trait")].inner.function.generics.params[1].name' '"T"' +// @is '$.index[*][?(@.name=="on_trait")].inner.function.generics.params[1].kind.type.bounds' [] +// @is '$.index[*][?(@.name=="on_trait")].inner.function.generics.params[1].kind.type.bounds' [] +// @count '$.index[*][?(@.name=="on_trait")].inner.function.generics.where_predicates[*]' 1 +// @is '$.index[*][?(@.name=="on_trait")].inner.function.generics.where_predicates[0].bound_predicate.type.generic' '"T"' +// @count '$.index[*][?(@.name=="on_trait")].inner.function.generics.where_predicates[0].bound_predicate.bounds[*]' 1 +// @is '$.index[*][?(@.name=="on_trait")].inner.function.generics.where_predicates[0].bound_predicate.bounds[0].outlives' \"\'a\" +pub fn on_trait<'a, T>() +where + T: 'a, +{ +}