-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incremental compilation error with evaluate_obligation: Ok(EvaluatedToOkModuloRegions) #85360
Comments
This is caused by the way that we cache projection obligations. During candidate confirmation, we call rust/compiler/rustc_trait_selection/src/traits/select/mod.rs Lines 1785 to 1794 in 7dc9ff5
The first time we normalize a type, rust/compiler/rustc_trait_selection/src/traits/project.rs Lines 533 to 537 in 7dc9ff5
In the reproducer for this issue, the projection of |
Always produce sub-obligations when using cached projection result See rust-lang#85360 When we skip adding the sub-obligations to the `obligation` list, we can affect whether or not the final result is `EvaluatedToOk` or `EvaluatedToOkModuloObligations`. This creates problems for incremental compilation, since the projection cache is untracked shared state. To solve this issue, we unconditionally process the sub-obligations. Surprisingly, this is a slight performance *win* in many cases.
This issue has now been fixed. However, we still need a minimized regression test. |
@Aaron1011 I can still produce an ICE with this on the latest nightly:
although perhaps the query stack has changed a bit:
backtrace
|
You're right - it looks like I didn't fully test that fix. I'll continue to investigate. |
I managed to remove the use core::any::Any;
use core::marker::PhantomData;
struct DerefWrap<T>(T);
impl<T> core::ops::Deref for DerefWrap<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.0
}
}
struct Storage<T, D> {
phantom: PhantomData<(T, D)>,
}
type ReadStorage<T> = Storage<T, DerefWrap<MaskedStorage<T>>>;
pub trait Component {
type Storage;
}
struct VecStorage;
struct Pos;
impl Component for Pos {
type Storage = VecStorage;
}
struct GenericComp<T> {
_t: T,
}
impl<T: 'static> Component for GenericComp<T> {
type Storage = VecStorage;
}
struct ReadData {
pos_interpdata: ReadStorage<GenericComp<Pos>>,
}
trait System {
type SystemData;
fn run(data: Self::SystemData, any: Box<dyn Any>);
}
struct Sys;
impl System for Sys {
type SystemData = (ReadData, ReadStorage<Pos>);
fn run((data, pos): Self::SystemData, any: Box<dyn Any>) {
<ReadStorage<GenericComp<Pos>> as SystemData>::setup(any);
ParJoin::par_join((&pos, &data.pos_interpdata));
}
}
trait ParJoin {
fn par_join(self)
where
Self: Sized,
{
}
}
impl<'a, T, D> ParJoin for &'a Storage<T, D>
where
T: Component,
D: core::ops::Deref<Target = MaskedStorage<T>>,
T::Storage: Sync,
{
}
impl<A, B> ParJoin for (A, B)
where
A: ParJoin,
B: ParJoin,
{
}
pub trait SystemData {
fn setup(any: Box<dyn Any>);
}
impl<T: 'static> SystemData for ReadStorage<T>
where
T: Component,
{
fn setup(any: Box<dyn Any>) {
let storage: &MaskedStorage<T> = any.downcast_ref().unwrap();
<dyn Any as CastFrom<MaskedStorage<T>>>::cast(&storage);
}
}
pub struct MaskedStorage<T: Component> {
_inner: T::Storage,
}
pub unsafe trait CastFrom<T> {
fn cast(t: &T) -> &Self;
}
unsafe impl<T> CastFrom<T> for dyn Any
where
T: Any + 'static,
{
fn cast(t: &T) -> &Self {
t
}
} Edit: removed |
See #85868 and https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/projection.20cache.20and.20subobligations.20.2377325/near/241147624 for discussion about a fix. |
@Aaron1011 is this blocked on finding a solution to the conflict you mention in the linked discussion? |
@Imberflur - that's right. I'm hoping that we'll be able to get to this soon. |
cc #84970 |
Is it the same issue or a separate?
Note that cg_clif is in use. |
@vi It looks like that's the same issue. |
Run into this in 1.54 stable. |
Adds the minimial repro test case from rust-lang#85360. The fix for rust-lang#85360 was supposed to be rust-lang#85868 however the repro was resolved in the 2021-07-05 nightly while rust-lang#85360 didn't land until 2021-09-03. The reason for that is d34a3a4 **also** resolves that issue. To test if rust-lang#85868 actually fixes rust-lang#85360, I reverted d34a3a4 and found that rust-lang#85868 does indeed resolve rust-lang#85360. With that question resolved, add a test case to our incremental test suite for the original Ok(EvaluatedToOkModuloRegions) ICE. Thanks to @lqd for helping track this down!
Add test for evaluate_obligation: Ok(EvaluatedToOkModuloRegions) ICE Adds the minimial repro test case from rust-lang#85360. The fix for rust-lang#85360 was supposed to be rust-lang#85868 however the repro was resolved in the 2021-07-05 nightly while rust-lang#85868 didn't land until 2021-09-03. The reason for that is d34a3a4 **also** resolves that issue. To test if rust-lang#85868 actually fixes rust-lang#85360, I reverted d34a3a4 and found that rust-lang#85868 does indeed resolve rust-lang#85360. With that question resolved, add a test case to our incremental test suite for the original Ok(EvaluatedToOkModuloRegions) ICE. Thanks to `@lqd` for helping track this down!
Add test for evaluate_obligation: Ok(EvaluatedToOkModuloRegions) ICE Adds the minimial repro test case from rust-lang#85360. The fix for rust-lang#85360 was supposed to be rust-lang#85868 however the repro was resolved in the 2021-07-05 nightly while rust-lang#85868 didn't land until 2021-09-03. The reason for that is d34a3a4 **also** resolves that issue. To test if rust-lang#85868 actually fixes rust-lang#85360, I reverted d34a3a4 and found that rust-lang#85868 does indeed resolve rust-lang#85360. With that question resolved, add a test case to our incremental test suite for the original Ok(EvaluatedToOkModuloRegions) ICE. Thanks to ``@lqd`` for helping track this down!
Add test for evaluate_obligation: Ok(EvaluatedToOkModuloRegions) ICE Adds the minimial repro test case from rust-lang#85360. The fix for rust-lang#85360 was supposed to be rust-lang#85868 however the repro was resolved in the 2021-07-05 nightly while rust-lang#85868 didn't land until 2021-09-03. The reason for that is d34a3a4 **also** resolves that issue. To test if rust-lang#85868 actually fixes rust-lang#85360, I reverted d34a3a4 and found that rust-lang#85868 does indeed resolve rust-lang#85360. With that question resolved, add a test case to our incremental test suite for the original Ok(EvaluatedToOkModuloRegions) ICE. Thanks to ```@lqd``` for helping track this down!
Add test for evaluate_obligation: Ok(EvaluatedToOkModuloRegions) ICE Adds the minimial repro test case from rust-lang#85360. The fix for rust-lang#85360 was supposed to be rust-lang#85868 however the repro was resolved in the 2021-07-05 nightly while rust-lang#85868 didn't land until 2021-09-03. The reason for that is d34a3a4 **also** resolves that issue. To test if rust-lang#85868 actually fixes rust-lang#85360, I reverted d34a3a4 and found that rust-lang#85868 does indeed resolve rust-lang#85360. With that question resolved, add a test case to our incremental test suite for the original Ok(EvaluatedToOkModuloRegions) ICE. Thanks to ````@lqd```` for helping track this down!
Adds the minimial repro test case from rust-lang#85360. The fix for rust-lang#85360 was supposed to be rust-lang#85868 however the repro was resolved in the 2021-07-05 nightly while rust-lang#85360 didn't land until 2021-09-03. The reason for that is d34a3a4 **also** resolves that issue. To test if rust-lang#85868 actually fixes rust-lang#85360, I reverted d34a3a4 and found that rust-lang#85868 does indeed resolve rust-lang#85360. With that question resolved, add a test case to our incremental test suite for the original Ok(EvaluatedToOkModuloRegions) ICE. Thanks to @lqd for helping track this down!
I was hoping this would be fixed by #85186 but we are still experiencing this issue on the
2021-05-15
nightlyCode
Original case:
https://gitlab.com/veloren/veloren/-/tree/imbris/update-toolchain
Reduced case:
https://github.com/Imberflur/incremental-ice-with-specs
Meta
rustc --version --verbose
:Error output (original case)
Backtrace
query stack during panic
Error output (reduced case)
Backtrace
query stack during panic
The text was updated successfully, but these errors were encountered: