convert Tracked to a struct variant

This commit is contained in:
Niko Matsakis 2018-10-21 07:14:25 -04:00
parent 3bc5b78284
commit 03751d3d5c
2 changed files with 18 additions and 11 deletions

View file

@ -651,7 +651,7 @@ where
match &memo.inputs {
QueryDescriptorSet::Constant => return false,
QueryDescriptorSet::Untracked => return true,
QueryDescriptorSet::Tracked(descriptors) => descriptors.clone(),
QueryDescriptorSet::Tracked { descriptors } => descriptors.clone(),
}
}
}
@ -759,14 +759,14 @@ where
true
}
QueryDescriptorSet::Tracked(inputs) => {
debug_assert!(!inputs.is_empty());
QueryDescriptorSet::Tracked { descriptors } => {
debug_assert!(!descriptors.is_empty());
debug_assert!(match self.changed_at {
ChangedAt::Constant(_) => false,
ChangedAt::Revision(_) => true,
});
// Check whether any of our inputs change since the
// Check whether any of our inputs changed since the
// **last point where we were verified** (not since we
// last changed). This is important: if we have
// memoized values, then an input may have changed in
@ -775,12 +775,12 @@ where
// R1. But our *verification* date will be R2, and we
// are only interested in finding out whether the
// input changed *again*.
let changed_input = inputs
let changed_input = descriptors
.iter()
.filter(|old_input| old_input.maybe_changed_since(db, self.verified_at))
.inspect(|old_input| {
debug!(
"{:?}::verify_inputs: `{:?}` may have changed",
"{:?}::verify_descriptors: `{:?}` may have changed",
Q::default(),
old_input
)

View file

@ -264,7 +264,9 @@ where
if set.is_empty() {
QueryDescriptorSet::Constant
} else {
QueryDescriptorSet::Tracked(Arc::new(set))
QueryDescriptorSet::Tracked {
descriptors: Arc::new(set),
}
}
}
};
@ -556,7 +558,9 @@ pub(crate) enum QueryDescriptorSet<DB: Database> {
Constant,
/// All reads were to tracked things:
Tracked(Arc<FxIndexSet<DB::QueryDescriptor>>),
Tracked {
descriptors: Arc<FxIndexSet<DB::QueryDescriptor>>,
},
/// Some reads to an untracked thing:
Untracked,
@ -565,9 +569,12 @@ pub(crate) enum QueryDescriptorSet<DB: Database> {
impl<DB: Database> std::fmt::Debug for QueryDescriptorSet<DB> {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
QueryDescriptorSet::Constant => write!(fmt, "Constant"),
QueryDescriptorSet::Tracked(set) => std::fmt::Debug::fmt(set, fmt),
QueryDescriptorSet::Untracked => write!(fmt, "Untracked"),
QueryDescriptorSet::Constant => fmt.debug_struct("Constant").finish(),
QueryDescriptorSet::Tracked { descriptors } => fmt
.debug_struct("Tracked")
.field("descriptors", descriptors)
.finish(),
QueryDescriptorSet::Untracked => fmt.debug_struct("Untracked").finish(),
}
}
}