Skip to content

Update TaggedStructure::push lifetimes #1005

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SteveIntensifies
Copy link

@SteveIntensifies SteveIntensifies commented Aug 12, 2025

Right now, TaggedStructure::push is defined by #994 as:

fn push<T: Extends<Self> + TaggedStructure<'a>>(mut self, next: &'a mut T) -> Self

This requires that the extending structure has the same lifetime as the base structure, which is unnecessarily restricting.

This PR updates the function signatures of push and extend to require that the extending structure outlives the base structure.

Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of any reason why this would be wrong, though I'm not super great at reasoning about variance.

@MarijnS95
Copy link
Collaborator

This manually-reimplemented lifetime/borrow-checking surrounding a bunch of raw pointers is tricky and finicky to get right, that's exactly why we have a bunch of tests around it to ensure expected correctness as well as usability.

As part of this change I'd appreciate to see an additional test that demonstrates what currently isn't supported (I can vaguely assume), and so that this doesn't regress in the future.

Also, welcome back ;)

@SteveIntensifies
Copy link
Author

SteveIntensifies commented Aug 13, 2025

That's a fair request. You don't need an additional test because the existing test would cover this case with minor modifications. I just had to make variable_pointers and corner to have different scopes.

Also, welcome back ;)

I'm totally new here 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants