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

singleton: forward attributes #522

Merged
merged 4 commits into from
Apr 17, 2024
Merged

Conversation

jordens
Copy link
Contributor

@jordens jordens commented Apr 2, 2024

This only works in the long form with a named variable because of
constraints on where the vis metavariable can be used.

close #521

@jordens jordens requested a review from a team as a code owner April 2, 2024 19:37
This only works in the long form with a named variable because of
constraints on where the `vis` metavariable can be used.

close rust-embedded#521
@jordens
Copy link
Contributor Author

jordens commented Apr 3, 2024

The visibility thing might be useless as this ends up in a closure. I'm open to input.

Copy link
Member

@Dirbaio Dirbaio left a comment

Choose a reason for hiding this comment

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

lgtm! nice

@adamgreig
Copy link
Member

Supporting attributes looks good and is definitely really useful. I can't tell when the visibility spec could ever make a difference though - the only way anything outside of the macro itself can refer to the storage is by the &mut returned from the macro, so I don't think it's material whether the underlying static is pub or not. Unless there's some other compiler check I'm missing about how a reference to a static gets used?

@jordens
Copy link
Contributor Author

jordens commented Apr 9, 2024

There are certainly ways to access it other than through the &mut, e.g. with #[export_name]+extern, but for those that I can find, the visibility is immaterial. Should it stay or go?

@adamgreig
Copy link
Member

Oh, true, that wasn't possible before but I suppose it is now. I think ideally the static should not be accessible from outside the macro... but using an export_name attribute and separate extern already requires unsafe so perhaps we can allow that.

I don't think there's any point including the visibility specifier as it seems like it can never make any difference, so I'd rather remove it.

@jordens jordens changed the title singleton: forward attributes and visibility singleton: forward attributes Apr 11, 2024
@jordens
Copy link
Contributor Author

jordens commented Apr 11, 2024

@adamgreig visibility forwarding removed.

therealprof
therealprof previously approved these changes Apr 16, 2024
Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

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

LGTM

@adamgreig adamgreig added this pull request to the merge queue Apr 17, 2024
Merged via the queue into rust-embedded:master with commit 4395bae Apr 17, 2024
14 checks passed
@jordens jordens deleted the singleton-meta branch April 17, 2024 04:03
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.

forward attributes through singleton!()
4 participants