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.
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
Improve warning for Send resources marked as non_send #8000
Improve warning for Send resources marked as non_send #8000
Changes from 1 commit
461d7dd
38d54f4
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 already asked on Discord but nobody answered: this check only triggers if a resource is first inserted as non-
Send
and then asSend
. If the order is swapped this won't trigger (there's even a test for this). IMO this is inconsistent, it should either always trigger or never.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.
It's perfectly safe to store a
Send
type in!Send
storage, though probably a mistake to do so. We could fire a warning in the opposite case, but I'm against hard-failing when there's no safety issue.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.
It's also safe to store a
Send
type inSend
storage though. The problem is thatcomponent_info
is shared betweenSend
and non-Send
resources with the sameTypeId
. When a resource is inserted as bothSend
and non-Send
thencomponent_info.is_send_and_sync()
will report only the value of the first one, which is however wrong for when the resource is first inserted as non-Send
. This can be fixed by either:ComponentId
s toSend
and non-Send
resources with the sameTypeId
Components::resource_indices
for non-Send
resourcesSend
first and then as non-Send
component_info
to setis_send_and_sync
when it isfalse
but aSend
Resource
is being insertedAt the end I would expect these two functions to either both succeed or both fail (currently only the first one succeeds):
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.
The case where I ran into this error is much simpler and simply requires insert_non_send_resource, then adding a system that uses it. Doing insert_resource first does prevent the error, which seems a bit odd but that doesn't really cause any usability problems
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.
While this is a pretty big footgun as is, changing the behavior here would be a breaking change, and probably not suited for a PR aiming at 0.10.1. I'm OK with just changing the panic message for now, and have a separate PR resolve this for 0.11.
Hopefully we get
!Send
resources out of the World before then though.