-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 trait for smart pointer dereference #7141
Comments
Visiting for bug triage, email from 2013-08-12 (Thinking off the top of my head, the GC guy in me figures we might need or at least want to have two methods in the Trait, or via some other analogous manner provide information about whether the context of the invocation is |
Also, I think pcwalton's blog post and his plans for smart-pointers, moving GC to a library, etc, are relevant material here. |
Being able to override dereference is looking increasingly important as we jettison pointer types, and probably newtype dereferencing (#6246), from the language. Nominating. |
cc me |
i'm not sure what I was thinking in my first comment above, since @thestinger is clearly talking about pointer-dereference, not memory allocation. |
accepted for 1.0 backcompat lang. |
Nominating as I believe this is out of scope for 1.0. We can just special case |
What about |
deferring decision about any change in p-status for this bug until we can meet with pcwalton |
leaving on 1.0 for now. (If later work with box construct proves it to be unneeded, we'll remove it then.) |
I'd love to see this for use in |
I've been wanting to write up something more detailed but failing, so let me sketch out the design I had in mind. Basically we had two traits:
The structure of these traits encodes an "inherited mutability" like structure -- in other words, these traits can faithfully model I don't intend to ever permit smart pointers that act like
I think the implementation here has to go in two phases:
For step 1, one challenge is that we have to instrument type check to pass down more context. In particular, to type check an expression, we have to know whether it is in a "mutable lvalue" context or not. For example, when we type check the expression The other challenge is that the trait returns a reference
The adjustment data structure itself could be refactored to make this nicer (into something more layerable, like a cons list of adjustments), but I'd hold off on that since it's adequate for the current purpose. OK, that's a high-level sketch, happy to provide more details on request. |
(And I do plan to write up a proper RFC with more details and examples... but I'm working on several of those) |
Ah, one other comment: I have intentionally not provided a way to move out of a |
Actually, thinking more, I think it's plausible to support an additional trait:
But it should be added as a later step, because there are some significant complications (actually similar to support auto-deref). Basically we have to first type one way (assuming no move, most likely) and then go back and patch things up once we know the type of Note that I've been careful to ensure that, if you implement |
@nikomatsakis wrote:
We used to have (edit: I mean "first-class smart pointer" in the sense that one could do |
Did you mean "isn't"? (I hope so, otherwise I understand nothing.) If you wanted to copy out a POD type wouldn't
I also don't quite grok this... was this meant to be called |
@glaebhoerl indeed, I meant isn't, and I think the
|
Remove leftover plugin conf_file code changelog: none Removes dead code that used to support the following syntax: ```rust #![plugin(clippy(conf_file="path/to/clippy's/configuration"))] ``` RLS (and others?) will need to remove the `&[]` from `clippy_lints::read_conf(&[], sess)`. r? `@flip1995`
At a minimum, a trait for obtaining an immutable reference from a type used to overload
*x
and&*x
.Obtaining mutable references and moving out of pointers can be left out, as they're only useful on a unique pointer type. It can be revisited in the future if a compelling use case ever comes up.
The text was updated successfully, but these errors were encountered: