Skip to content

Commit 9df8317

Browse files
committed
Auto merge of rust-lang#154289 - jhpratt:rollup-JFDweJT, r=jhpratt
Rollup of 10 pull requests Successful merges: - rust-lang#153964 (Fix `doc_cfg` not working as expected on trait impls) - rust-lang#153979 (Rename various query cycle things.) - rust-lang#154132 (Add missing num_internals feature gate to coretests/benches) - rust-lang#154153 (core: Implement `unchecked_funnel_{shl,shr}`) - rust-lang#154236 (Clean up query-forcing functions) - rust-lang#154252 (Don't store current-session side effects in `OnDiskCache`) - rust-lang#154017 ( Fix invalid add of duplicated call locations for the rustdoc scraped examples feature) - rust-lang#154163 (enzyme submodule update) - rust-lang#154264 (Update books) - rust-lang#154282 (rustc-dev-guide subtree update)
2 parents 212b0d4 + 04975e4 commit 9df8317

Some content is hidden

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

59 files changed

+881
-460
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4573,7 +4573,6 @@ dependencies = [
45734573
"rustc_data_structures",
45744574
"rustc_errors",
45754575
"rustc_hir",
4576-
"rustc_index",
45774576
"rustc_macros",
45784577
"rustc_middle",
45794578
"rustc_serialize",

compiler/rustc_incremental/src/persist/save.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_data_structures::sync::par_join;
66
use rustc_middle::dep_graph::{
77
DepGraph, SerializedDepGraph, WorkProduct, WorkProductId, WorkProductMap,
88
};
9+
use rustc_middle::query::on_disk_cache;
910
use rustc_middle::ty::TyCtxt;
1011
use rustc_serialize::Encodable as RustcEncodable;
1112
use rustc_serialize::opaque::FileEncoder;
@@ -82,7 +83,7 @@ pub(crate) fn save_dep_graph(tcx: TyCtxt<'_>) {
8283

8384
file_format::save_in(sess, query_cache_path, "query cache", |encoder| {
8485
tcx.sess.time("incr_comp_serialize_result_cache", || {
85-
on_disk_cache.serialize(tcx, encoder)
86+
on_disk_cache::OnDiskCache::serialize(tcx, encoder)
8687
})
8788
});
8889
});

compiler/rustc_middle/src/dep_graph/graph.rs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ impl DepGraphData {
709709
// side effect.
710710
std::iter::once(DepNodeIndex::FOREVER_RED_NODE).collect(),
711711
);
712-
tcx.store_side_effect(dep_node_index, side_effect);
712+
tcx.query_system.side_effects.borrow_mut().insert(dep_node_index, side_effect);
713713
dep_node_index
714714
}
715715

@@ -718,7 +718,13 @@ impl DepGraphData {
718718
#[inline]
719719
fn force_side_effect<'tcx>(&self, tcx: TyCtxt<'tcx>, prev_index: SerializedDepNodeIndex) {
720720
with_deps(TaskDepsRef::Ignore, || {
721-
let side_effect = tcx.load_side_effect(prev_index).unwrap();
721+
let side_effect = tcx
722+
.query_system
723+
.on_disk_cache
724+
.as_ref()
725+
.unwrap()
726+
.load_side_effect(tcx, prev_index)
727+
.unwrap();
722728

723729
// Use `send_and_color` as `promote_node_and_deps_to_current` expects all
724730
// green dependencies. `send_and_color` will also prevent multiple nodes
@@ -745,7 +751,7 @@ impl DepGraphData {
745751
}
746752

747753
// This will just overwrite the same value for concurrent calls.
748-
tcx.store_side_effect(dep_node_index, side_effect);
754+
tcx.query_system.side_effects.borrow_mut().insert(dep_node_index, side_effect);
749755
})
750756
}
751757

@@ -1549,23 +1555,4 @@ impl<'tcx> TyCtxt<'tcx> {
15491555
fn is_eval_always(self, kind: DepKind) -> bool {
15501556
self.dep_kind_vtable(kind).is_eval_always
15511557
}
1552-
1553-
// Interactions with on_disk_cache
1554-
fn load_side_effect(
1555-
self,
1556-
prev_dep_node_index: SerializedDepNodeIndex,
1557-
) -> Option<QuerySideEffect> {
1558-
self.query_system
1559-
.on_disk_cache
1560-
.as_ref()
1561-
.and_then(|c| c.load_side_effect(self, prev_dep_node_index))
1562-
}
1563-
1564-
#[inline(never)]
1565-
#[cold]
1566-
fn store_side_effect(self, dep_node_index: DepNodeIndex, side_effect: QuerySideEffect) {
1567-
if let Some(c) = self.query_system.on_disk_cache.as_ref() {
1568-
c.store_side_effect(dep_node_index, side_effect)
1569-
}
1570-
}
15711558
}

compiler/rustc_middle/src/dep_graph/serialized.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ rustc_index::newtype_index! {
7272
pub struct SerializedDepNodeIndex {}
7373
}
7474

