Auto merge of #154638 - JonathanBrouwer:rollup-oLBZ6Tr, r=JonathanBrouwer

Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#150752 (Update libc to v0.2.183)
 - rust-lang/rust#152432 (add rustc option -Zpacked-stack)
 - rust-lang/rust#154634 (Use `Hcx`/`hcx` consistently for `StableHashingContext`.)
 - rust-lang/rust#154635 (./x run miri: default to edition 2021)
This commit is contained in:
bors
2026-03-31 20:16:05 +00:00
50 changed files with 512 additions and 316 deletions
+2 -2
View File
@@ -120,8 +120,8 @@ fn eq(&self, names: &&[Symbol]) -> bool {
}
}
impl<CTX: rustc_span::HashStableContext> HashStable<CTX> for Path {
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
impl<Hcx: rustc_span::HashStableContext> HashStable<Hcx> for Path {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.segments.len().hash_stable(hcx, hasher);
for segment in &self.segments {
segment.ident.hash_stable(hcx, hasher);
+5 -5
View File
@@ -138,8 +138,8 @@ fn decode(_d: &mut D) -> Self {
}
}
impl<CTX> HashStable<CTX> for LazyAttrTokenStream {
fn hash_stable(&self, _hcx: &mut CTX, _hasher: &mut StableHasher) {
impl<Hcx> HashStable<Hcx> for LazyAttrTokenStream {
fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {
panic!("Attempted to compute stable hash for LazyAttrTokenStream");
}
}
@@ -824,11 +824,11 @@ fn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self {
}
}
impl<CTX> HashStable<CTX> for TokenStream
impl<Hcx> HashStable<Hcx> for TokenStream
where
CTX: crate::HashStableContext,
Hcx: crate::HashStableContext,
{
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
for sub_tt in self.iter() {
sub_tt.hash_stable(hcx, hasher);
}
@@ -45,8 +45,8 @@ enum OngoingModuleCodegen {
Async(JoinHandle<Result<ModuleCodegenResult, String>>),
}
impl<HCX> HashStable<HCX> for OngoingModuleCodegen {
fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) {
impl<Hcx> HashStable<Hcx> for OngoingModuleCodegen {
fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) {
// do nothing
}
}
+36 -2
View File
@@ -3,16 +3,17 @@
use rustc_hir::def_id::DefId;
use rustc_hir::find_attr;
use rustc_middle::middle::codegen_fn_attrs::{
CodegenFnAttrFlags, CodegenFnAttrs, PatchableFunctionEntry, SanitizerFnAttrs,
CodegenFnAttrFlags, CodegenFnAttrs, PatchableFunctionEntry, SanitizerFnAttrs, TargetFeature,
};
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::config::{BranchProtection, FunctionReturn, OptLevel, PAuthKey, PacRet};
use rustc_span::sym;
use rustc_symbol_mangling::mangle_internal_symbol;
use rustc_target::spec::{Arch, FramePointer, SanitizerSet, StackProbeType, StackProtector};
use smallvec::SmallVec;
use crate::context::SimpleCx;
use crate::errors::SanitizerMemtagRequiresMte;
use crate::errors::{PackedStackBackchainNeedsSoftfloat, SanitizerMemtagRequiresMte};
use crate::llvm::AttributePlace::Function;
use crate::llvm::{
self, AllocKindFlags, Attribute, AttributeKind, AttributePlace, MemoryEffects, Value,
@@ -302,6 +303,36 @@ fn stackprotector_attr<'ll>(cx: &SimpleCx<'ll>, sess: &Session) -> Option<&'ll A
Some(sspattr.create_attr(cx.llcx))
}
fn packed_stack_attr<'ll>(
cx: &SimpleCx<'ll>,
sess: &Session,
function_attributes: &Vec<TargetFeature>,
) -> Option<&'ll Attribute> {
if sess.target.arch != Arch::S390x {
return None;
}
if !sess.opts.unstable_opts.packed_stack {
return None;
}
// The backchain and softfloat flags can be set via -Ctarget-features=...
// or via #[target_features(enable = ...)] so we have to check both possibilities
let have_backchain = sess.unstable_target_features.contains(&sym::backchain)
|| function_attributes.iter().any(|feature| feature.name == sym::backchain);
let have_softfloat = sess.unstable_target_features.contains(&sym::soft_float)
|| function_attributes.iter().any(|feature| feature.name == sym::soft_float);
// If both, backchain and packedstack, are enabled LLVM cannot generate valid function entry points
// with the default ABI. However if the softfloat flag is set LLVM will switch to the softfloat
// ABI, where this works.
if have_backchain && !have_softfloat {
sess.dcx().emit_err(PackedStackBackchainNeedsSoftfloat);
return None;
}
Some(llvm::CreateAttrString(cx.llcx, "packed-stack"))
}
pub(crate) fn target_cpu_attr<'ll>(cx: &SimpleCx<'ll>, sess: &Session) -> &'ll Attribute {
let target_cpu = llvm_util::target_cpu(sess);
llvm::CreateAttrStringValue(cx.llcx, "target-cpu", target_cpu)
@@ -517,6 +548,9 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
if let Some(align) = codegen_fn_attrs.alignment {
llvm::set_alignment(llfn, align);
}
if let Some(packed_stack) = packed_stack_attr(cx, sess, &codegen_fn_attrs.target_features) {
to_add.push(packed_stack);
}
to_add.extend(patchable_function_entry_attrs(
cx,
sess,
@@ -204,3 +204,10 @@ pub(crate) struct MismatchedDataLayout<'a> {
pub(crate) struct FixedX18InvalidArch<'a> {
pub arch: &'a str,
}
#[derive(Diagnostic)]
#[diag("`-Zpacked-stack` is incompatible with `backchain` target feature")]
#[note(
"enabling both `-Zpacked-stack` and the `backchain` target feature is incompatible with the default s390x ABI. Switch to s390x-unknown-none-softfloat if you need both attributes"
)]
pub(crate) struct PackedStackBackchainNeedsSoftfloat;
+2 -2
View File
@@ -102,8 +102,8 @@ mod temp_stable_hash_impls {
use crate::ModuleCodegen;
impl<HCX, M> HashStable<HCX> for ModuleCodegen<M> {
fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) {
impl<Hcx, M> HashStable<Hcx> for ModuleCodegen<M> {
fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) {
// do nothing
}
}
+3 -3
View File
@@ -103,11 +103,11 @@ fn hash<H: Hasher>(&self, s: &mut H) {
}
}
impl<T, CTX> HashStable<CTX> for Interned<'_, T>
impl<T, Hcx> HashStable<Hcx> for Interned<'_, T>
where
T: HashStable<CTX>,
T: HashStable<Hcx>,
{
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.0.hash_stable(hcx, hasher);
}
}
+3 -3
View File
@@ -60,10 +60,10 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
impl<CTX> HashStable<CTX> for Pu128 {
impl<Hcx> HashStable<Hcx> for Pu128 {
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
{ self.0 }.hash_stable(ctx, hasher)
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
{ self.0 }.hash_stable(hcx, hasher)
}
}
@@ -347,10 +347,10 @@ fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
}
}
impl<K: HashStable<CTX> + StableOrd, V: HashStable<CTX>, CTX> HashStable<CTX> for SortedMap<K, V> {
impl<K: HashStable<Hcx> + StableOrd, V: HashStable<Hcx>, Hcx> HashStable<Hcx> for SortedMap<K, V> {
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self.data.hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.data.hash_stable(hcx, hasher);
}
}
@@ -15,7 +15,7 @@
FromStableHash, SipHasher128Hash as StableHasherHash, StableSipHasher128 as StableHasher,
};
/// Something that implements `HashStable<CTX>` can be hashed in a way that is
/// Something that implements `HashStable<Hcx>` can be hashed in a way that is
/// stable across multiple compilation sessions.
///
/// Note that `HashStable` imposes rather more strict requirements than usual
@@ -41,16 +41,16 @@
/// - `hash_stable()` must be independent of the host architecture. The
/// `StableHasher` takes care of endianness and `isize`/`usize` platform
/// differences.
pub trait HashStable<CTX> {
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher);
pub trait HashStable<Hcx> {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher);
}
/// Implement this for types that can be turned into stable keys like, for
/// example, for DefId that can be converted to a DefPathHash. This is used for
/// bringing maps into a predictable order before hashing them.
pub trait ToStableHashKey<HCX> {
type KeyType: Ord + Sized + HashStable<HCX>;
fn to_stable_hash_key(&self, hcx: &HCX) -> Self::KeyType;
pub trait ToStableHashKey<Hcx> {
type KeyType: Ord + Sized + HashStable<Hcx>;
fn to_stable_hash_key(&self, hcx: &Hcx) -> Self::KeyType;
}
/// Trait for marking a type as having a sort order that is
@@ -136,9 +136,9 @@ fn stable_cmp(&self, other: &Self) -> std::cmp::Ordering {
/// Use `#[derive(HashStable_Generic)]` instead.
macro_rules! impl_stable_traits_for_trivial_type {
($t:ty) => {
impl<CTX> $crate::stable_hasher::HashStable<CTX> for $t {
impl<Hcx> $crate::stable_hasher::HashStable<Hcx> for $t {
#[inline]
fn hash_stable(&self, _: &mut CTX, hasher: &mut $crate::stable_hasher::StableHasher) {
fn hash_stable(&self, _: &mut Hcx, hasher: &mut $crate::stable_hasher::StableHasher) {
::std::hash::Hash::hash(self, hasher);
}
}
@@ -177,9 +177,9 @@ impl $crate::stable_hasher::StableOrd for $t {
// We need a custom impl as the default hash function will only hash half the bits. For stable
// hashing we want to hash the full 128-bit hash.
impl<CTX> HashStable<CTX> for Hash128 {
impl<Hcx> HashStable<Hcx> for Hash128 {
#[inline]
fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) {
self.as_u128().hash(hasher);
}
}
@@ -192,64 +192,64 @@ impl StableOrd for Hash128 {
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
}
impl<CTX> HashStable<CTX> for ! {
fn hash_stable(&self, _ctx: &mut CTX, _hasher: &mut StableHasher) {
impl<Hcx> HashStable<Hcx> for ! {
fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {
unreachable!()
}
}
impl<CTX, T> HashStable<CTX> for PhantomData<T> {
fn hash_stable(&self, _ctx: &mut CTX, _hasher: &mut StableHasher) {}
impl<Hcx, T> HashStable<Hcx> for PhantomData<T> {
fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {}
}
impl<CTX> HashStable<CTX> for NonZero<u32> {
impl<Hcx> HashStable<Hcx> for NonZero<u32> {
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self.get().hash_stable(ctx, hasher)
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.get().hash_stable(hcx, hasher)
}
}
impl<CTX> HashStable<CTX> for NonZero<usize> {
impl<Hcx> HashStable<Hcx> for NonZero<usize> {
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self.get().hash_stable(ctx, hasher)
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.get().hash_stable(hcx, hasher)
}
}
impl<CTX> HashStable<CTX> for f32 {
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
impl<Hcx> HashStable<Hcx> for f32 {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
let val: u32 = self.to_bits();
val.hash_stable(ctx, hasher);
val.hash_stable(hcx, hasher);
}
}
impl<CTX> HashStable<CTX> for f64 {
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
impl<Hcx> HashStable<Hcx> for f64 {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
let val: u64 = self.to_bits();
val.hash_stable(ctx, hasher);
val.hash_stable(hcx, hasher);
}
}
impl<CTX> HashStable<CTX> for ::std::cmp::Ordering {
impl<Hcx> HashStable<Hcx> for ::std::cmp::Ordering {
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
(*self as i8).hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
(*self as i8).hash_stable(hcx, hasher);
}
}
impl<T1: HashStable<CTX>, CTX> HashStable<CTX> for (T1,) {
impl<T1: HashStable<Hcx>, Hcx> HashStable<Hcx> for (T1,) {
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
let (ref _0,) = *self;
_0.hash_stable(ctx, hasher);
_0.hash_stable(hcx, hasher);
}
}
impl<T1: HashStable<CTX>, T2: HashStable<CTX>, CTX> HashStable<CTX> for (T1, T2) {
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
impl<T1: HashStable<Hcx>, T2: HashStable<Hcx>, Hcx> HashStable<Hcx> for (T1, T2) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
let (ref _0, ref _1) = *self;
_0.hash_stable(ctx, hasher);
_1.hash_stable(ctx, hasher);
_0.hash_stable(hcx, hasher);
_1.hash_stable(hcx, hasher);
}
}
@@ -261,17 +261,17 @@ impl<T1: StableOrd, T2: StableOrd> StableOrd for (T1, T2) {
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
}
impl<T1, T2, T3, CTX> HashStable<CTX> for (T1, T2, T3)
impl<T1, T2, T3, Hcx> HashStable<Hcx> for (T1, T2, T3)
where
T1: HashStable<CTX>,
T2: HashStable<CTX>,
T3: HashStable<CTX>,
T1: HashStable<Hcx>,
T2: HashStable<Hcx>,
T3: HashStable<Hcx>,
{
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
let (ref _0, ref _1, ref _2) = *self;
_0.hash_stable(ctx, hasher);
_1.hash_stable(ctx, hasher);
_2.hash_stable(ctx, hasher);
_0.hash_stable(hcx, hasher);
_1.hash_stable(hcx, hasher);
_2.hash_stable(hcx, hasher);
}
}
@@ -284,19 +284,19 @@ impl<T1: StableOrd, T2: StableOrd, T3: StableOrd> StableOrd for (T1, T2, T3) {
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
}
impl<T1, T2, T3, T4, CTX> HashStable<CTX> for (T1, T2, T3, T4)
impl<T1, T2, T3, T4, Hcx> HashStable<Hcx> for (T1, T2, T3, T4)
where
T1: HashStable<CTX>,
T2: HashStable<CTX>,
T3: HashStable<CTX>,
T4: HashStable<CTX>,
T1: HashStable<Hcx>,
T2: HashStable<Hcx>,
T3: HashStable<Hcx>,
T4: HashStable<Hcx>,
{
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
let (ref _0, ref _1, ref _2, ref _3) = *self;
_0.hash_stable(ctx, hasher);
_1.hash_stable(ctx, hasher);
_2.hash_stable(ctx, hasher);
_3.hash_stable(ctx, hasher);
_0.hash_stable(hcx, hasher);
_1.hash_stable(hcx, hasher);
_2.hash_stable(hcx, hasher);
_3.hash_stable(hcx, hasher);
}
}
@@ -311,93 +311,93 @@ impl<T1: StableOrd, T2: StableOrd, T3: StableOrd, T4: StableOrd> StableOrd for (
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
}
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for [T] {
default fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self.len().hash_stable(ctx, hasher);
impl<T: HashStable<Hcx>, Hcx> HashStable<Hcx> for [T] {
default fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.len().hash_stable(hcx, hasher);
for item in self {
item.hash_stable(ctx, hasher);
item.hash_stable(hcx, hasher);
}
}
}
impl<CTX> HashStable<CTX> for [u8] {
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self.len().hash_stable(ctx, hasher);
impl<Hcx> HashStable<Hcx> for [u8] {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.len().hash_stable(hcx, hasher);
hasher.write(self);
}
}
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for Vec<T> {
impl<T: HashStable<Hcx>, Hcx> HashStable<Hcx> for Vec<T> {
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self[..].hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self[..].hash_stable(hcx, hasher);
}
}
impl<K, V, R, CTX> HashStable<CTX> for indexmap::IndexMap<K, V, R>
impl<K, V, R, Hcx> HashStable<Hcx> for indexmap::IndexMap<K, V, R>
where
K: HashStable<CTX> + Eq + Hash,
V: HashStable<CTX>,
K: HashStable<Hcx> + Eq + Hash,
V: HashStable<Hcx>,
R: BuildHasher,
{
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self.len().hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.len().hash_stable(hcx, hasher);
for kv in self {
kv.hash_stable(ctx, hasher);
kv.hash_stable(hcx, hasher);
}
}
}
impl<K, R, CTX> HashStable<CTX> for indexmap::IndexSet<K, R>
impl<K, R, Hcx> HashStable<Hcx> for indexmap::IndexSet<K, R>
where
K: HashStable<CTX> + Eq + Hash,
K: HashStable<Hcx> + Eq + Hash,
R: BuildHasher,
{
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self.len().hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.len().hash_stable(hcx, hasher);
for key in self {
key.hash_stable(ctx, hasher);
key.hash_stable(hcx, hasher);
}
}
}
impl<A, const N: usize, CTX> HashStable<CTX> for SmallVec<[A; N]>
impl<A, const N: usize, Hcx> HashStable<Hcx> for SmallVec<[A; N]>
where
A: HashStable<CTX>,
A: HashStable<Hcx>,
{
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self[..].hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self[..].hash_stable(hcx, hasher);
}
}
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Box<T> {
impl<T: ?Sized + HashStable<Hcx>, Hcx> HashStable<Hcx> for Box<T> {
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
(**self).hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
(**self).hash_stable(hcx, hasher);
}
}
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for ::std::rc::Rc<T> {
impl<T: ?Sized + HashStable<Hcx>, Hcx> HashStable<Hcx> for ::std::rc::Rc<T> {
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
(**self).hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
(**self).hash_stable(hcx, hasher);
}
}
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for ::std::sync::Arc<T> {
impl<T: ?Sized + HashStable<Hcx>, Hcx> HashStable<Hcx> for ::std::sync::Arc<T> {
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
(**self).hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
(**self).hash_stable(hcx, hasher);
}
}
impl<CTX> HashStable<CTX> for str {
impl<Hcx> HashStable<Hcx> for str {
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self.as_bytes().hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.as_bytes().hash_stable(hcx, hasher);
}
}
@@ -409,9 +409,9 @@ impl StableOrd for &str {
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
}
impl<CTX> HashStable<CTX> for String {
impl<Hcx> HashStable<Hcx> for String {
#[inline]
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self[..].hash_stable(hcx, hasher);
}
}
@@ -424,26 +424,26 @@ impl StableOrd for String {
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
}
impl<HCX> ToStableHashKey<HCX> for String {
impl<Hcx> ToStableHashKey<Hcx> for String {
type KeyType = String;
#[inline]
fn to_stable_hash_key(&self, _: &HCX) -> Self::KeyType {
fn to_stable_hash_key(&self, _: &Hcx) -> Self::KeyType {
self.clone()
}
}
impl<HCX, T1: ToStableHashKey<HCX>, T2: ToStableHashKey<HCX>> ToStableHashKey<HCX> for (T1, T2) {
impl<Hcx, T1: ToStableHashKey<Hcx>, T2: ToStableHashKey<Hcx>> ToStableHashKey<Hcx> for (T1, T2) {
type KeyType = (T1::KeyType, T2::KeyType);
#[inline]
fn to_stable_hash_key(&self, hcx: &HCX) -> Self::KeyType {
fn to_stable_hash_key(&self, hcx: &Hcx) -> Self::KeyType {
(self.0.to_stable_hash_key(hcx), self.1.to_stable_hash_key(hcx))
}
}
impl<CTX> HashStable<CTX> for bool {
impl<Hcx> HashStable<Hcx> for bool {
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
(if *self { 1u8 } else { 0u8 }).hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
(if *self { 1u8 } else { 0u8 }).hash_stable(hcx, hasher);
}
}
@@ -454,17 +454,17 @@ impl StableOrd for bool {
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
}
impl<T, CTX> HashStable<CTX> for Option<T>
impl<T, Hcx> HashStable<Hcx> for Option<T>
where
T: HashStable<CTX>,
T: HashStable<Hcx>,
{
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
if let Some(ref value) = *self {
1u8.hash_stable(ctx, hasher);
value.hash_stable(ctx, hasher);
1u8.hash_stable(hcx, hasher);
value.hash_stable(hcx, hasher);
} else {
0u8.hash_stable(ctx, hasher);
0u8.hash_stable(hcx, hasher);
}
}
}
@@ -476,81 +476,81 @@ impl<T: StableOrd> StableOrd for Option<T> {
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
}
impl<T1, T2, CTX> HashStable<CTX> for Result<T1, T2>
impl<T1, T2, Hcx> HashStable<Hcx> for Result<T1, T2>
where
T1: HashStable<CTX>,
T2: HashStable<CTX>,
T1: HashStable<Hcx>,
T2: HashStable<Hcx>,
{
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
mem::discriminant(self).hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
mem::discriminant(self).hash_stable(hcx, hasher);
match *self {
Ok(ref x) => x.hash_stable(ctx, hasher),
Err(ref x) => x.hash_stable(ctx, hasher),
Ok(ref x) => x.hash_stable(hcx, hasher),
Err(ref x) => x.hash_stable(hcx, hasher),
}
}
}
impl<'a, T, CTX> HashStable<CTX> for &'a T
impl<'a, T, Hcx> HashStable<Hcx> for &'a T
where
T: HashStable<CTX> + ?Sized,
T: HashStable<Hcx> + ?Sized,
{
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
(**self).hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
(**self).hash_stable(hcx, hasher);
}
}
impl<T, CTX> HashStable<CTX> for ::std::mem::Discriminant<T> {
impl<T, Hcx> HashStable<Hcx> for ::std::mem::Discriminant<T> {
#[inline]
fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) {
::std::hash::Hash::hash(self, hasher);
}
}
impl<T, CTX> HashStable<CTX> for ::std::ops::RangeInclusive<T>
impl<T, Hcx> HashStable<Hcx> for ::std::ops::RangeInclusive<T>
where
T: HashStable<CTX>,
T: HashStable<Hcx>,
{
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self.start().hash_stable(ctx, hasher);
self.end().hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.start().hash_stable(hcx, hasher);
self.end().hash_stable(hcx, hasher);
}
}
impl<I: Idx, T, CTX> HashStable<CTX> for IndexSlice<I, T>
impl<I: Idx, T, Hcx> HashStable<Hcx> for IndexSlice<I, T>
where
T: HashStable<CTX>,
T: HashStable<Hcx>,
{
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self.len().hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.len().hash_stable(hcx, hasher);
for v in &self.raw {
v.hash_stable(ctx, hasher);
v.hash_stable(hcx, hasher);
}
}
}
impl<I: Idx, T, CTX> HashStable<CTX> for IndexVec<I, T>
impl<I: Idx, T, Hcx> HashStable<Hcx> for IndexVec<I, T>
where
T: HashStable<CTX>,
T: HashStable<Hcx>,
{
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self.len().hash_stable(ctx, hasher);
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.len().hash_stable(hcx, hasher);
for v in &self.raw {
v.hash_stable(ctx, hasher);
v.hash_stable(hcx, hasher);
}
}
}
impl<I: Idx, CTX> HashStable<CTX> for DenseBitSet<I> {
fn hash_stable(&self, _ctx: &mut CTX, hasher: &mut StableHasher) {
impl<I: Idx, Hcx> HashStable<Hcx> for DenseBitSet<I> {
fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) {
::std::hash::Hash::hash(self, hasher);
}
}
impl<R: Idx, C: Idx, CTX> HashStable<CTX> for bit_set::BitMatrix<R, C> {
fn hash_stable(&self, _ctx: &mut CTX, hasher: &mut StableHasher) {
impl<R: Idx, C: Idx, Hcx> HashStable<Hcx> for bit_set::BitMatrix<R, C> {
fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) {
::std::hash::Hash::hash(self, hasher);
}
}
@@ -563,15 +563,15 @@ fn hash_stable(&self, _ctx: &mut CTX, hasher: &mut StableHasher) {
// It is not safe to implement HashStable for HashSet, HashMap or any other collection type
// with unstable but observable iteration order.
// See https://github.com/rust-lang/compiler-team/issues/533 for further information.
impl<V, HCX> !HashStable<HCX> for std::collections::HashSet<V> {}
impl<K, V, HCX> !HashStable<HCX> for std::collections::HashMap<K, V> {}
impl<V, Hcx> !HashStable<Hcx> for std::collections::HashSet<V> {}
impl<K, V, Hcx> !HashStable<Hcx> for std::collections::HashMap<K, V> {}
impl<K, V, HCX> HashStable<HCX> for ::std::collections::BTreeMap<K, V>
impl<K, V, Hcx> HashStable<Hcx> for ::std::collections::BTreeMap<K, V>
where
K: HashStable<HCX> + StableOrd,
V: HashStable<HCX>,
K: HashStable<Hcx> + StableOrd,
V: HashStable<Hcx>,
{
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.len().hash_stable(hcx, hasher);
for entry in self.iter() {
entry.hash_stable(hcx, hasher);
@@ -579,11 +579,11 @@ fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
}
}
impl<K, HCX> HashStable<HCX> for ::std::collections::BTreeSet<K>
impl<K, Hcx> HashStable<Hcx> for ::std::collections::BTreeSet<K>
where
K: HashStable<HCX> + StableOrd,
K: HashStable<Hcx> + StableOrd,
{
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.len().hash_stable(hcx, hasher);
for entry in self.iter() {
entry.hash_stable(hcx, hasher);
@@ -44,8 +44,8 @@ struct Foo {
b: $ty,
}
impl<CTX> HashStable<CTX> for Foo {
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
impl<Hcx> HashStable<Hcx> for Foo {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.a.hash_stable(hcx, hasher);
self.b.hash_stable(hcx, hasher);
}
+2 -2
View File
@@ -71,8 +71,8 @@ pub fn is_stolen(&self) -> bool {
}
}
impl<CTX, T: HashStable<CTX>> HashStable<CTX> for Steal<T> {
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
impl<Hcx, T: HashStable<Hcx>> HashStable<Hcx> for Steal<T> {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.borrow().hash_stable(hcx, hasher);
}
}
@@ -262,12 +262,12 @@ fn hash<H: Hasher>(&self, state: &mut H) {
}
}
impl<'a, P, T, HCX> HashStable<HCX> for TaggedRef<'a, P, T>
impl<'a, P, T, Hcx> HashStable<Hcx> for TaggedRef<'a, P, T>
where
P: HashStable<HCX> + Aligned + ?Sized,
T: Tag + HashStable<HCX>,
P: HashStable<Hcx> + Aligned + ?Sized,
T: Tag + HashStable<Hcx>,
{
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.pointer().hash_stable(hcx, hasher);
self.tag().hash_stable(hcx, hasher);
}
@@ -32,8 +32,8 @@ unsafe fn from_usize(tag: usize) -> Self {
}
}
impl<HCX> crate::stable_hasher::HashStable<HCX> for Tag2 {
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut crate::stable_hasher::StableHasher) {
impl<Hcx> crate::stable_hasher::HashStable<Hcx> for Tag2 {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut crate::stable_hasher::StableHasher) {
(*self as u8).hash_stable(hcx, hasher);
}
}
+26 -26
View File
@@ -143,9 +143,9 @@ pub fn copied(self) -> UnordItems<T, impl Iterator<Item = T>> {
impl<T, I: Iterator<Item = T>> UnordItems<T, I> {
#[inline]
pub fn into_sorted<HCX>(self, hcx: &HCX) -> Vec<T>
pub fn into_sorted<Hcx>(self, hcx: &Hcx) -> Vec<T>
where
T: ToStableHashKey<HCX>,
T: ToStableHashKey<Hcx>,
{
self.collect_sorted(hcx, true)
}
@@ -168,9 +168,9 @@ pub fn into_sorted_stable_ord_by_key<K, C>(self, project_to_key: C) -> Vec<T>
}
#[inline]
pub fn collect_sorted<HCX, C>(self, hcx: &HCX, cache_sort_key: bool) -> C
pub fn collect_sorted<Hcx, C>(self, hcx: &Hcx, cache_sort_key: bool) -> C
where
T: ToStableHashKey<HCX>,
T: ToStableHashKey<Hcx>,
C: FromIterator<T> + BorrowMut<[T]>,
{
let mut items: C = self.0.collect();
@@ -315,9 +315,9 @@ pub fn into_items(self) -> UnordItems<V, impl Iterator<Item = V>> {
/// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation
/// for `V` is expensive (e.g. a `DefId -> DefPathHash` lookup).
#[inline]
pub fn to_sorted<HCX>(&self, hcx: &HCX, cache_sort_key: bool) -> Vec<&V>
pub fn to_sorted<Hcx>(&self, hcx: &Hcx, cache_sort_key: bool) -> Vec<&V>
where
V: ToStableHashKey<HCX>,
V: ToStableHashKey<Hcx>,
{
to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&x| x)
}
@@ -357,9 +357,9 @@ pub fn into_sorted_stable_ord(self) -> Vec<V>
/// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation
/// for `V` is expensive (e.g. a `DefId -> DefPathHash` lookup).
#[inline]
pub fn into_sorted<HCX>(self, hcx: &HCX, cache_sort_key: bool) -> Vec<V>
pub fn into_sorted<Hcx>(self, hcx: &Hcx, cache_sort_key: bool) -> Vec<V>
where
V: ToStableHashKey<HCX>,
V: ToStableHashKey<Hcx>,
{
to_sorted_vec(hcx, self.inner.into_iter(), cache_sort_key, |x| x)
}
@@ -415,9 +415,9 @@ fn from(value: UnordItems<V, I>) -> Self {
}
}
impl<HCX, V: Hash + Eq + HashStable<HCX>> HashStable<HCX> for UnordSet<V> {
impl<Hcx, V: Hash + Eq + HashStable<Hcx>> HashStable<Hcx> for UnordSet<V> {
#[inline]
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
hash_iter_order_independent(self.inner.iter(), hcx, hasher);
}
}
@@ -555,9 +555,9 @@ pub fn keys(&self) -> UnordItems<&K, impl Iterator<Item = &K>> {
/// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation
/// for `K` is expensive (e.g. a `DefId -> DefPathHash` lookup).
#[inline]
pub fn to_sorted<HCX>(&self, hcx: &HCX, cache_sort_key: bool) -> Vec<(&K, &V)>
pub fn to_sorted<Hcx>(&self, hcx: &Hcx, cache_sort_key: bool) -> Vec<(&K, &V)>
where
K: ToStableHashKey<HCX>,
K: ToStableHashKey<Hcx>,
{
to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&(k, _)| k)
}
@@ -582,9 +582,9 @@ pub fn to_sorted_stable_ord(&self) -> Vec<(&K, &V)>
/// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation
/// for `K` is expensive (e.g. a `DefId -> DefPathHash` lookup).
#[inline]
pub fn into_sorted<HCX>(self, hcx: &HCX, cache_sort_key: bool) -> Vec<(K, V)>
pub fn into_sorted<Hcx>(self, hcx: &Hcx, cache_sort_key: bool) -> Vec<(K, V)>
where
K: ToStableHashKey<HCX>,
K: ToStableHashKey<Hcx>,
{
to_sorted_vec(hcx, self.inner.into_iter(), cache_sort_key, |(k, _)| k)
}
@@ -610,9 +610,9 @@ pub fn into_sorted_stable_ord(self) -> Vec<(K, V)>
/// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation
/// for `K` is expensive (e.g. a `DefId -> DefPathHash` lookup).
#[inline]
pub fn values_sorted<HCX>(&self, hcx: &HCX, cache_sort_key: bool) -> impl Iterator<Item = &V>
pub fn values_sorted<Hcx>(&self, hcx: &Hcx, cache_sort_key: bool) -> impl Iterator<Item = &V>
where
K: ToStableHashKey<HCX>,
K: ToStableHashKey<Hcx>,
{
to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&(k, _)| k)
.into_iter()
@@ -638,9 +638,9 @@ fn index(&self, key: &Q) -> &V {
}
}
impl<HCX, K: Hash + Eq + HashStable<HCX>, V: HashStable<HCX>> HashStable<HCX> for UnordMap<K, V> {
impl<Hcx, K: Hash + Eq + HashStable<Hcx>, V: HashStable<Hcx>> HashStable<Hcx> for UnordMap<K, V> {
#[inline]
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
hash_iter_order_independent(self.inner.iter(), hcx, hasher);
}
}
@@ -701,23 +701,23 @@ fn from(value: UnordItems<T, I>) -> Self {
}
}
impl<HCX, V: Hash + Eq + HashStable<HCX>> HashStable<HCX> for UnordBag<V> {
impl<Hcx, V: Hash + Eq + HashStable<Hcx>> HashStable<Hcx> for UnordBag<V> {
#[inline]
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
hash_iter_order_independent(self.inner.iter(), hcx, hasher);
}
}
#[inline]
fn to_sorted_vec<HCX, T, K, I>(
hcx: &HCX,
fn to_sorted_vec<Hcx, T, K, I>(
hcx: &Hcx,
iter: I,
cache_sort_key: bool,
extract_key: fn(&T) -> &K,
) -> Vec<T>
where
I: Iterator<Item = T>,
K: ToStableHashKey<HCX>,
K: ToStableHashKey<Hcx>,
{
let mut items: Vec<T> = iter.collect();
if cache_sort_key {
@@ -730,12 +730,12 @@ fn to_sorted_vec<HCX, T, K, I>(
}
fn hash_iter_order_independent<
HCX,
T: HashStable<HCX>,
Hcx,
T: HashStable<Hcx>,
I: Iterator<Item = T> + ExactSizeIterator,
>(
mut it: I,
hcx: &mut HCX,
hcx: &mut Hcx,
hasher: &mut StableHasher,
) {
let len = it.len();
+2 -2
View File
@@ -712,11 +712,11 @@ fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
}
}
impl<CTX: crate::HashStableContext> ToStableHashKey<CTX> for Namespace {
impl<Hcx: crate::HashStableContext> ToStableHashKey<Hcx> for Namespace {
type KeyType = Namespace;
#[inline]
fn to_stable_hash_key(&self, _: &CTX) -> Namespace {
fn to_stable_hash_key(&self, _: &Hcx) -> Namespace {
*self
}
}
+2 -2
View File
@@ -144,8 +144,8 @@ pub fn $method(&self) -> Option<DefId> {
}
}
impl<CTX> HashStable<CTX> for LangItem {
fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher) {
impl<Hcx> HashStable<Hcx> for LangItem {
fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) {
::std::hash::Hash::hash(self, hasher);
}
}
+8 -8
View File
@@ -54,18 +54,18 @@ fn index(self) -> usize {
}
}
impl<CTX: HashStableContext> HashStable<CTX> for OwnerId {
impl<Hcx: HashStableContext> HashStable<Hcx> for OwnerId {
#[inline]
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.to_stable_hash_key(hcx).hash_stable(hcx, hasher);
}
}
impl<CTX: HashStableContext> ToStableHashKey<CTX> for OwnerId {
impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for OwnerId {
type KeyType = DefPathHash;
#[inline]
fn to_stable_hash_key(&self, hcx: &CTX) -> DefPathHash {
fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash {
hcx.def_path_hash(self.to_def_id())
}
}
@@ -176,21 +176,21 @@ impl StableOrd for ItemLocalId {
pub const CRATE_OWNER_ID: OwnerId = OwnerId { def_id: CRATE_DEF_ID };
impl<CTX: rustc_span::HashStableContext> ToStableHashKey<CTX> for HirId {
impl<Hcx: rustc_span::HashStableContext> ToStableHashKey<Hcx> for HirId {
type KeyType = (DefPathHash, ItemLocalId);
#[inline]
fn to_stable_hash_key(&self, hcx: &CTX) -> (DefPathHash, ItemLocalId) {
fn to_stable_hash_key(&self, hcx: &Hcx) -> (DefPathHash, ItemLocalId) {
let def_path_hash = self.owner.def_id.to_stable_hash_key(hcx);
(def_path_hash, self.local_id)
}
}
impl<CTX: HashStableContext> ToStableHashKey<CTX> for ItemLocalId {
impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for ItemLocalId {
type KeyType = ItemLocalId;
#[inline]
fn to_stable_hash_key(&self, _: &CTX) -> ItemLocalId {
fn to_stable_hash_key(&self, _: &Hcx) -> ItemLocalId {
*self
}
}
+2 -2
View File
@@ -174,8 +174,8 @@ fn hash_stable(&self, hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx
} else if stable_hash_generic || stable_hash_no_context {
quote! {
#gate_rustc_only
impl<CTX> ::rustc_data_structures::stable_hasher::HashStable<CTX> for #name {
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) {
impl<Hcx> ::rustc_data_structures::stable_hasher::HashStable<Hcx> for #name {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) {
self.as_u32().hash_stable(hcx, hasher)
}
}
+8 -8
View File
@@ -138,9 +138,9 @@ pub fn set_lint_index(&mut self, new_lint_index: Option<u16>) {
}
}
impl<HCX: HashStableContext> HashStable<HCX> for LintExpectationId {
impl<Hcx: HashStableContext> HashStable<Hcx> for LintExpectationId {
#[inline]
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
match self {
LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => {
hir_id.hash_stable(hcx, hasher);
@@ -156,11 +156,11 @@ fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
}
}
impl<HCX: HashStableContext> ToStableHashKey<HCX> for LintExpectationId {
impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for LintExpectationId {
type KeyType = (DefPathHash, ItemLocalId, u16, u16);
#[inline]
fn to_stable_hash_key(&self, hcx: &HCX) -> Self::KeyType {
fn to_stable_hash_key(&self, hcx: &Hcx) -> Self::KeyType {
match self {
LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => {
let (def_path_hash, lint_idx) = hir_id.to_stable_hash_key(hcx);
@@ -621,18 +621,18 @@ pub fn to_string(&self) -> String {
}
}
impl<HCX> HashStable<HCX> for LintId {
impl<Hcx> HashStable<Hcx> for LintId {
#[inline]
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.lint_name_raw().hash_stable(hcx, hasher);
}
}
impl<HCX> ToStableHashKey<HCX> for LintId {
impl<Hcx> ToStableHashKey<Hcx> for LintId {
type KeyType = &'static str;
#[inline]
fn to_stable_hash_key(&self, _: &HCX) -> &'static str {
fn to_stable_hash_key(&self, _: &Hcx) -> &'static str {
self.lint_name_raw()
}
}
@@ -251,10 +251,10 @@ pub fn from_cgu_name(cgu_name: &str) -> WorkProductId {
WorkProductId { hash: hasher.finish() }
}
}
impl<HCX> ToStableHashKey<HCX> for WorkProductId {
impl<Hcx> ToStableHashKey<Hcx> for WorkProductId {
type KeyType = Fingerprint;
#[inline]
fn to_stable_hash_key(&self, _: &HCX) -> Self::KeyType {
fn to_stable_hash_key(&self, _: &Hcx) -> Self::KeyType {
self.hash
}
}
@@ -171,7 +171,7 @@ fn decode(_: &mut D) -> Self {
}
}
impl<CTX> HashStable<CTX> for Cache {
impl<Hcx> HashStable<Hcx> for Cache {
#[inline]
fn hash_stable(&self, _: &mut CTX, _: &mut StableHasher) {}
fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) {}
}
+2 -2
View File
@@ -151,8 +151,8 @@ pub struct ScalarInt {
// Cannot derive these, as the derives take references to the fields, and we
// can't take references to fields of packed structs.
impl<CTX> crate::ty::HashStable<CTX> for ScalarInt {
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut crate::ty::StableHasher) {
impl<Hcx> crate::ty::HashStable<Hcx> for ScalarInt {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut crate::ty::StableHasher) {
// Using a block `{self.data}` here to force a copy instead of using `self.data`
// directly, because `hash_stable` takes `&self` and would thus borrow `self.data`.
// Since `Self` is a packed struct, that would create a possibly unaligned reference,
+2 -2
View File
@@ -607,7 +607,7 @@ pub struct TyCtxtFeed<'tcx, KEY: Copy> {
/// Never return a `Feed` from a query. Only queries that create a `DefId` are
/// allowed to feed queries for that `DefId`.
impl<KEY: Copy, CTX> !HashStable<CTX> for TyCtxtFeed<'_, KEY> {}
impl<KEY: Copy, Hcx> !HashStable<Hcx> for TyCtxtFeed<'_, KEY> {}
/// The same as `TyCtxtFeed`, but does not contain a `TyCtxt`.
/// Use this to pass around when you have a `TyCtxt` elsewhere.
@@ -622,7 +622,7 @@ pub struct Feed<'tcx, KEY: Copy> {
/// Never return a `Feed` from a query. Only queries that create a `DefId` are
/// allowed to feed queries for that `DefId`.
impl<KEY: Copy, CTX> !HashStable<CTX> for Feed<'_, KEY> {}
impl<KEY: Copy, Hcx> !HashStable<Hcx> for Feed<'_, KEY> {}
impl<T: fmt::Debug + Copy> fmt::Debug for Feed<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+2 -2
View File
@@ -636,10 +636,10 @@ impl StableOrd for OutputType {
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
}
impl<HCX: HashStableContext> ToStableHashKey<HCX> for OutputType {
impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for OutputType {
type KeyType = Self;
fn to_stable_hash_key(&self, _: &HCX) -> Self::KeyType {
fn to_stable_hash_key(&self, _: &Hcx) -> Self::KeyType {
*self
}
}
+4
View File
@@ -530,3 +530,7 @@ pub(crate) struct UnexpectedBuiltinCfg {
#[derive(Diagnostic)]
#[diag("ThinLTO is not supported by the codegen backend, using fat LTO instead")]
pub(crate) struct ThinLtoNotSupportedByBackend;
#[derive(Diagnostic)]
#[diag("`-Zpacked-stack` is only supported on s390x")]
pub(crate) struct UnsupportedPackedStack;
+2
View File
@@ -2557,6 +2557,8 @@ pub(crate) fn parse_assert_incr_state(
"pass `-install_name @rpath/...` to the macOS linker (default: no)"),
packed_bundled_libs: bool = (false, parse_bool, [TRACKED],
"change rlib format to store native libraries as archives"),
packed_stack: bool = (false, parse_bool, [TRACKED],
"use packed stack frames (s390x only) (default: no)"),
panic_abort_tests: bool = (false, parse_bool, [TRACKED],
"support compiling tests with panic=abort (default: no)"),
panic_in_drop: PanicStrategy = (PanicStrategy::Unwind, parse_panic_strategy, [TRACKED],
+6
View File
@@ -1363,6 +1363,12 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
}
}
}
if sess.opts.unstable_opts.packed_stack {
if sess.target.arch != Arch::S390x {
sess.dcx().emit_err(errors::UnsupportedPackedStack);
}
}
}
/// Holds data on the current incremental compilation session, if there is one.
+14 -14
View File
@@ -402,59 +402,59 @@ fn decode(d: &mut D) -> LocalDefId {
LocalDefId
);
impl<CTX: HashStableContext> HashStable<CTX> for DefId {
impl<Hcx: HashStableContext> HashStable<Hcx> for DefId {
#[inline]
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
hcx.def_path_hash(*self).hash_stable(hcx, hasher);
}
}
impl<CTX: HashStableContext> HashStable<CTX> for LocalDefId {
impl<Hcx: HashStableContext> HashStable<Hcx> for LocalDefId {
#[inline]
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
hcx.def_path_hash(self.to_def_id()).local_hash().hash_stable(hcx, hasher);
}
}
impl<CTX: HashStableContext> HashStable<CTX> for CrateNum {
impl<Hcx: HashStableContext> HashStable<Hcx> for CrateNum {
#[inline]
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.as_def_id().to_stable_hash_key(hcx).stable_crate_id().hash_stable(hcx, hasher);
}
}
impl<CTX: HashStableContext> ToStableHashKey<CTX> for DefId {
impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for DefId {
type KeyType = DefPathHash;
#[inline]
fn to_stable_hash_key(&self, hcx: &CTX) -> DefPathHash {
fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash {
hcx.def_path_hash(*self)
}
}
impl<CTX: HashStableContext> ToStableHashKey<CTX> for LocalDefId {
impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for LocalDefId {
type KeyType = DefPathHash;
#[inline]
fn to_stable_hash_key(&self, hcx: &CTX) -> DefPathHash {
fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash {
hcx.def_path_hash(self.to_def_id())
}
}
impl<CTX: HashStableContext> ToStableHashKey<CTX> for CrateNum {
impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for CrateNum {
type KeyType = DefPathHash;
#[inline]
fn to_stable_hash_key(&self, hcx: &CTX) -> DefPathHash {
fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash {
self.as_def_id().to_stable_hash_key(hcx)
}
}
impl<CTX: HashStableContext> ToStableHashKey<CTX> for DefPathHash {
impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for DefPathHash {
type KeyType = DefPathHash;
#[inline]
fn to_stable_hash_key(&self, _: &CTX) -> DefPathHash {
fn to_stable_hash_key(&self, _: &Hcx) -> DefPathHash {
*self
}
}
+25 -25
View File
@@ -207,9 +207,9 @@ pub fn fresh_empty() -> LocalExpnId {
})
}
pub fn fresh(mut expn_data: ExpnData, ctx: impl HashStableContext) -> LocalExpnId {
pub fn fresh(mut expn_data: ExpnData, hcx: impl HashStableContext) -> LocalExpnId {
debug_assert_eq!(expn_data.parent.krate, LOCAL_CRATE);
let expn_hash = update_disambiguator(&mut expn_data, ctx);
let expn_hash = update_disambiguator(&mut expn_data, hcx);
HygieneData::with(|data| {
let expn_id = data.local_expn_data.push(Some(expn_data));
let _eid = data.local_expn_hashes.push(expn_hash);
@@ -231,9 +231,9 @@ pub fn to_expn_id(self) -> ExpnId {
}
#[inline]
pub fn set_expn_data(self, mut expn_data: ExpnData, ctx: impl HashStableContext) {
pub fn set_expn_data(self, mut expn_data: ExpnData, hcx: impl HashStableContext) {
debug_assert_eq!(expn_data.parent.krate, LOCAL_CRATE);
let expn_hash = update_disambiguator(&mut expn_data, ctx);
let expn_hash = update_disambiguator(&mut expn_data, hcx);
HygieneData::with(|data| {
let old_expn_data = &mut data.local_expn_data[self];
assert!(old_expn_data.is_none(), "expansion data is reset for an expansion ID");
@@ -950,13 +950,13 @@ pub fn mark_with_reason(
allow_internal_unstable: Option<Arc<[Symbol]>>,
reason: DesugaringKind,
edition: Edition,
ctx: impl HashStableContext,
hcx: impl HashStableContext,
) -> Span {
let expn_data = ExpnData {
allow_internal_unstable,
..ExpnData::default(ExpnKind::Desugaring(reason), self, edition, None, None)
};
let expn_id = LocalExpnId::fresh(expn_data, ctx);
let expn_id = LocalExpnId::fresh(expn_data, hcx);
self.apply_mark(expn_id.to_expn_id(), Transparency::Transparent)
}
}
@@ -1102,9 +1102,9 @@ pub fn is_root(&self) -> bool {
}
#[inline]
fn hash_expn(&self, ctx: &mut impl HashStableContext) -> Hash64 {
fn hash_expn(&self, hcx: &mut impl HashStableContext) -> Hash64 {
let mut hasher = StableHasher::new();
self.hash_stable(ctx, &mut hasher);
self.hash_stable(hcx, &mut hasher);
hasher.finish()
}
}
@@ -1482,11 +1482,11 @@ pub fn raw_encode_syntax_context(
/// `set_expn_data`). It is *not* called for foreign `ExpnId`s deserialized
/// from another crate's metadata - since `ExpnHash` includes the stable crate id,
/// collisions are only possible between `ExpnId`s within the same crate.
fn update_disambiguator(expn_data: &mut ExpnData, mut ctx: impl HashStableContext) -> ExpnHash {
fn update_disambiguator(expn_data: &mut ExpnData, mut hcx: impl HashStableContext) -> ExpnHash {
// This disambiguator should not have been set yet.
assert_eq!(expn_data.disambiguator, 0, "Already set disambiguator for ExpnData: {expn_data:?}");
ctx.assert_default_hashing_controls("ExpnData (disambiguator)");
let mut expn_hash = expn_data.hash_expn(&mut ctx);
hcx.assert_default_hashing_controls("ExpnData (disambiguator)");
let mut expn_hash = expn_data.hash_expn(&mut hcx);
let disambiguator = HygieneData::with(|data| {
// If this is the first ExpnData with a given hash, then keep our
@@ -1501,7 +1501,7 @@ fn update_disambiguator(expn_data: &mut ExpnData, mut ctx: impl HashStableContex
debug!("Set disambiguator for expn_data={:?} expn_hash={:?}", expn_data, expn_hash);
expn_data.disambiguator = disambiguator;
expn_hash = expn_data.hash_expn(&mut ctx);
expn_hash = expn_data.hash_expn(&mut hcx);
// Verify that the new disambiguator makes the hash unique
#[cfg(debug_assertions)]
@@ -1514,28 +1514,28 @@ fn update_disambiguator(expn_data: &mut ExpnData, mut ctx: impl HashStableContex
});
}
ExpnHash::new(ctx.def_path_hash(LOCAL_CRATE.as_def_id()).stable_crate_id(), expn_hash)
ExpnHash::new(hcx.def_path_hash(LOCAL_CRATE.as_def_id()).stable_crate_id(), expn_hash)
}
impl<CTX: HashStableContext> HashStable<CTX> for SyntaxContext {
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
impl<Hcx: HashStableContext> HashStable<Hcx> for SyntaxContext {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
const TAG_EXPANSION: u8 = 0;
const TAG_NO_EXPANSION: u8 = 1;
if self.is_root() {
TAG_NO_EXPANSION.hash_stable(ctx, hasher);
TAG_NO_EXPANSION.hash_stable(hcx, hasher);
} else {
TAG_EXPANSION.hash_stable(ctx, hasher);
TAG_EXPANSION.hash_stable(hcx, hasher);
let (expn_id, transparency) = self.outer_mark();
expn_id.hash_stable(ctx, hasher);
transparency.hash_stable(ctx, hasher);
expn_id.hash_stable(hcx, hasher);
transparency.hash_stable(hcx, hasher);
}
}
}
impl<CTX: HashStableContext> HashStable<CTX> for ExpnId {
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
ctx.assert_default_hashing_controls("ExpnId");
impl<Hcx: HashStableContext> HashStable<Hcx> for ExpnId {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
hcx.assert_default_hashing_controls("ExpnId");
let hash = if *self == ExpnId::root() {
// Avoid fetching TLS storage for a trivial often-used value.
Fingerprint::ZERO
@@ -1543,12 +1543,12 @@ fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self.expn_hash().0
};
hash.hash_stable(ctx, hasher);
hash.hash_stable(hcx, hasher);
}
}
impl<CTX: HashStableContext> HashStable<CTX> for LocalExpnId {
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
impl<Hcx: HashStableContext> HashStable<Hcx> for LocalExpnId {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.to_expn_id().hash_stable(hcx, hasher);
}
}
+4 -4
View File
@@ -2812,13 +2812,13 @@ pub trait HashStableContext {
fn assert_default_hashing_controls(&self, msg: &str);
}
impl<CTX> HashStable<CTX> for Span
impl<Hcx> HashStable<Hcx> for Span
where
CTX: HashStableContext,
Hcx: HashStableContext,
{
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
// `span_hash_stable` does all the work.
ctx.span_hash_stable(*self, hasher)
hcx.span_hash_stable(*self, hasher)
}
}
+8 -6
View File
@@ -505,6 +505,7 @@
avx512bw,
avx512f,
await_macro,
backchain,
bang,
begin_panic,
bench,
@@ -1919,6 +1920,7 @@
slice_len_fn,
slice_patterns,
slicing_syntax,
soft_float: "soft-float",
sparc,
sparc64,
sparc_target_feature,
@@ -2599,17 +2601,17 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
impl<CTX> HashStable<CTX> for Symbol {
impl<Hcx> HashStable<Hcx> for Symbol {
#[inline]
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.as_str().hash_stable(hcx, hasher);
}
}
impl<CTX> ToStableHashKey<CTX> for Symbol {
impl<Hcx> ToStableHashKey<Hcx> for Symbol {
type KeyType = String;
#[inline]
fn to_stable_hash_key(&self, _: &CTX) -> String {
fn to_stable_hash_key(&self, _: &Hcx) -> String {
self.as_str().to_string()
}
}
@@ -2659,9 +2661,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
impl<CTX> HashStable<CTX> for ByteSymbol {
impl<Hcx> HashStable<Hcx> for ByteSymbol {
#[inline]
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
self.as_byte_str().hash_stable(hcx, hasher);
}
}
+2 -2
View File
@@ -117,8 +117,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
#[cfg(feature = "nightly")]
impl<CTX> HashStable<CTX> for InferConst {
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
impl<Hcx> HashStable<Hcx> for InferConst {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
match self {
InferConst::Var(_) => {
panic!("const variables should not be hashed: {self:?}")
+3 -3
View File
@@ -50,13 +50,13 @@ pub enum SimplifiedType<DefId> {
}
#[cfg(feature = "nightly")]
impl<HCX: Clone, DefId: HashStable<HCX>> ToStableHashKey<HCX> for SimplifiedType<DefId> {
impl<Hcx: Clone, DefId: HashStable<Hcx>> ToStableHashKey<Hcx> for SimplifiedType<DefId> {
type KeyType = Fingerprint;
#[inline]
fn to_stable_hash_key(&self, hcx: &HCX) -> Fingerprint {
fn to_stable_hash_key(&self, hcx: &Hcx) -> Fingerprint {
let mut hasher = StableHasher::new();
let mut hcx: HCX = hcx.clone();
let mut hcx: Hcx = hcx.clone();
self.hash_stable(&mut hcx, &mut hasher);
hasher.finish()
}
+6 -6
View File
@@ -217,15 +217,15 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[cfg(feature = "nightly")]
// This is not a derived impl because a derive would require `I: HashStable`
impl<CTX, I: Interner> HashStable<CTX> for RegionKind<I>
impl<Hcx, I: Interner> HashStable<Hcx> for RegionKind<I>
where
I::EarlyParamRegion: HashStable<CTX>,
I::LateParamRegion: HashStable<CTX>,
I::DefId: HashStable<CTX>,
I::Symbol: HashStable<CTX>,
I::EarlyParamRegion: HashStable<Hcx>,
I::LateParamRegion: HashStable<Hcx>,
I::DefId: HashStable<Hcx>,
I::Symbol: HashStable<Hcx>,
{
#[inline]
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
std::mem::discriminant(self).hash_stable(hcx, hasher);
match self {
ReErased | ReStatic | ReError(_) => {
+2 -2
View File
@@ -97,8 +97,8 @@ fn hash<H: Hasher>(&self, s: &mut H) {
}
#[cfg(feature = "nightly")]
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for WithCachedTypeInfo<T> {
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
impl<T: HashStable<Hcx>, Hcx> HashStable<Hcx> for WithCachedTypeInfo<T> {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
if self.stable_hash == Fingerprint::ZERO || cfg!(debug_assertions) {
// No cached hash available. This can only mean that incremental is disabled.
// We don't cache stable hashes in non-incremental mode, because they are used
+4 -4
View File
@@ -687,15 +687,15 @@ fn tag() -> &'static str {
}
#[cfg(feature = "nightly")]
impl<CTX> HashStable<CTX> for InferTy {
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
impl<Hcx> HashStable<Hcx> for InferTy {
fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
use InferTy::*;
std::mem::discriminant(self).hash_stable(ctx, hasher);
std::mem::discriminant(self).hash_stable(hcx, hasher);
match self {
TyVar(_) | IntVar(_) | FloatVar(_) => {
panic!("type variables should not be hashed: {self:?}")
}
FreshTy(v) | FreshIntTy(v) | FreshFloatTy(v) => v.hash_stable(ctx, hasher),
FreshTy(v) | FreshIntTy(v) | FreshFloatTy(v) => v.hash_stable(hcx, hasher),
}
}
}
+2 -2
View File
@@ -146,9 +146,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.178"
version = "0.2.183"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
dependencies = [
"rustc-std-workspace-core",
]
+1 -1
View File
@@ -33,7 +33,7 @@ miniz_oxide = { version = "0.8.0", optional = true, default-features = false }
addr2line = { version = "0.25.0", optional = true, default-features = false }
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
libc = { version = "0.2.178", default-features = false, features = [
libc = { version = "0.2.183", default-features = false, features = [
'rustc-dep-of-std',
], public = true }
+6 -1
View File
@@ -1872,7 +1872,12 @@ fn file_time_to_timespec(time: Option<SystemTime>) -> io::Result<libc::timespec>
io::ErrorKind::InvalidInput,
"timestamp is too small to set as a file time",
)),
None => Ok(libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ }),
None => Ok({
let mut ts = libc::timespec::default();
ts.tv_sec = 0;
ts.tv_nsec = libc::UTIME_OMIT as _;
ts
}),
}
}
+12 -5
View File
@@ -1,3 +1,4 @@
use core::mem;
use core::num::niche_types::Nanoseconds;
use crate::io;
@@ -6,8 +7,12 @@
const NSEC_PER_SEC: u64 = 1_000_000_000;
#[allow(dead_code)] // Used for pthread condvar timeouts
pub const TIMESPEC_MAX: libc::timespec =
libc::timespec { tv_sec: <libc::time_t>::MAX, tv_nsec: 1_000_000_000 - 1 };
pub const TIMESPEC_MAX: libc::timespec = {
let mut ts = unsafe { mem::zeroed::<libc::timespec>() };
ts.tv_sec = <libc::time_t>::MAX;
ts.tv_nsec = 1_000_000_000 - 1;
ts
};
// This additional constant is only used when calling
// `libc::pthread_cond_timedwait`.
@@ -164,9 +169,11 @@ pub fn checked_sub_duration(&self, other: &Duration) -> Option<Timespec> {
#[allow(dead_code)]
pub fn to_timespec(&self) -> Option<libc::timespec> {
Some(libc::timespec {
tv_sec: self.tv_sec.try_into().ok()?,
tv_nsec: self.tv_nsec.as_inner().try_into().ok()?,
Some({
let mut ts = libc::timespec::default();
ts.tv_sec = self.tv_sec.try_into().ok()?;
ts.tv_nsec = self.tv_nsec.as_inner().try_into().ok()?;
ts
})
}
+4 -4
View File
@@ -570,10 +570,10 @@ unsafe fn nanosleep(rqtp: *const libc::timespec, rmtp: *mut libc::timespec) -> l
// nanosleep will fill in `ts` with the remaining time.
unsafe {
while secs > 0 || nsecs > 0 {
let mut ts = libc::timespec {
tv_sec: cmp::min(libc::time_t::MAX as u64, secs) as libc::time_t,
tv_nsec: nsecs,
};
let mut ts = libc::timespec::default();
ts.tv_sec = cmp::min(libc::time_t::MAX as u64, secs) as libc::time_t;
ts.tv_nsec = nsecs;
secs -= ts.tv_sec as u64;
let ts_ptr = &raw mut ts;
let r = nanosleep(ts_ptr, ts_ptr);
@@ -180,6 +180,10 @@ fn run(self, builder: &Builder<'_>) {
// Forward arguments. This may contain further arguments to the program
// after another --, so this must be at the end.
miri.args(builder.config.args());
// Add default edition for Miri tests (2021); defaulting to 2015 is often confusing.
if !builder.config.args().iter().any(|arg| arg.starts_with("--edition")) {
miri.arg("--edition=2021");
}
miri.into_cmd().run(builder);
}
@@ -0,0 +1,37 @@
//@ add-minicore
//@ revisions: enable-packedstack default-packedstack
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=3 --crate-type=lib --target=s390x-unknown-linux-gnu -Cforce-unwind-tables=no
//@ needs-llvm-components: systemz
//@[enable-packedstack] compile-flags: -Zpacked-stack
#![feature(no_core, lang_items)]
#![no_std]
#![no_core]
extern crate minicore;
use minicore::*;
extern "C" {
fn extern_func() -> i32;
}
// CHECK-LABEL: test_packedstack
#[no_mangle]
extern "C" fn test_packedstack() -> i32 {
// test the creation of call stack with and without packed-stack
// without packed-stack we always reserve a least the maximal space of 160 bytes
// default-packedstack: stmg %r14, %r15, 112(%r15)
// default-packedstack-NEXT: aghi %r15, -160
// default-packedstack-NEXT: brasl %r14, extern_func
// with packed-stack only the actually needed registers are reserved on the stack
// enable-packedstack: stmg %r14, %r15, 144(%r15)
// enable-packedstack-NEXT: aghi %r15, -16
// enable-packedstack-NEXT: brasl %r14, extern_func
unsafe {
extern_func();
}
1
// CHECK: br %r{{.*}}
}
+18
View File
@@ -0,0 +1,18 @@
//@ add-minicore
//@ compile-flags: -Copt-level=3 --crate-type=lib --target=s390x-unknown-none-softfloat -Zpacked-stack
//@ needs-llvm-components: systemz
#![feature(s390x_target_feature)]
#![crate_type = "lib"]
#![feature(no_core, lang_items)]
#![no_core]
extern crate minicore;
use minicore::*;
#[no_mangle]
pub fn test_packedstack() {
// CHECK: @test_packedstack() unnamed_addr #0
}
// CHECK: attributes #0 = { {{.*}}"packed-stack"{{.*}} }
@@ -0,0 +1,6 @@
error: `-Zpacked-stack` is incompatible with `backchain` target feature
|
= note: enabling both `-Zpacked-stack` and the `backchain` target feature is incompatible with the default s390x ABI. Switch to s390x-unknown-none-softfloat if you need both attributes
error: aborting due to 1 previous error
@@ -0,0 +1,10 @@
warning: unstable feature specified for `-Ctarget-feature`: `backchain`
|
= note: this feature is not stably supported; its behavior can change in the future
error: packedstack with backchain needs softfloat
|
= note: enabling both `-Zpacked-stack` and the `backchain` target feature is incompatible with the default s390x ABI. Switch to s390x-unknown-none-softfloat if you need both attributes
error: aborting due to 1 previous error; 1 warning emitted
@@ -0,0 +1,44 @@
//@ add-minicore
//@ revisions: wrong_arch only_packedstack backchain_attr backchain_cli with_softfloat
//@ compile-flags: -Zpacked-stack --crate-type=rlib
//@ ignore-backends: gcc
//@ [wrong_arch] compile-flags: --target=x86_64-unknown-linux-gnu
//@ [wrong_arch] should-fail
//@ [wrong_arch] needs-llvm-components: x86
//@ [only_packedstack] compile-flags: --target=s390x-unknown-linux-gnu
//@ [only_packedstack] build-pass
//@ [only_packedstack] needs-llvm-components: systemz
//@ [backchain_attr] compile-flags: --target=s390x-unknown-linux-gnu
//@ [backchain_attr] build-fail
//@ [backchain_attr] needs-llvm-components: systemz
//@ [backchain_cli] compile-flags: -Ctarget-feature=+backchain --target=s390x-unknown-linux-gnu
//@ [backchain_cli] should-fail
//@ [backchain_cli] needs-llvm-components: systemz
//@ [with_softfloat] compile-flags: -Ctarget-feature=+backchain
//@ [with_softfloat] compile-flags: --target=s390x-unknown-none-softfloat
//@ [with_softfloat] build-pass
//@ [with_softfloat] needs-llvm-components: systemz
#![feature(s390x_target_feature)]
#![crate_type = "rlib"]
#![feature(no_core,lang_items)]
#![no_core]
extern crate minicore;
use minicore::*;
#[no_mangle]
#[cfg_attr(backchain_attr,target_feature(enable = "backchain"))]
pub fn test() {
}
//[wrong_arch]~? ERROR `-Zpacked-stack` is only supported on s390x
//[backchain_cli]~? WARN unstable feature specified for `-Ctarget-feature`: `backchain`
//[backchain_cli]~? ERROR `-Zpacked-stack` is incompatible with `backchain` target feature
//[backchain_attr]~? ERROR `-Zpacked-stack` is incompatible with `backchain` target feature
//[with_softfloat]~? WARN unstable feature specified for `-Ctarget-feature`: `backchain`
@@ -0,0 +1,6 @@
warning: unstable feature specified for `-Ctarget-feature`: `backchain`
|
= note: this feature is not stably supported; its behavior can change in the future
warning: 1 warning emitted
@@ -0,0 +1,4 @@
error: `-Zpacked-stack` is only supported on s390x
error: aborting due to 1 previous error