-
Notifications
You must be signed in to change notification settings - Fork 488
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
Update coherence and orphan rules documentation to match RFC 2451 #703
Conversation
src/items/coherence.md
Outdated
In languages without coherence, the compiler has to have some way to choose | ||
which implementation to use when multiple implementations could apply. Scala | ||
does this by having complex scope resolution rules for "implicit" parameters. | ||
Haskell (when a discouraged flag is enabled) does this by picking an impl |
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 entire paragraph is irrelevant. Haskell (mainly) and other languages are only interesting for the purposes of "influences".
src/items/coherence.md
Outdated
@@ -0,0 +1,79 @@ | |||
## What is coherence and why do we care? |
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.
I think this text should mainly explain that overlap is prevented (and the rules for that) and that orphans are not allowed (and the rules for that).
Question to @nikomatsakis: is the orphan rule actually part of preventing overlap in the compiler?
Hi @Centril! I made the changes you requested, and since all the terms seemed relevant I moved all of them to the glossary, making the coherence explanation much shorter so I moved it back to where it was. If you think this is too much for the glossary I can also move them back/move only some of them/etc. Your question to Niko about the orphan rule/overlap is still relevant, because the old text is not too specific there either (I changed it back to the way it was). One question about defining fundamental types: I looked for the attribute, and saw that |
@ohadravid thanks for doing this! |
src/glossary.md
Outdated
@@ -65,6 +73,13 @@ For example, `2 + (3 * 4)` is an expression that returns the value 14. | |||
An [item] that is not a member of an [implementation], such as a *free | |||
function* or a *free const*. Contrast to an [associated item]. | |||
|
|||
### Fundamental Type | |||
|
|||
Includes `&`, `&mut`, `Box` and `Pin`. Any time a type `T` is |
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.
Some points & questions (which @nikomatsakis may help with):
-
&
and friends are not types; they are type constructors. -
Suppose we have
#[fundamental] struct W<P0, P1> { ... }
. How wouldW<A0, A1>
behave with respect to locality? In this case the addition of a second type parameter is intentional so that we can suss out the essence of how fundamental types behave. It seems lifetimes have no effect on locality. -
Before itemizing the list of fundamental types it would be good to give a definition of how such types behave.
-
What about fundamental
trait
s?
No it's good. :)
I think we sorta want to give a description of behavior for any arbitrary fundamental type that is semi-syntactic in that it talks about type arguments and type constructors and how those relate wrt. locality and such. Then we can itemize a list of fundamental type constructors. |
Co-Authored-By: Mazdak Farrokhzad <[email protected]>
I applied all your edits @Centril , also edited some more title case -> sentence case and such. I changed the fundamental types part to use the type constructor wording, but I leave it to Niko to define what they are :) I did use the order of: what are fundamentals, itemized list, locality. |
@Centril @nikomatsakis I used Niko's definitions from RFC 1023. |
Filed #714 for any follow-ups to the more formal spec. |
Thanks! |
…nikomatsakis Stabilize the `re_rebalance_coherence` feature This PR stabilizes [RFC 2451](https://rust-lang.github.io/rfcs/2451-re-rebalancing-coherence.html), re-rebalance coherence. Changes include removing the attribute from tests which tested both the old and new behavior, moving the feature to `accepted` and removing the old logic. I'll also open a [PR](rust-lang/reference#703) against the reference, updating it with the content of the RFC. Closes #63599 r? @nikomatsakis
Update Cargo, books ## cargo 12 commits in 5da4b4d47963868d9878480197581ccbbdaece74..8280633db680dec5bfe1de25156d1a1d53e6d190 2019-10-28 21:53:41 +0000 to 2019-11-11 23:17:05 +0000 - Don't panic when parsing `/proc/stat` (rust-lang/cargo#7580) - Fix unused configuration key warning for a few keys under `build`. (rust-lang/cargo#7575) - Add back support for `BROWSER` envvar in `cargo doc --open`. (rust-lang/cargo#7576) - Only include "already existing ..." comment in gitignore on conflict (rust-lang/cargo#7570) - Add VS Code user dir to .gitignore (rust-lang/cargo#7578) - Added aliases to subcommand typo suggestions. (rust-lang/cargo#7486) - Use multiple requirement syntax consistently (rust-lang/cargo#7573) - Update verison to 0.42 (rust-lang/cargo#7568) - Expand documentation on build scripts. (rust-lang/cargo#7565) - Update crossbeam-utils requirement from 0.6 to 0.7 (rust-lang/cargo#7566) - don't download std-docs on CI (rust-lang/cargo#7513) - Change my-buddy to github-handle (rust-lang/cargo#7553) ## nomicon 2 commits in 5004ad30d69f93553ceef74439fea2159d1f769e..58e36e0e08dec5a379ac568827c058e25990d6cd 2019-10-12 19:52:40 +0200 to 2019-10-30 08:14:24 -0500 - remove references to the nursery - Add github action to replace Travis.yml (rust-lang/nomicon#172) ## reference 7 commits in 4b21b64..45558c4 2019-10-27 22:33:11 +0100 to 2019-11-08 14:47:35 +0100 - Audit code blocks. (rust-lang/reference#715) - Update coherence and orphan rules documentation to match RFC 2451 (rust-lang/reference#703) - Update organization name (rust-lang/reference#713) - State that no_implicit_prelude also applies to nested modules (rust-lang/reference#707) - expand Copy docs (rust-lang/reference#711) - github action doesn't use the nursery (rust-lang/reference#706) - Migrate to GitHub Actions. (rust-lang/reference#705) ## book 1 commits in 28fa3d15b0bc67ea5e79eeff2198e4277fc61baf..e79dd62aa63396714278d484d91d48826737f47f 2019-10-29 07:16:09 -0500 to 2019-10-30 07:33:12 -0500 - No need for an iterator here to fetch values (rust-lang/book#1957) ## rust-by-example 1 commits in f3197ddf2abab9abdbc029def8164f4a748b0d91..dcee312c66267eb5a2f6f1561354003950e29105 2019-10-29 10:17:40 -0300 to 2019-10-31 11:26:53 -0300 - refactor: simplify extracting Result from Option (rust-lang/rust-by-example#1283) ## edition-guide 2 commits in e58bc4ca104e890ac56af846877c874c432a64b5..f553fb26c60c4623ea88a1cfe731eafe0643ce34 2019-07-31 20:14:12 +0200 to 2019-10-30 08:27:42 -0500 - remove old references to the nursery - Port from Travis to GitHub Actions (rust-lang/edition-guide#192)
As part of stabilizing RFC 2451 (re-rebalance coherence) in rust-lang/rust#65879, I wanted to update the reference to match it.
I copied the relevant parts of the RFC, with a slight rewording by @nikomatsakis (comment).