Skip to content

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
@jordens jordens deleted the singleton-meta branch April 17, 2024 04:03
adamgreig added a commit that referenced this pull request Aug 6, 2025
singleton: forward attributes
adamgreig added a commit that referenced this pull request Aug 31, 2025
singleton: forward attributes
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