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

Remove the unnecessary lang items for Send and Sync #28326

Closed
bstrie opened this issue Sep 10, 2015 · 7 comments
Closed

Remove the unnecessary lang items for Send and Sync #28326

bstrie opened this issue Sep 10, 2015 · 7 comments
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@bstrie
Copy link
Contributor

bstrie commented Sep 10, 2015

I remember @huonw telling me long ago that these lang items are unnecessary, though I don't remember if there's a good reason for why they haven't been removed yet.

@bstrie bstrie added the A-libs label Sep 10, 2015
@eefriedman
Copy link
Contributor

The lang-items are currently necessary for the following testcase to compile:

fn main() {
    let _x : Box<Fn()+Send+Sync>;
}

@Manishearth
Copy link
Member

They are necessary for the following reasons:

  • Sync has some interaction with #[thread_local] or static mut or something
  • Box<Trait+Marker> only works for language-blessed marker traits
  • I believe the compiler also heavily caches these traits

These are mostly edge cases (and even if they weren't there we would still be able to do everything), which is why we like to say that Send/Sync could be created in a library with minimal differences. But that doesn't mean they should.

@bstrie
Copy link
Contributor Author

bstrie commented Sep 10, 2015

@Manishearth RE: could vs should, IMO in the long term the caching argument is the only defensible one because that's the only one that can be considered an ignorable implementation detail. We've got this whole OIBIT thing for a reason, let's not count on lang items to shore up language deficiencies forever. (And even if OIBITs are currently unstable, presumably they won't be unstable forever.)

@arielb1
Copy link
Contributor

arielb1 commented Sep 10, 2015

@Manishearth

Ordinary statics are required to be Sync, as they are shared between all threads in a process.

@steveklabnik
Copy link
Member

steveklabnik commented Mar 8, 2017

Triage: no changes.

Tagging with lang and libs, since this would have to be coordinated between the two of them.

@steveklabnik steveklabnik added T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed A-libs labels Mar 8, 2017
@Manishearth
Copy link
Member

I don't think this is a libs issue; it's really a T-compiler issue, maybe a lang issue. The end result of this issue is that the final public language shouldn't change at all, so the lang part sort of drops out. idk.

Now, I guess a holistic solution for these would be to keep Sync a lang item (for statics) and invent a new internal attribute for traits which are allowed to be used in objects.

@steveklabnik steveklabnik added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Mar 8, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-cleanup Category: PRs that clean code up or issues documenting cleanup. label Jul 24, 2017
@leoyvens
Copy link
Contributor

#45772 did all we could do here by removing the send lang item. We need sync for statics. @Mark-Simulacrum this may be closed.

@eddyb eddyb closed this as completed Nov 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants