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

Reorganise the special traits section #149

Merged
merged 1 commit into from
Dec 10, 2017

Conversation

matthewjasper
Copy link
Contributor

@matthewjasper matthewjasper commented Nov 4, 2017

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 and RefUnwindSafe being auto traits (can probably be removed if/when auto traits are stabilised)
  • Send and Sync being used for thread safety
  • Box being fundamental (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 give UnsafeCell<T> special behaviour.
  • Primitive type implementations
  • Lang items used for the runtime or for Box<T>
  • CoerceUnsized, Unsize, NonZero

Not lang items, but maybe worth documenting:

  • IntoIterator and Option are used in for loops.

# 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
Copy link
Contributor

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.


* 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.
Copy link
Contributor

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"

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead link.

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`).
Copy link
Contributor

@Havvy Havvy Nov 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Location of Box is an unstable implementation detail. I misread this.


## `Clone`

The [`Clone`] trait is implemented by the compiler for the following types:
Copy link
Contributor

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?

## `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]
Copy link
Contributor

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".

Copy link
Contributor

@Havvy Havvy left a 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.

@Havvy
Copy link
Contributor

Havvy commented Nov 18, 2017

@matthewjasper What's that status on this and the associated PR for the stdlib docs?

@matthewjasper
Copy link
Contributor Author

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.

@Havvy
Copy link
Contributor

Havvy commented Dec 8, 2017

#146 has been merged now.

@matthewjasper
Copy link
Contributor Author

All auto traits can be added as bounds on trait objects, so I made some changes to reflect that.

@Havvy
Copy link
Contributor

Havvy commented Dec 9, 2017

You messed up your rebase and have every commit in there.

@matthewjasper
Copy link
Contributor Author

Fixed

Copy link
Contributor

@Havvy Havvy left a 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.

@Havvy Havvy merged commit 2abf0d0 into rust-lang:master Dec 10, 2017
@Havvy
Copy link
Contributor

Havvy commented Dec 10, 2017

😍 Thanks!

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Dec 15, 2017
…=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
@matthewjasper matthewjasper deleted the lang-items branch October 18, 2018 21:00
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

Successfully merging this pull request may close these issues.

2 participants