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

Rc and Arc should be marked #[fundamental] #24317

Open
P1start opened this Issue Apr 11, 2015 · 7 comments

Comments

Projects
None yet
10 participants
@P1start
Copy link
Contributor

P1start commented Apr 11, 2015

Box is already, so I think all other pointer types probably should be too.

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Apr 11, 2015

cc @nikomatsakis

(I'm not sure I agree with the assertion made here, but it seems like it would be good to talk about it, and then either improve the docs to explain why one should not, or actually do it.)

@nagisa

This comment has been minimized.

Copy link
Contributor

nagisa commented Apr 13, 2015

Box is just a wrapper around plain pointer, while Rc and Arc are not. This is also https://github.com/rust-lang/rfcs material.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Apr 13, 2015

My feeling is that making Rc, Arc, and other "smart pointer" types "fundamental" probably does make sense, but I'm still reluctant to use this attribute too widely until we have a better feeling for what changes (if any) we want to make to coherence. i.e., is #[fundamental] the actual scheme that we want or what?

If we do decide the fundamental IS the scheme we want, then I would probably apply it to:

  1. smart pointers, by convention.
  2. ops traits, just because it's easy enough to remember.

These would be generalization of the existing types (Box) and traits (Fn, etc) that are marked as fundamental.

@aturon

This comment has been minimized.

Copy link
Member

aturon commented Jan 20, 2016

I definitely don't think we should make this step just for the sake of uniformity. As @nikomatsakis alludes to, we probably want to drop #[fundamental] in favor of some other approach in the future, and so I think we should avoid using it as much as possible in the meantime.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jan 21, 2016

We discussed this in the libs team triage yesterday and as @aturon mentioned we'd like to avoid more #[fundamental] types if possible (as mentioned by @aturon), so closing.

@aturon aturon reopened this Nov 13, 2017

@aturon aturon removed the I-nominated label Nov 13, 2017

@cramertj

This comment has been minimized.

Copy link
Member

cramertj commented Nov 13, 2017

I've been wanting this several times recently when implementing some traits with functions which take &mut self, but many impls of which actually only need &self. I'd love to be able to write impl MyTrait for Arc/Rc<MyType> (&'a doesn't work because I need to pass a 'static type). My current workaround is to make a wrapper type struct MyWrapper(Arc<MyType>) and do impl MyTrait for MyWrapper. This is annoying, and it seems unnecessary.

While I understand the justification for wanting to avoid #[fundamental], I think that smart-pointer types such as Rc and Arc should work the same as & and Box from a coherence perspective.

@cramertj

This comment has been minimized.

Copy link
Member

cramertj commented Dec 18, 2018

I keep coming back to this and am pretty confident that, given that &mut, &, Box, and Pin are all #[fundamental], Arc and Rc should be as well. I can't come up with a justification for these types behaving inconsistently. I understand the reluctance to add more #[fundamental] types since it spreads a system we're not confident in the workings of, and I'd be opposed to adding #[fundamental] to other non-ptr-related types in stdlib just for the convenience of it, but I think it's more important that our pointer types behave consistently with one another. I've opened #5695 -- feel free to close if you decide it's still unwanted.

bors added a commit that referenced this issue Dec 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.