-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add a Share kind #12686
Add a Share kind #12686
Conversation
cc me |
I'm glad to see this. Can you make the followup change that converts some |
@brson the PR is not ready but I added a new commit that replaces |
Weak { ptr: self.ptr, | ||
nosend: marker::NoSend, | ||
noshare: marker::NoShare | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This style is more commonly found as:
Structure {
field1: value1,
field2: value2,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Travis seems to have a legitimate problem |
This is ready to go and looks awesome. @nikomatsakis can you review? |
I'm not sure what the effect of using |
Do we still intend to add a |
@flaper87 r+ modulo nits. I see some Travis CI failures, though? Didn't investigate. |
match expr.node { | ||
// Just visit the expression if the | ||
// item is taking an address. | ||
ast::ExprAddrOf(..) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem quite right. What about something like:
struct Wrap<T> { field: T }
static UNSAFE: Unsafe<int> = ...;
static WRAPPED_UNSAFE: Wrap<&'static Unsafe<int>> = Wrap { field: &UNSAFE };
I think I would give r+ just to get this landed (and do the cleanups I suggested as a follow-up), except that Travis reporting a 100+ character line error. |
The interner uses `RefCell` internally which opted out from Share.
We currently gather loans for static items that are defined within functions. This change enables loan gathering on static items declared globally.
`Share` implies that all *reachable* content is *threadsafe*. Threadsafe is defined as "exposing no operation that permits a data race if multiple threads have access to a &T pointer simultaneously". (NB: the type system should guarantee that if you have access to memory via a &T pointer, the only other way to gain access to that memory is through another &T pointer)... Fixes #11781 cc #12577 What this PR will do ================ - [x] Add Share kind and - [x] Replace usages of Freeze with Share in bounds. - [x] Add Unsafe<T> #12577 - [x] Forbid taking the address of a immutable static item with `Unsafe<T>` interior What's left to do in a separate PR (after the snapshot)? =========================================== - Remove `Freeze` completely
Share
implies that all reachable content is threadsafe.Threadsafe is defined as "exposing no operation that permits a data race if multiple threads have access to a &T pointer simultaneously". (NB: the type system should guarantee that if you have access to memory via a &T pointer, the only other way to gain access to that memory is through another &T pointer)...
Fixes #11781
cc #12577
What this PR will do
Unsafe<T>
type to be used as the basis forCell
,RefCell
,Atomic
, etc and removeFreeze
#12577Unsafe<T>
interiorWhat's left to do in a separate PR (after the snapshot)?
Freeze
completely