From 14c619340e4df07c79e60ac051a0796b30fd0acc Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Fri, 19 Nov 2021 18:02:42 -0500 Subject: [PATCH] Add test for evaluate_obligation: Ok(EvaluatedToOkModuloRegions) ICE Adds the minimial repro test case from #85360. The fix for #85360 was supposed to be #85868 however the repro was resolved in the 2021-07-05 nightly while #85360 didn't land until 2021-09-03. The reason for that is d34a3a401b4e44f289a4d5bf53da83367cbb6aa7 **also** resolves that issue. To test if #85868 actually fixes #85360, I reverted d34a3a401b4e44f289a4d5bf53da83367cbb6aa7 and found that #85868 does indeed resolve #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! --- .../issue-85360-eval-obligation-ice.rs | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 src/test/incremental/issue-85360-eval-obligation-ice.rs diff --git a/src/test/incremental/issue-85360-eval-obligation-ice.rs b/src/test/incremental/issue-85360-eval-obligation-ice.rs new file mode 100644 index 00000000000..e05da656db6 --- /dev/null +++ b/src/test/incremental/issue-85360-eval-obligation-ice.rs @@ -0,0 +1,117 @@ +// revisions:cfail1 cfail2 +// compile-flags: --crate-type=lib --edition=2021 +// build-pass + +use core::any::Any; +use core::marker::PhantomData; + +struct DerefWrap(T); + +impl core::ops::Deref for DerefWrap { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +struct Storage { + phantom: PhantomData<(T, D)>, +} + +type ReadStorage = Storage>>; + +pub trait Component { + type Storage; +} + +struct VecStorage; + +struct Pos; + +impl Component for Pos { + type Storage = VecStorage; +} + +struct GenericComp { + _t: T, +} + +impl Component for GenericComp { + type Storage = VecStorage; +} +struct ReadData { + pos_interpdata: ReadStorage>, +} + +trait System { + type SystemData; + + fn run(data: Self::SystemData, any: Box); +} + +struct Sys; + +impl System for Sys { + type SystemData = (ReadData, ReadStorage); + + fn run((data, pos): Self::SystemData, any: Box) { + > 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 +where + T: Component, + D: core::ops::Deref>, + T::Storage: Sync, +{ +} + +impl ParJoin for (A, B) +where + A: ParJoin, + B: ParJoin, +{ +} + +pub trait SystemData { + fn setup(any: Box); +} + +impl SystemData for ReadStorage +where + T: Component, +{ + fn setup(any: Box) { + let storage: &MaskedStorage = any.downcast_ref().unwrap(); + + >>::cast(&storage); + } +} + +pub struct MaskedStorage { + _inner: T::Storage, +} + +pub unsafe trait CastFrom { + fn cast(t: &T) -> &Self; +} + +unsafe impl CastFrom for dyn Any +where + T: Any + 'static, +{ + fn cast(t: &T) -> &Self { + t + } +}