-
Notifications
You must be signed in to change notification settings - Fork 506
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
Arbitrary self types v2: update reference. #1699
Draft
adetaylor
wants to merge
4
commits into
rust-lang:master
Choose a base branch
from
adetaylor:arbitrary-self-types-v2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,34 +17,12 @@ r[lang-types.box.deref] | |
* The [dereference operator] for `Box<T>` produces a place which can be moved | ||
from. This means that the `*` operator and the destructor of `Box<T>` are | ||
built-in to the language. | ||
|
||
r[lang-types.box.receiver] | ||
* [Methods] can take `Box<Self>` as a receiver. | ||
|
||
r[lang-types.box.fundamental] | ||
* A trait may be implemented for `Box<T>` in the same crate as `T`, which the | ||
[orphan rules] prevent for other generic types. | ||
|
||
<!-- Editor Note: This is nowhere close to an exhaustive list --> | ||
|
||
r[lang-types.rc] | ||
## `Rc<T>` | ||
|
||
r[lang-types.rc.receiver] | ||
[Methods] can take [`Rc<Self>`] as a receiver. | ||
|
||
r[lang-types.arc] | ||
## `Arc<T>` | ||
|
||
r[lang-types.arc.receiver] | ||
[Methods] can take [`Arc<Self>`] as a receiver. | ||
|
||
r[lang-types.pin] | ||
## `Pin<P>` | ||
|
||
r[lang-types.pin.receiver] | ||
[Methods] can take [`Pin<P>`] as a receiver. | ||
|
||
r[lang-types.unsafe-cell] | ||
## `UnsafeCell<T>` | ||
|
||
|
@@ -73,7 +51,19 @@ r[lang-types.deref] | |
## `Deref` and `DerefMut` | ||
|
||
As well as overloading the unary `*` operator, [`Deref`] and [`DerefMut`] are | ||
also used in [method resolution] and [deref coercions]. | ||
also used in [deref coercions]; see also [`Receiver`] below. | ||
|
||
r[lang-types.receiver] | ||
## `Receiver` | ||
|
||
[`Receiver`] is used in [method resolution]. It indicates that a type may be | ||
used as a method receiver; that is, the type of a `self` parameter for a | ||
method. There is a blanket implementation of `Receiver` for all `T: Deref`, | ||
so it's rare to implement `Receiver` directly: you'd only normally do this | ||
for smart pointer types which for some reason can't implement `Deref`. | ||
Comment on lines
+62
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd probably remove this bit about it being rare and instead describe affirmatively why |
||
Built-in types which implement `Receiver` (via `Deref`) and are commonly | ||
used as method receivers include `Rc<T>`, `Arc<T>`, `Box<T>`, and `Pin<P>` | ||
where `P: Deref`. | ||
|
||
r[lang-types.drop] | ||
## `Drop` | ||
|
@@ -218,6 +208,7 @@ These implicit `Sized` bounds may be relaxed by using the special `?Sized` bound | |
[`DerefMut`]: std::ops::DerefMut | ||
[`Pin<P>`]: std::pin::Pin | ||
[`Rc<Self>`]: std::rc::Rc | ||
[`Receiver`]: std::ops::Receiver | ||
[`RefUnwindSafe`]: std::panic::RefUnwindSafe | ||
[`Termination`]: std::process::Termination | ||
[`UnwindSafe`]: std::panic::UnwindSafe | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is better, but still some things we can improve:
T
, add ... to the list"), but we don't mean the list of "candidate types" as defined later, we mean the list of "contributing types". The word "candidate" is also used further below in a seemingly-inconsistent way.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.
Agreed with all your points other than this one:
It is of semantic relevance - it says this, which you may have overlooked:
I'll have another crack at it.
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.
Great, thanks. Did miss that bit.