-
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
Add test for evaluate_obligation: Ok(EvaluatedToOkModuloRegions) ICE #91065
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
src/test/incremental/issue-85360-eval-obligation-ice.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// revisions:cfail1 cfail2 | ||
//[cfail1] compile-flags: --crate-type=lib --edition=2021 -Zassert-incr-state=not-loaded | ||
//[cfail2] compile-flags: --crate-type=lib --edition=2021 -Zassert-incr-state=loaded | ||
// build-pass | ||
|
||
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
// compile-flags: --edition=2021 | ||
|
||
#![feature(rustc_attrs)] | ||
|
||
use core::any::Any; | ||
use core::marker::PhantomData; | ||
|
||
fn main() { | ||
test::<MaskedStorage<GenericComp<Pos>>>(make()); | ||
//~^ ERROR evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOk) | ||
//~| ERROR evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOk) | ||
|
||
test::<MaskedStorage<GenericComp2<Pos>>>(make()); | ||
//~^ ERROR evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp2<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) | ||
//~| ERROR evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp2<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) | ||
} | ||
|
||
#[rustc_evaluate_where_clauses] | ||
fn test<T: Sized>(_: T) {} | ||
|
||
fn make<T>() -> T { | ||
todo!() | ||
} | ||
|
||
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 GenericComp2<T> { | ||
_t: T, | ||
} | ||
|
||
impl<T: 'static> Component for GenericComp2<T> where for<'a> &'a bool: 'a { | ||
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
error: evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOk) | ||
--> $DIR/issue-85360-eval-obligation-ice.rs:9:5 | ||
| | ||
LL | test::<MaskedStorage<GenericComp<Pos>>>(make()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | fn test<T: Sized>(_: T) {} | ||
| - predicate | ||
|
||
error: evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOk) | ||
--> $DIR/issue-85360-eval-obligation-ice.rs:9:5 | ||
| | ||
LL | test::<MaskedStorage<GenericComp<Pos>>>(make()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | fn test<T: Sized>(_: T) {} | ||
| ----- predicate | ||
|
||
error: evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp2<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) | ||
--> $DIR/issue-85360-eval-obligation-ice.rs:13:5 | ||
| | ||
LL | test::<MaskedStorage<GenericComp2<Pos>>>(make()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | fn test<T: Sized>(_: T) {} | ||
| - predicate | ||
|
||
error: evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp2<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) | ||
--> $DIR/issue-85360-eval-obligation-ice.rs:13:5 | ||
| | ||
LL | test::<MaskedStorage<GenericComp2<Pos>>>(make()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | fn test<T: Sized>(_: T) {} | ||
| ----- predicate | ||
|
||
error: aborting due to 4 previous errors | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make the top-level evaluation produce
EvaluatedToOkModuloRegions
by addingwhere for<'a> &'a bool: 'a
to this impl. However, this will not work until #91329 is mergedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that that PR has been merged, it should be possible to adjust this impl to produce
EvaluatedToOkModuloRegions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented. Thanks @Aaron1011!