Delay a bug when overwriting fed value.
This commit is contained in:
parent
222acaa23e
commit
3bb5d1dfc1
3 changed files with 30 additions and 15 deletions
|
@ -533,12 +533,20 @@ macro_rules! define_feedable {
|
||||||
let (value_hash, old_hash): (Fingerprint, Fingerprint) = tcx.with_stable_hashing_context(|mut hcx|
|
let (value_hash, old_hash): (Fingerprint, Fingerprint) = tcx.with_stable_hashing_context(|mut hcx|
|
||||||
(hasher(&mut hcx, &value), hasher(&mut hcx, &old))
|
(hasher(&mut hcx, &value), hasher(&mut hcx, &old))
|
||||||
);
|
);
|
||||||
assert_eq!(
|
if old_hash != value_hash {
|
||||||
old_hash, value_hash,
|
// We have an inconsistency. This can happen if one of the two
|
||||||
"Trying to feed an already recorded value for query {} key={key:?}:\nold value: {old:?}\nnew value: {value:?}",
|
// results is tainted by errors. In this case, delay a bug to
|
||||||
stringify!($name),
|
// ensure compilation is doomed, and keep the `old` value.
|
||||||
)
|
tcx.sess.delay_span_bug(DUMMY_SP, format!(
|
||||||
|
"Trying to feed an already recorded value for query {} key={key:?}:\n\
|
||||||
|
old value: {old:?}\nnew value: {value:?}",
|
||||||
|
stringify!($name),
|
||||||
|
));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// The query is `no_hash`, so we have no way to perform a sanity check.
|
||||||
|
// If feeding the same value multiple times needs to be supported,
|
||||||
|
// the query should not be marked `no_hash`.
|
||||||
bug!(
|
bug!(
|
||||||
"Trying to feed an already recorded value for query {} key={key:?}:\nold value: {old:?}\nnew value: {value:?}",
|
"Trying to feed an already recorded value for query {} key={key:?}:\nold value: {old:?}\nnew value: {value:?}",
|
||||||
stringify!($name),
|
stringify!($name),
|
||||||
|
|
|
@ -433,16 +433,22 @@ where
|
||||||
(hasher(&mut hcx, &cached_result), hasher(&mut hcx, &result))
|
(hasher(&mut hcx, &cached_result), hasher(&mut hcx, &result))
|
||||||
});
|
});
|
||||||
let formatter = query.format_value();
|
let formatter = query.format_value();
|
||||||
debug_assert_eq!(
|
if old_hash != new_hash {
|
||||||
old_hash,
|
// We have an inconsistency. This can happen if one of the two
|
||||||
new_hash,
|
// results is tainted by errors. In this case, delay a bug to
|
||||||
"Computed query value for {:?}({:?}) is inconsistent with fed value,\n\
|
// ensure compilation is doomed.
|
||||||
computed={:#?}\nfed={:#?}",
|
qcx.dep_context().sess().delay_span_bug(
|
||||||
query.dep_kind(),
|
DUMMY_SP,
|
||||||
key,
|
format!(
|
||||||
formatter(&result),
|
"Computed query value for {:?}({:?}) is inconsistent with fed value,\n\
|
||||||
formatter(&cached_result),
|
computed={:#?}\nfed={:#?}",
|
||||||
);
|
query.dep_kind(),
|
||||||
|
key,
|
||||||
|
formatter(&result),
|
||||||
|
formatter(&cached_result),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
job_owner.complete(cache, result, dep_node_index);
|
job_owner.complete(cache, result, dep_node_index);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
//
|
//
|
||||||
// compile-flags: -Zincremental-ignore-spans
|
// compile-flags: -Zincremental-ignore-spans
|
||||||
// revisions: cpass cfail
|
// revisions: cpass cfail
|
||||||
|
// error-pattern: cycle detected when computing type of `Bar::N`
|
||||||
|
|
||||||
#![feature(trait_alias)]
|
#![feature(trait_alias)]
|
||||||
#![crate_type="lib"]
|
#![crate_type="lib"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue