Skip to content

add #[non_owned] and #[mutable] attributes #6251

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

Closed
wants to merge 4 commits into from
Closed

add #[non_owned] and #[mutable] attributes #6251

wants to merge 4 commits into from

Conversation

thestinger
Copy link
Contributor

Also fixed the docstring on TC_ONCE_CLOSURE (was accidentally the same as TC_MUTABLE) and shifted the TC_EMPTY_ENUM bit left by one since whatever previously used that bit has been removed.

@brson
Copy link
Contributor

brson commented May 5, 2013

What is the effect of being #[non_owned]? Does a struct being non-owned impact which heap is used to allocate a ~? If a non-owned struct allocated in a ~ actually uses the local heap then that will invoke the GC, defeating the purpose of using non-owned smart pointers.

I am still not clear on the impact of non-owned. Is there consensus on how this is supposed to work? I am worried that there are a lot of 'cracks' in the type system and things are not fitting together as well as they should.

@thestinger
Copy link
Contributor Author

@brson: I think the effect of not being Owned is just that it's non-sendable. A struct containing borrowed pointers isn't Owned so it definitely shouldn't be used as the deciding factor for local heap allocation (TC_MANAGED would make more sense for that AFAIK).

@pcwalton
Copy link
Contributor

pcwalton commented May 6, 2013

I think I'd prefer #[unsafe_mutable] to #[mutable] — people are going to add #[mutable] to their structs and wonder why they aren't mutable. I'm OK with that being done in a followup though.

@thestinger
Copy link
Contributor Author

@pcwalton: maybe #[non_const] to go along with #[non_owned], since const will only be used for the Const trait. I was actually going to call it that originally but I went with mutable when I realized I didn't have to add TC_NON_CONST - but that's not really a good reason :).

@sanxiyn
Copy link
Member

sanxiyn commented May 7, 2013

CC #5601.

bors added a commit that referenced this pull request May 7, 2013
Also fixed the docstring on `TC_ONCE_CLOSURE` (was accidentally the same as `TC_MUTABLE`) and shifted the `TC_EMPTY_ENUM` bit left by one since whatever previously used that bit has been removed.
@bors bors closed this May 7, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 3, 2020
flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 3, 2020
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.

5 participants