-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
52985 diagnostics no concrete type behind existential type #53588
52985 diagnostics no concrete type behind existential type #53588
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@oli-obk, unrelated, but played around with some use cases for further testing and stumbled across some stuff. Let me know if you want me to move this message elsewhere. I have code snippets and corresponding errors, with expected behavior in comments on the snippets. Please let me know if my understanding is off; I based some assumptions off the documentation at https://github.com/rust-lang/rfcs/blob/master/text/2071-impl-trait-existential-types.md. Would be happy to file issues for and potentially look further into some of these, though some of these issues may already be known. Wanted to just note them because I have a feeling that some of these cases working as described could invalidate or at least affect this PR. |
WRT this PR, does this mean we can revert your previous PR for this error? |
I think rust-lang/rfcs#2515 is discussing the symmetry between |
@oli-obk agreed that we can revert the original PR as hitting the inf recursion case in EDIT: I have reverted the relevant code from the original PR in commit a515eee below. |
}) | ||
}; | ||
|
||
let old = self.tables.concrete_existential_types.insert(def_id, definition_ty); | ||
if let ty::TyAnon(def_id, _substs) = definition_ty.sty { |
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 think we should compare this def_id
to the other def_id
in scope and only run the type_of
query if it is the same. Otherwise we're running it uselessly every time an existential type resolves to an existential type or an impl Trait type
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.
Worse, it would cause a cycle if you had an existential type that resolved to another TyAnon
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'll add a test case for this case
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
- Original cycle error diagnostics PR'd against this issue caught panic-causing error while resolving std::mem::transmute calls - Now, catch invalid use case of not providing a concrete sized type behind existential type in definining use case. - Update relevant test to reflect this new error 52985: revert normalize query changes - PR 53588 invalidates 53316, causing a correct cycle error to occur with a good span. - Don't need to revert the whole merge as the test files are still fine, just need to revert the normalize query changes. - It should now be correct that infinite recursion detected during normalize query type folding is a bug, should have been caught earlier (when resolving the existential type's defining use cases). 52985: code review impl - Only cause cycle error if anonymous type resolves to anonymous type that has the same def id (is the same type) as the original (parent) type. - Add test case to cover this case for existential types. 52985: remove Ty prefix from TyAnon - To align with changes per commit 6f637da
@bors r+ thanks! |
📌 Commit 7440125 has been approved by |
…ype_behind_existential_type, r=oli-obk 52985 diagnostics no concrete type behind existential type @oli-obk FYI. See below for new cycle error generated. ```rust error[E0391]: cycle detected when processing `Foo` --> /dev/staging/existential_type_no_concrete_type_nouse_potential.rs:3:1 | 3 | existential type Foo: Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...which requires processing `bar`... --> /dev/staging/existential_type_no_concrete_type_nouse_potential.rs:6:23 | 6 | fn bar(x: Foo) -> Foo { | _______________________^ 7 | | x 8 | | } | |_^ = note: ...which again requires processing `Foo`, completing the cycle error: aborting due to previous error For more information about this error, try `rustc --explain E0391`. ```
☀️ Test successful - status-appveyor, status-travis |
@oli-obk FYI. See below for new cycle error generated.