Skip to content

Commit f686619

Browse files
committed
Rename DepNodeKey::recover to try_recover_key
1 parent a6bfed4 commit f686619

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

compiler/rustc_middle/src/dep_graph/dep_node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ pub trait DepNodeKey<'tcx>: fmt::Debug + Sized {
213213
/// `fingerprint_style()` is not `FingerprintStyle::Opaque`.
214214
/// It is always valid to return `None` here, in which case incremental
215215
/// compilation will treat the query as having changed instead of forcing it.
216-
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>;
216+
fn try_recover_key(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>;
217217
}
218218

219219
// Blanket impl of `DepNodeKey`, which is specialized by other impls elsewhere.
@@ -244,7 +244,7 @@ where
244244
}
245245

246246
#[inline(always)]
247-
default fn recover(_: TyCtxt<'tcx>, _: &DepNode) -> Option<Self> {
247+
default fn try_recover_key(_: TyCtxt<'tcx>, _: &DepNode) -> Option<Self> {
248248
None
249249
}
250250
}

compiler/rustc_middle/src/dep_graph/dep_node_key.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl<'tcx> DepNodeKey<'tcx> for () {
1818
}
1919

2020
#[inline(always)]
21-
fn recover(_: TyCtxt<'tcx>, _: &DepNode) -> Option<Self> {
21+
fn try_recover_key(_: TyCtxt<'tcx>, _: &DepNode) -> Option<Self> {
2222
Some(())
2323
}
2424
}
@@ -40,7 +40,7 @@ impl<'tcx> DepNodeKey<'tcx> for DefId {
4040
}
4141

4242
#[inline(always)]
43-
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
43+
fn try_recover_key(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
4444
dep_node.extract_def_id(tcx)
4545
}
4646
}
@@ -62,7 +62,7 @@ impl<'tcx> DepNodeKey<'tcx> for LocalDefId {
6262
}
6363

6464
#[inline(always)]
65-
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
65+
fn try_recover_key(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
6666
dep_node.extract_def_id(tcx).map(|id| id.expect_local())
6767
}
6868
}
@@ -84,7 +84,7 @@ impl<'tcx> DepNodeKey<'tcx> for OwnerId {
8484
}
8585

8686
#[inline(always)]
87-
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
87+
fn try_recover_key(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
8888
dep_node.extract_def_id(tcx).map(|id| OwnerId { def_id: id.expect_local() })
8989
}
9090
}
@@ -107,7 +107,7 @@ impl<'tcx> DepNodeKey<'tcx> for CrateNum {
107107
}
108108

109109
#[inline(always)]
110-
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
110+
fn try_recover_key(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
111111
dep_node.extract_def_id(tcx).map(|id| id.krate)
112112
}
113113
}
@@ -166,7 +166,7 @@ impl<'tcx> DepNodeKey<'tcx> for HirId {
166166
}
167167

168168
#[inline(always)]
169-
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
169+
fn try_recover_key(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
170170
if tcx.key_fingerprint_style(dep_node.kind) == KeyFingerprintStyle::HirId {
171171
let (local_hash, local_id) = Fingerprint::from(dep_node.key_fingerprint).split();
172172
let def_path_hash = DefPathHash::new(tcx.stable_crate_id(LOCAL_CRATE), local_hash);
@@ -199,8 +199,8 @@ impl<'tcx> DepNodeKey<'tcx> for ModDefId {
199199
}
200200

201201
#[inline(always)]
202-
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
203-
DefId::recover(tcx, dep_node).map(ModDefId::new_unchecked)
202+
fn try_recover_key(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
203+
DefId::try_recover_key(tcx, dep_node).map(ModDefId::new_unchecked)
204204
}
205205
}
206206

@@ -221,7 +221,7 @@ impl<'tcx> DepNodeKey<'tcx> for LocalModDefId {
221221
}
222222

223223
#[inline(always)]
224-
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
225-
LocalDefId::recover(tcx, dep_node).map(LocalModDefId::new_unchecked)
224+
fn try_recover_key(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
225+
LocalDefId::try_recover_key(tcx, dep_node).map(LocalModDefId::new_unchecked)
226226
}
227227
}

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ pub(crate) fn try_load_from_on_disk_cache_inner<'tcx, C: QueryCache, const FLAGS
396396
) {
397397
debug_assert!(tcx.dep_graph.is_green(&dep_node));
398398

399-
let key = C::Key::recover(tcx, &dep_node).unwrap_or_else(|| {
399+
let key = C::Key::try_recover_key(tcx, &dep_node).unwrap_or_else(|| {
400400
panic!(
401401
"Failed to recover key for {dep_node:?} with key fingerprint {}",
402402
dep_node.key_fingerprint
@@ -465,7 +465,7 @@ pub(crate) fn force_from_dep_node_inner<'tcx, C: QueryCache, const FLAGS: QueryF
465465
"calling force_from_dep_node() on dep_kinds::codegen_unit"
466466
);
467467

468-
if let Some(key) = C::Key::recover(tcx, &dep_node) {
468+
if let Some(key) = C::Key::try_recover_key(tcx, &dep_node) {
469469
force_query(query, tcx, key, dep_node);
470470
true
471471
} else {

0 commit comments

Comments
 (0)