Skip to content

Rename @ to GC<T> #9796

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
brson opened this issue Oct 10, 2013 · 2 comments
Closed

Rename @ to GC<T> #9796

brson opened this issue Oct 10, 2013 · 2 comments

Comments

@brson
Copy link
Contributor

brson commented Oct 10, 2013

Don't have time to put a full description here, but here are some random notes.

Update this with the actual plan once we know it.

We didn't really decide anything today; just discussing how to move GC into the libs. Here are the notes.

- pcwalton: want to talk about GC, DSTs
  - `my_smart_pointer.as_ref().some_method()`
  - If we have `GC<Mut<T>>`
    - `my_smart_pointer.as_ref().as_ref().some_method()`
- You could do `fn foo(Foo<self>, ...)`
- Absolute minimum things for 1.0 if we wanted to do `@T` => `GC<T>`
  - change `@T` to `GC<T>`
  - change `@T` constructor to placement new, `in`
  - generalize explicit self to accept smart pointer declarations
    like `GC<self>`, `GC<Mut<self>>`

Unclear to me if this should work:
- GC<[T]>
- ~[T], &[T] ==>

- GC<Trait> <-- this would be nice to have, but maybe it can wait
- GC<~Trait> <-- potential workaround

- Eventually we'd probably want an overloaded `*`, but we can (for now) make GC a lang item and just do built-in deref

trait Trait {
fn foo(GC<Mut>, ...)
fn bar(&self, ...)
fn baz(&mut self, ...)
fn xyz(self, ...)
}
fn boo(Anything<I<Want>>, ...)

obj: GC<Mut>
obj.foo()
obj.as_ref().bar() <-- explicit freeze?
obj.as_mut_ref().baz() <-- explicit mut borrow?

impl Trait for GC<Mut> {
fn foo(GC<Mut) {
self: GC<Mut<GC<Mut>>>
}
fn bar(&self) {
self: &GC<Mut>
}
...
fn xyz(self) {
self: GC<Mut>
}
}


brson asks what about `fn foo(&RC<self>, ...)`.
nmatsakis: why not? should be possible to make it work
brson: would allow you to take RC<self> "by ref" (not cloning)

Nominating.

@alexcrichton
Copy link
Member

cc #7803

@brson
Copy link
Contributor Author

brson commented Oct 10, 2013

Dupe.

@brson brson closed this as completed Oct 10, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 1, 2022
Fix rust-lang#9771 (`unnecessary_to_owned` false positive)

Fixes rust-lang#9771

In that issue's example(s), the lint tried to add a `&` to a value, which implicitly changed the type of a field to a reference. The fix is to add the reference to `receiver_ty` (the type of the receiver of the `to_owned`-like method), before passing `receiver_ty` to `can_change_type`. `can_change_type` properly rejects the modified `receiver_ty`.

cc: `@mikerite` just because I think he was the author of `can_change_type`.

changelog: fix `unnecessary_to_owned` false positive which implicitly tried to change the type of a field to a reference
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

No branches or pull requests

2 participants