Skip to content
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

Implement disjointed statics #85

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

Conversation

CAD97
Copy link
Contributor

@CAD97 CAD97 commented Mar 11, 2024

I'm not super enthused about the impl duplicating much of disjointed_slice, and certainly wants some more test coverage, but it works sufficiently enough for initial review of the approach.

The initial vision for #81 allowed using unsized types for the static (e.g. dyn Trait), but to avoid silently introducing extra indirection, this restricts disjointed statics to sized types. For dyn Trait injection, you can use &dyn Trait as the static type. However, no shorthand is provided for linking static IMPL: Concrete to such a declaration, and downstream must create the correctly typed static themselves. This is at least in part due to the moderate difficulty of hygienically naming the correct item type from downstream.

This feels a little bad for linking fn(), since ending up with &fn() is kind of silly. We might want for a separate "disjointed fn" which links the function item instead of a static item.

closes #81

@CAD97

This comment was marked as resolved.

@CAD97
Copy link
Contributor Author

CAD97 commented Mar 12, 2024

Potential alternative name: #[linkme::injected]. With that name I'd consider it important to work for fn items directly. I can't think of a good way to directly link some static and create a new static item for others, unfortunately.

@dtolnay
Copy link
Owner

dtolnay commented Aug 11, 2024

I have not gotten a chance to review this yet — sorry about the delay. I am still occupied with a different project (which I had though might be done by now, but isn't). If I were to add you on linkme as a maintainer, could you merge this yourself, or get a review from anyone else and then merge? Of course, I am not sure whether this defeats your intention for putting the new macro into this crate as opposed to your own crate.

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.

Proposal: add a #[disjointed_static] attribute
2 participants