Skip to content

Commit e1994bd

Browse files
incr.comp.: Make some DepNodes non-anonymous.
1 parent f0bbf4e commit e1994bd

File tree

4 files changed

+36
-59
lines changed

4 files changed

+36
-59
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ use hir::map::DefPathHash;
6565
use hir::{HirId, ItemLocalId};
6666

6767
use ich::Fingerprint;
68-
use ty::{TyCtxt, Instance, InstanceDef};
68+
use ty::{TyCtxt, Instance, InstanceDef, ParamEnvAnd, Ty};
69+
use ty::subst::Substs;
6970
use rustc_data_structures::stable_hasher::{StableHasher, HashStable};
7071
use ich::StableHashingContext;
7172
use std::fmt;
@@ -480,17 +481,17 @@ define_dep_nodes!( <'tcx>
480481
[] TypeckBodiesKrate,
481482
[] TypeckTables(DefId),
482483
[] HasTypeckTables(DefId),
483-
[anon] ConstEval,
484+
[] ConstEval { param_env: ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)> },
484485
[] SymbolName(DefId),
485486
[] InstanceSymbolName { instance: Instance<'tcx> },
486487
[] SpecializationGraph(DefId),
487488
[] ObjectSafety(DefId),
488489

489-
[anon] IsCopy,
490-
[anon] IsSized,
491-
[anon] IsFreeze,
492-
[anon] NeedsDrop,
493-
[anon] Layout,
490+
[] IsCopy { param_env: ParamEnvAnd<'tcx, Ty<'tcx>> },
491+
[] IsSized { param_env: ParamEnvAnd<'tcx, Ty<'tcx>> },
492+
[] IsFreeze { param_env: ParamEnvAnd<'tcx, Ty<'tcx>> },
493+
[] NeedsDrop { param_env: ParamEnvAnd<'tcx, Ty<'tcx>> },
494+
[] Layout { param_env: ParamEnvAnd<'tcx, Ty<'tcx>> },
494495

495496
// The set of impls for a given trait.
496497
[] TraitImpls(DefId),
@@ -524,10 +525,6 @@ define_dep_nodes!( <'tcx>
524525
// trait-select node.
525526
[anon] TraitSelect,
526527

527-
// For proj. cache, we just keep a list of all def-ids, since it is
528-
// not a hotspot.
529-
[] ProjectionCache { def_ids: DefIdList },
530-
531528
[] ParamEnv(DefId),
532529
[] DescribeDef(DefId),
533530
[] DefSpan(DefId),
@@ -708,40 +705,6 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefId, De
708705
}
709706
}
710707

711-
712-
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefIdList,) {
713-
const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
714-
715-
// We actually would not need to specialize the implementation of this
716-
// method but it's faster to combine the hashes than to instantiate a full
717-
// hashing context and stable-hashing state.
718-
fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint {
719-
let mut fingerprint = Fingerprint::zero();
720-
721-
for &def_id in self.0.iter() {
722-
let def_path_hash = tcx.def_path_hash(def_id);
723-
fingerprint = fingerprint.combine(def_path_hash.0);
724-
}
725-
726-
fingerprint
727-
}
728-
729-
fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String {
730-
use std::fmt::Write;
731-
732-
let mut s = String::new();
733-
write!(&mut s, "[").unwrap();
734-
735-
for &def_id in self.0.iter() {
736-
write!(&mut s, "{}", tcx.def_path(def_id).to_string(tcx)).unwrap();
737-
}
738-
739-
write!(&mut s, "]").unwrap();
740-
741-
s
742-
}
743-
}
744-
745708
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (HirId,) {
746709
const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
747710

@@ -800,4 +763,3 @@ impl_stable_hash_for!(struct ::dep_graph::WorkProductId {
800763
hash
801764
});
802765

803-
type DefIdList = Vec<DefId>;

src/librustc/ty/maps/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ fn typeck_item_bodies_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
377377
DepConstructor::TypeckBodiesKrate
378378
}
379379

380-
fn const_eval_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>)
380+
fn const_eval_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>)
381381
-> DepConstructor<'tcx> {
382-
DepConstructor::ConstEval
382+
DepConstructor::ConstEval { param_env }
383383
}
384384

385385
fn mir_keys<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
@@ -390,24 +390,24 @@ fn crate_variances<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
390390
DepConstructor::CrateVariances
391391
}
392392

393-
fn is_copy_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
394-
DepConstructor::IsCopy
393+
fn is_copy_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
394+
DepConstructor::IsCopy { param_env }
395395
}
396396

397-
fn is_sized_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
398-
DepConstructor::IsSized
397+
fn is_sized_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
398+
DepConstructor::IsSized { param_env }
399399
}
400400

401-
fn is_freeze_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
402-
DepConstructor::IsFreeze
401+
fn is_freeze_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
402+
DepConstructor::IsFreeze { param_env }
403403
}
404404

405-
fn needs_drop_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
406-
DepConstructor::NeedsDrop
405+
fn needs_drop_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
406+
DepConstructor::NeedsDrop { param_env }
407407
}
408408

409-
fn layout_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
410-
DepConstructor::Layout
409+
fn layout_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
410+
DepConstructor::Layout { param_env }
411411
}
412412

413413
fn lint_levels_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {

src/librustc/ty/maps/plumbing.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
672672
DepKind::NeedsDrop |
673673
DepKind::Layout |
674674
DepKind::TraitSelect |
675-
DepKind::ProjectionCache |
676675
DepKind::ConstEval |
677676

678677
// We don't have enough information to reconstruct the query key of

src/librustc/ty/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,22 @@ impl<'tcx, T> ParamEnvAnd<'tcx, T> {
12531253
}
12541254
}
12551255

1256+
impl<'gcx, T> HashStable<StableHashingContext<'gcx>> for ParamEnvAnd<'gcx, T>
1257+
where T: HashStable<StableHashingContext<'gcx>>
1258+
{
1259+
fn hash_stable<W: StableHasherResult>(&self,
1260+
hcx: &mut StableHashingContext<'gcx>,
1261+
hasher: &mut StableHasher<W>) {
1262+
let ParamEnvAnd {
1263+
ref param_env,
1264+
ref value
1265+
} = *self;
1266+
1267+
param_env.hash_stable(hcx, hasher);
1268+
value.hash_stable(hcx, hasher);
1269+
}
1270+
}
1271+
12561272
#[derive(Copy, Clone, Debug)]
12571273
pub struct Destructor {
12581274
/// The def-id of the destructor method

0 commit comments

Comments
 (0)