-
Notifications
You must be signed in to change notification settings - Fork 492
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
Reorganise the special traits section #149
Conversation
src/special-types-and-traits.md
Outdated
# Special types and traits | ||
|
||
Certain types and traits that exist in [the standard library] are known to the | ||
Rust compiler (usually by [lang items]). This chapter documents the special |
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.
Language items are unstable, and per #119, we don't want to document unstable things, we shouldn't link or talk about them.
src/special-types-and-traits.md
Outdated
|
||
* The [dereference operator] for `Box<T>` produces an lvalue which can be moved | ||
from. This means that the `*` operator and the destructor of `Box<T>` are | ||
built in to the language. |
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.
"built into" or "built-in to"
src/special-types-and-traits.md
Outdated
from. This means that the `*` operator and the destructor of `Box<T>` are | ||
built in to the language. | ||
* [Methods] can take `Box<Self>` as a receiver. | ||
* For the purpose of the [orphan rules], `Box<T>` is treated as being defined in |
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.
Dead link.
src/special-types-and-traits.md
Outdated
built in to the language. | ||
* [Methods] can take `Box<Self>` as a receiver. | ||
* For the purpose of the [orphan rules], `Box<T>` is treated as being defined in | ||
the same crate as `T` (rather than in `alloc`). |
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.
Location of I misread this.Box
is an unstable implementation detail.
src/special-types-and-traits.md
Outdated
|
||
## `Clone` | ||
|
||
The [`Clone`] trait is implemented by the compiler for the following types: |
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.
Perhaps a note that it's not special, except that it is a bounds on the Copy trait?
src/special-types-and-traits.md
Outdated
## `Sized` | ||
|
||
The [`Sized`] trait indicates that the size of this type is known at | ||
compile-time, that is, it's not a [dynamically sized type]. [Type parameters] |
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.
Should be a semicolon after "compile-time".
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.
All minor nits. Looks good to me otherwise.
@matthewjasper What's that status on this and the associated PR for the stdlib docs? |
I was hoping that #146 would be merged so that I could link to it for orphan rules. I can just remove the link for now though. |
#146 has been merged now. |
All auto traits can be added as bounds on trait objects, so I made some changes to reflect that. |
You messed up your rebase and have every commit in there. |
1fb1e53
to
a68b9e5
Compare
Fixed |
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.
There's an unused link ref (lang items), but let's not block this PR anymore on something that can be handled quickly in another PR.
😍 Thanks! |
…=steveklabnik Use a better link for method resolution in Deref docs rust-lang/reference#149 breaks these links, so make them point to somewhere which won't break and provides a more deatailed description of method resolution. cc @Havvy r? @steveklabnik
Moves this all into one page. Expands this section to document special types as well.
Doesn't change the wording much for the traits that already had pages.
Uses the nomicon pages for variance (for now) and dropck.
This does break a 2 links in std that should really point to the documentation for method name resolution, PR for that soon.
cc rust-lang/rust#44496 (RFC 2133)
Things that aren't lang items, but do appear here:
Send
,Sync
,UnwindSafe
andRefUnwindSafe
being auto traits (can probably be removed if/when auto traits are stabilised)Send
andSync
being used for thread safetyBox
beingfundamental
(will link to text in Implementations improvements part 1 #146 once that's merged)Lang items that don't appear here:
Debug
: this is used for the missing debug lint.drop_in_place
: not really different to intrinsics.Freeze
: Used to giveUnsafeCell<T>
special behaviour.Box<T>
CoerceUnsized
,Unsize
,NonZero
Not lang items, but maybe worth documenting:
IntoIterator
andOption
are used infor
loops.