75+
impl SerializedDepNodeIndex {
76+
/// Converts a current-session dep node index to a "serialized" index,
77+
/// for the purpose of serializing data to be loaded by future sessions.
78+
#[inline(always)]
79+
pub fn from_curr_for_serialization(index: DepNodeIndex) -> Self {
80+
SerializedDepNodeIndex::from_u32(index.as_u32())
81+
}
82+
}
83+
7584
const DEP_NODE_SIZE: usize = size_of::<SerializedDepNodeIndex>();
7685
/// Amount of padding we need to add to the edge list data so that we can retrieve every
7786
/// SerializedDepNodeIndex with a fixed-size read then mask.

compiler/rustc_middle/src/hooks/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_span::def_id::{CrateNum, LocalDefId};
99
use rustc_span::{ExpnHash, ExpnId};
1010

1111
use crate::mir;
12-
use crate::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex};
12+
use crate::query::on_disk_cache::CacheEncoder;
1313
use crate::ty::{Ty, TyCtxt};
1414

1515
macro_rules! declare_hooks {
@@ -111,10 +111,8 @@ declare_hooks! {
111111
/// Creates the MIR for a given `DefId`, including unreachable code.
112112
hook build_mir_inner_impl(def: LocalDefId) -> mir::Body<'tcx>;
113113

114-
hook encode_query_values(
115-
encoder: &mut CacheEncoder<'_, 'tcx>,
116-
query_result_index: &mut EncodedDepNodeIndex
117-
) -> ();
114+
/// Serializes all eligible query return values into the on-disk cache.
115+
hook encode_query_values(encoder: &mut CacheEncoder<'_, 'tcx>) -> ();
118116
}
119117

120118
#[cold]

compiler/rustc_middle/src/queries.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ use crate::{mir, thir};
131131
// `Providers` that the driver creates (using several `rustc_*` crates).
132132
//
133133
// The result type of each query must implement `Clone`. Additionally
134-
// `ty::query::from_cycle_error::FromCycleError` can be implemented which produces an appropriate
134+
// `QueryVTable::handle_cycle_error_fn` can be used to produce an appropriate
135135
// placeholder (error) value if the query resulted in a query cycle.
136-
// Queries without a `FromCycleError` implementation will raise a fatal error on query
137-
// cycles instead.
136+
// Queries without a custom `handle_cycle_error_fn` implementation will raise a
137+
// fatal error on query cycles instead.
138138
rustc_queries! {
139139
/// Caches the expansion of a derive proc macro, e.g. `#[derive(Serialize)]`.
140140
/// The key is:
@@ -577,7 +577,7 @@ rustc_queries! {
577577

578578
/// Checks whether a type is representable or infinitely sized
579579
//
580-
// Infinitely sized types will cause a cycle. The `value_from_cycle_error` impl will print
580+
// Infinitely sized types will cause a cycle. The query's `handle_cycle_error_fn` will print
581581
// a custom error about the infinite size and then abort compilation. (In the past we
582582
// recovered and continued, but in practice that leads to confusing subsequent error
583583
// messages about cycles that then abort.)

compiler/rustc_middle/src/query/job.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::sync::Arc;
66
use parking_lot::{Condvar, Mutex};
77
use rustc_span::Span;
88

9-
use crate::query::CycleError;
9+
use crate::query::Cycle;
1010
use crate::ty::TyCtxt;
1111

1212
/// A value uniquely identifying an active query job.
@@ -59,7 +59,7 @@ pub struct QueryWaiter<'tcx> {
5959
pub parent: Option<QueryJobId>,
6060
pub condvar: Condvar,
6161
pub span: Span,
62-
pub cycle: Mutex<Option<CycleError<'tcx>>>,
62+
pub cycle: Mutex<Option<Cycle<'tcx>>>,
6363
}
6464

6565
#[derive(Clone, Debug)]
@@ -79,7 +79,7 @@ impl<'tcx> QueryLatch<'tcx> {
7979
tcx: TyCtxt<'tcx>,
8080
query: Option<QueryJobId>,
8181
span: Span,
82-
) -> Result<(), CycleError<'tcx>> {
82+
) -> Result<(), Cycle<'tcx>> {
8383
let mut waiters_guard = self.waiters.lock();
8484
let Some(waiters) = &mut *waiters_guard else {
8585
return Ok(()); // already complete

compiler/rustc_middle/src/query/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ pub use self::into_query_key::IntoQueryKey;
55
pub use self::job::{QueryJob, QueryJobId, QueryLatch, QueryWaiter};
66
pub use self::keys::{AsLocalQueryKey, LocalCrate, QueryKey};
77
pub use self::plumbing::{
8-
ActiveKeyStatus, CycleError, EnsureMode, QueryMode, QueryState, QuerySystem, QueryVTable,
9-
TyCtxtAt, TyCtxtEnsureDone, TyCtxtEnsureOk, TyCtxtEnsureResult,
8+
ActiveKeyStatus, Cycle, EnsureMode, QueryMode, QueryState, QuerySystem, QueryVTable, TyCtxtAt,
9+
TyCtxtEnsureDone, TyCtxtEnsureOk, TyCtxtEnsureResult,
1010
};
1111
pub use self::stack::QueryStackFrame;
1212
pub use crate::queries::Providers;

0 commit comments

Comments
 (0)