-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Abort after representability errors
#153317
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -741,8 +741,7 @@ impl<'tcx> AdtDef<'tcx> { | |
| } | ||
| } | ||
|
|
||
| /// This type exists just so a `FromCycleError` impl can be made for the `check_representability` | ||
| /// query. | ||
| #[derive(Clone, Copy, Debug, HashStable)] | ||
| pub enum Representability { | ||
| Representable, | ||
| Infinite(ErrorGuaranteed), | ||
| } | ||
| pub struct Representability; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you want to keep enforcing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I change this: let _ = tcx.check_representability(item.owner_id.def_id);to this: tcx.check_representability(item.owner_id.def_id);I get this warning: I'm not sure where the I could instead do this: tcx.ensure_ok().check_representability(item.owner_id.def_id);which is probably better, given that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I totally goldfished that I tried Anyway, I don't see how to avoid the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. Unfortunate but makes sense for now |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| enum MList { Cons(isize, MList), Nil } | ||
| //~^ ERROR recursive type `MList` has infinite size | ||
| //~| ERROR cycle | ||
|
|
||
| fn main() { let a = MList::Cons(10, MList::Cons(11, MList::Nil)); } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,6 @@ | ||
| struct A<T>(std::sync::OnceLock<Self>); | ||
| //~^ ERROR recursive type `A` has infinite size | ||
| //~| ERROR cycle detected when computing layout of `A<()>` | ||
|
|
||
| static B: A<()> = todo!(); | ||
| //~^ ERROR cycle occurred during layout computation | ||
|
|
||
| fn main() {} |
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.
I like that you haven't got rid of this type, although I would have made it
pub struct Representability(())in order to make its construction a private detail for a query implementation.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.
Hmm, but we cannot do that as query implementation is in another crate. I guess I would've done
new_uncheckedunsafe fn instead then if rustc was my project, but that's kinda a far too theoretical concern for an open project.