Skip to content

Commit 27e9c99

Browse files
committed
Auto merge of #152266 - jhpratt:rollup-YUfQl73, r=jhpratt
Rollup of 4 pull requests Successful merges: - #148590 (Stabilize `atomic_try_update`and deprecate `fetch_update` starting 1.99.0) - #150522 (Stabilize new inclusive range type and iterator type) - #151576 (Stabilize `core::hint::cold_path`) - #152199 (Move `rustc_query_system::cache`.)
2 parents 56aaf58 + c9332fa commit 27e9c99

30 files changed

Lines changed: 297 additions & 344 deletions
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ use rustc_data_structures::sync::Lock;
77

88
use crate::dep_graph::{DepContext, DepNodeIndex};
99

10-
pub struct Cache<Key, Value> {
10+
pub struct WithDepNodeCache<Key, Value> {
1111
hashmap: Lock<FxHashMap<Key, WithDepNode<Value>>>,
1212
}
1313

14-
impl<Key: Clone, Value: Clone> Clone for Cache<Key, Value> {
14+
impl<Key: Clone, Value: Clone> Clone for WithDepNodeCache<Key, Value> {
1515
fn clone(&self) -> Self {
1616
Self { hashmap: Lock::new(self.hashmap.borrow().clone()) }
1717
}
1818
}
1919

20-
impl<Key, Value> Default for Cache<Key, Value> {
20+
impl<Key, Value> Default for WithDepNodeCache<Key, Value> {
2121
fn default() -> Self {
2222
Self { hashmap: Default::default() }
2323
}
2424
}
2525

26-
impl<Key: Eq + Hash, Value: Clone> Cache<Key, Value> {
26+
impl<Key: Eq + Hash, Value: Clone> WithDepNodeCache<Key, Value> {
2727
pub fn get<Tcx: DepContext>(&self, key: &Key, tcx: Tcx) -> Option<Value> {
2828
Some(self.hashmap.borrow().get(key)?.get(tcx))
2929
}

compiler/rustc_middle/src/traits/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//!
33
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html
44
5+
pub mod cache;
56
pub mod query;
67
pub mod select;
78
pub mod solve;

compiler/rustc_middle/src/traits/select.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
use rustc_errors::ErrorGuaranteed;
66
use rustc_hir::def_id::DefId;
77
use rustc_macros::{HashStable, TypeVisitable};
8-
use rustc_query_system::cache::Cache;
98
use rustc_type_ir::solve::AliasBoundKind;
109

1110
use self::EvaluationResult::*;
1211
use super::{SelectionError, SelectionResult};
12+
use crate::traits::cache::WithDepNodeCache;
1313
use crate::ty;
1414

15-
pub type SelectionCache<'tcx, ENV> =
16-
Cache<(ENV, ty::TraitPredicate<'tcx>), SelectionResult<'tcx, SelectionCandidate<'tcx>>>;
15+
pub type SelectionCache<'tcx, ENV> = WithDepNodeCache<
16+
(ENV, ty::TraitPredicate<'tcx>),
17+
SelectionResult<'tcx, SelectionCandidate<'tcx>>,
18+
>;
1719

18-
pub type EvaluationCache<'tcx, ENV> = Cache<(ENV, ty::PolyTraitPredicate<'tcx>), EvaluationResult>;
20+
pub type EvaluationCache<'tcx, ENV> =
21+
WithDepNodeCache<(ENV, ty::PolyTraitPredicate<'tcx>), EvaluationResult>;
1922

2023
/// The selection process begins by considering all impls, where
2124
/// clauses, and so forth that might resolve an obligation. Sometimes

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use rustc_hir::lang_items::LangItem;
4040
use rustc_hir::limit::Limit;
4141
use rustc_hir::{self as hir, HirId, Node, TraitCandidate, find_attr};
4242
use rustc_index::IndexVec;
43-
use rustc_query_system::cache::WithDepNode;
4443
use rustc_query_system::dep_graph::DepNodeIndex;
4544
use rustc_query_system::ich::StableHashingContext;
4645
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
@@ -71,6 +70,7 @@ use crate::query::plumbing::QuerySystem;
7170
use crate::query::{IntoQueryParam, LocalCrate, Providers, TyCtxtAt};
7271
use crate::thir::Thir;
7372
use crate::traits;
73+
use crate::traits::cache::WithDepNode;
7474
use crate::traits::solve::{
7575
self, CanonicalInput, ExternalConstraints, ExternalConstraintsData, PredefinedOpaques,
7676
QueryResult, inspect,

compiler/rustc_query_system/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(min_specialization)]
66
// tidy-alphabetical-end
77

8-
pub mod cache;
98
pub mod dep_graph;
109
mod error;
1110
pub mod ich;

library/alloc/src/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3270,7 +3270,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
32703270
// Acquire is necessary for the success case to synchronise with `Arc::new_cyclic`, when the inner
32713271
// value can be initialized after `Weak` references have already been created. In that case, we
32723272
// expect to observe the fully initialized value.
3273-
if self.inner()?.strong.fetch_update(Acquire, Relaxed, checked_increment).is_ok() {
3273+
if self.inner()?.strong.try_update(Acquire, Relaxed, checked_increment).is_ok() {
32743274
// SAFETY: pointer is not null, verified in checked_increment
32753275
unsafe { Some(Arc::from_inner_in(self.ptr, self.alloc.clone())) }
32763276
} else {

library/core/src/alloc/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use crate::{cmp, ptr};
5757
/// let mut allocated = 0;
5858
/// if self
5959
/// .remaining
60-
/// .fetch_update(Relaxed, Relaxed, |mut remaining| {
60+
/// .try_update(Relaxed, Relaxed, |mut remaining| {
6161
/// if size > remaining {
6262
/// return None;
6363
/// }

library/core/src/hint.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,6 @@ pub const fn unlikely(b: bool) -> bool {
724724
/// # Examples
725725
///
726726
/// ```
727-
/// #![feature(cold_path)]
728727
/// use core::hint::cold_path;
729728
///
730729
/// fn foo(x: &[i32]) {
@@ -750,7 +749,6 @@ pub const fn unlikely(b: bool) -> bool {
750749
/// than the branch:
751750
///
752751
/// ```
753-
/// #![feature(cold_path)]
754752
/// use core::hint::cold_path;
755753
///
756754
/// #[inline(always)]
@@ -777,7 +775,8 @@ pub const fn unlikely(b: bool) -> bool {
777775
/// }
778776
/// }
779777
/// ```
780-
#[unstable(feature = "cold_path", issue = "136873")]
778+
#[stable(feature = "cold_path", since = "CURRENT_RUSTC_VERSION")]
779+
#[rustc_const_stable(feature = "cold_path", since = "CURRENT_RUSTC_VERSION")]
781780
#[inline(always)]
782781
pub const fn cold_path() {
783782
crate::intrinsics::cold_path()

library/core/src/index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ unsafe impl<T> SliceIndex<[T]> for Clamp<ops::RangeFrom<usize>> {
315315
}
316316

317317
#[unstable(feature = "sliceindex_wrappers", issue = "146179")]
318-
unsafe impl<T> SliceIndex<[T]> for Clamp<range::RangeTo<usize>> {
318+
unsafe impl<T> SliceIndex<[T]> for Clamp<ops::RangeTo<usize>> {
319319
type Output = [T];
320320

321321
fn get(self, slice: &[T]) -> Option<&Self::Output> {
@@ -408,7 +408,7 @@ unsafe impl<T> SliceIndex<[T]> for Clamp<ops::RangeToInclusive<usize>> {
408408
}
409409

410410
#[unstable(feature = "sliceindex_wrappers", issue = "146179")]
411-
unsafe impl<T> SliceIndex<[T]> for Clamp<range::RangeFull> {
411+
unsafe impl<T> SliceIndex<[T]> for Clamp<ops::RangeFull> {
412412
type Output = [T];
413413

414414
fn get(self, slice: &[T]) -> Option<&Self::Output> {

library/core/src/intrinsics/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,7 @@ pub const unsafe fn assume(b: bool) {
409409
/// Therefore, implementations must not require the user to uphold
410410
/// any safety invariants.
411411
///
412-
/// This intrinsic does not have a stable counterpart.
413-
#[unstable(feature = "core_intrinsics", issue = "none")]
412+
/// The stabilized version of this intrinsic is [`core::hint::cold_path`].
414413
#[rustc_intrinsic]
415414
#[rustc_nounwind]
416415
#[miri::intrinsic_fallback_is_spec]

0 commit comments

Comments
 (0)