Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #127305

Merged
merged 11 commits into from
Jul 4, 2024
2 changes: 1 addition & 1 deletion library/core/src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/slice/sort/stable/drift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ fn logical_merge<T, F: FnMut(&T, &T) -> 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() {
Expand Down
2 changes: 2 additions & 0 deletions library/portable-simd/crates/core_simd/src/swizzle_dyn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion library/std/src/sys/pal/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/unix/process/process_vxworks.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
17 changes: 9 additions & 8 deletions library/std/src/sys/pal/wasm/atomics/futex.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -10,11 +14,8 @@ use crate::time::Duration;
pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -> 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
}
}

Expand All @@ -23,12 +24,12 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -
/// 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);
}
}
8 changes: 6 additions & 2 deletions library/std/src/sys/pal/wasm/atomics/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 9 additions & 2 deletions src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -512,9 +513,15 @@ impl FromWithTcx<clean::WherePredicate> 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) }
Expand Down
6 changes: 3 additions & 3 deletions src/rustdoc-json-types/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -511,9 +511,9 @@ pub enum WherePredicate {
/// ```
generic_params: Vec<GenericParamDef>,
},
RegionPredicate {
LifetimePredicate {
lifetime: String,
bounds: Vec<GenericBound>,
outlives: Vec<String>,
},
EqPredicate {
lhs: Type,
Expand Down
4 changes: 3 additions & 1 deletion src/tools/jsondocck/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -71,7 +73,7 @@ impl CommandKind {
if let CommandKind::Count = self {
if args[1].parse::<usize>().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;
Expand Down
4 changes: 2 additions & 2 deletions src/tools/jsondoclint/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions tests/rustdoc-json/lifetime/outlives_in_param.rs
Original file line number Diff line number Diff line change
@@ -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>() {}
24 changes: 24 additions & 0 deletions tests/rustdoc-json/lifetime/outlives_in_where.rs
Original file line number Diff line number Diff line change
@@ -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,
{
}
Loading