-
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
Add basic GATs reference information #1265
Conversation
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.
Also in src/items/associated-items.md:207
:
This paragraph gives a wordy description of syntax for associated type declarations. This isn't very easy to follow and isn't updated regarding GATs. I suggest something like the following:
An associated type declaration declares a signature for associated type definitions. It is written in one of the following forms, where
Assoc
is the name of the associated type,Params
is a comma-separated list of type, lifetime or const parameters,Bounds
is a plus-separated list of trait bounds on the associated type, andWhereBounds
is a comma-separated list of bounds on parameters:type Assoc; type Assoc: Bounds; type Assoc<Params>; type Assoc<Params>: Bounds; type Assoc<Params> where WhereBounds; type Assoc<Params>: Bounds where WhereBounds;
Similarly for assoc. type definitions, para from line 215.
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.
Does anything about where
clauses like, e.g., Self: 'a
, need to be added here? I'm thinking about this specifically: https://rust-lang.github.io/generic-associated-types-initiative/explainer/required_bounds.html
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.
Thanks for posting this!
Unfortunately I don't know enough to even get started on what to cover. I see things like the Object safety list needs to be updated?
I can try to add a short explanation |
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 looks good. I have a few minor suggestions, @jackh726.
type Assoc; | ||
type Assoc: Bounds; | ||
type Assoc<Params>; | ||
type Assoc<Params>: Bounds; |
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.
It occurs to me that it would be worth clarifying the distinction between Bounds
and WhereBounds
!
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.
That is stated in the paragraph above? Should we be more detailed?
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 we could be more explicit. Left some suggestions. WDYT?
src/items/type-aliases.md
Outdated
A type alias with the [_Type_] specification may only appear as an | ||
[associated type] in a [trait 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 clause by itself doesn't seem to be correct to me. It seems to imply that the following is not allowed:
type X = i32;
Perhaps this could be turned around so that it specifically says what a trait impl associated type needs? A sentence could be added to the previous paragraph, since they are talking about the same thing. Maybe something like this:
A type alias without the [Type] specification may only appear as an [associated type] in a [trait].
Associated types in a [trait impl] must include the [Type] specification.
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've made a separate paragraph for each for of type aliases, to be specific about what is allow, what is required, and what isn't allowed in each.
src/items/associated-items.md
Outdated
lifetime or const parameters, `Bounds` is a plus-separated list of trait bounds | ||
on the associated type, and `WhereBounds` is a comma-separated list of bounds on | ||
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.
lifetime or const parameters, `Bounds` is a plus-separated list of trait bounds | |
on the associated type, and `WhereBounds` is a comma-separated list of bounds on | |
parameters: | |
lifetime or const parameters, `Bounds` is a plus-separated list of trait bounds | |
that the associated type must meet, and `WhereBounds` is a comma-separated list of bounds that the parameters must meet: |
type Assoc<Params>: Bounds; | ||
type Assoc<Params> where WhereBounds; | ||
type Assoc<Params>: Bounds where WhereBounds; | ||
``` |
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.
Maybe something like
Relationship between Bounds
and WhereBounds
In this example:
trait Example {
type Output<T>: Ord where T: Debug
}
Given a reference to the associated type like <X as Example>::Output<Y>
, the associated type itself must be Ord
, and the type Y
must be Debug
.
type Assoc; | ||
type Assoc: Bounds; | ||
type Assoc<Params>; | ||
type Assoc<Params>: Bounds; |
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 we could be more explicit. Left some suggestions. WDYT?
Update books ## reference 4 commits in f6ed74f582bddcec73f753eafaab3749c4f7df61..4ea7c5def38ac81df33a9e48e5637a82a5ac404d 2022-10-08 02:43:26 -0700 to 2022-10-25 15:14:36 -0700 - Document Half Open Range Patterns + Improve Range Patterns in General (rust-lang/reference#1274) - clarifying which row contains the example (rust-lang/reference#1287) - Add `sym` operands for inline assembly (rust-lang/reference#1270) - Add basic GATs reference information (rust-lang/reference#1265) ## book 141 commits in f1e5ad844d0c61738006cdef26227beeb136948e..aa5ee485bd6bd80d205da7c82fcdd776f92fdd51 2022-09-19 09:48:21 -0400 to 2022-10-20 16:49:55 -0400 - Remove Turkish translation - Update chapter 4 from latest print edits - Update chapter 3 from latest print edits - Clarify division truncates toward zero. Fixes rust-lang/book#2856. - Update chapter 2 from latest print edits - Fix a problem with literal style ending - Explain both kinds of format string arguments - Update chapter 1 from latest print edits - Snapshot consolidated appendices - Fix ListNumber0, newlines after lists - Don't match nodes without anything - Handle listing numbers in appendices too - Regenerate everything - Fix chapter numbers in word doc so they're in the XML - Number Table captions too - Handle figures too - Regenerate ch4 - Handle listing numbers - Regenerate ch13 - Regenerate ch12 - Regenerate ch11 - Regenerate chapter 10 - Fix ListBullet0 - Handle ending of BoxCode better - Regenerate chapter 9 - Regenerate ch8 - Make RunInHead consistent-ish - Fix extra newline before boxes - Fix Box RunIn Head/Para - Fix newline after RunInHead/Para - Regenerate ch7 - Fix QuotePara - Fix ListPlain - Regenerate ch6 - Fix BoxCode - Regenerate chapter 5 - Fix GraphicSlug and CaptionLine - Regenerate snapshot of chapter 4 - Fix boxes a bit - Add a shellcheck ignore - Handle BoxListBullet - Handle superscript - Regenerate ch3 from xml and fix tables - Fix italics and whitespace interactions - Fix italic preceding/following - Fix preceding/following xpaths again - Fix italics - Fix code blocks - Fix more last bullets in lists - Fix box newlines - Fix last bullet in a list - Fix BoxType - Fix notes - Fix literals - Add the no editing warning at the top when getting snapshots from docx - Make the snapshot of the frontmatter nicer - Updates to appendixes C, D, and E after copyedit checks - Snapshots after copyedit checks of appendices a and b + recheck of 20 - Snapshot of appendices from copyedit - Updated snapshot of the appendices - Re-checks of chapter 19 - Re-checks of chapter 18 - Messy snapshot of chapter 20 after copyedit checks - Snapshot of ch20 after copyedit - Updated snapshot of chapter 20 - Messy snapshot of chapter 19 after copyedit checks - Snapshot of ch19 after copyedit - Updated snapshot of ch19 - Messy snapshot of ch 18 after copyedit review - Snapshot of ch 18 after copyedit - Update snapshot of ch18 - Messy snapshot of ch 17 after copyedit review - Snapshot of ch17 copyedit - Updated snapshot of ch17 - Messy snapshot of ch16 after copyedit - Snapshot of ch16 copyedited - Updated snapshot of ch16 - Messy snapshot of ch 15 after copyedit checks - Re-review of earlier chapters - Snapshot of ch15 copyedit - Update snapshot of ch15 - Messy snapshots of other chapters with indentation fixed - Messy snapshot of ch2 with indentation fixed - Add unittests to the allowed words - Messy snapshot of chapter 14 after checking copyedit - Snapshot of chapter 14 after copyedit - Update snapshot of ch14 - Regenerate manual output for chapter 14 - Messy snapshot of chapter 13 after copyedit check - Updated snapshot of ch13 after copyedit - Updated snapshot of ch13 - Messy snapshot of chapter 12 after copyedit checks - Snapshot of chapter 12 copyedited - Update snapshot for chapter 12 - Messy snapshot of chapter 11 after copyedit check - Snapshot of chapter 11 copyedited - Updated snapshot of chapter 11 - Messy snapshot of chapter 10 after copyedit check - Snapshot of chapter 10 copyedit - Updated snapshot of chapter 10 - Messy snapshot of ch9 after copyedit checks - Snapshot of ch 9 copyedit - Update snapshot of chapter 9 - Messy snapshot of chapter 8 - Update println style in ch8 - Snapshot of chapter 8 from copyedit - Updated snapshot of chapter 8 - Rearrange my notes yet again - Messy snapshot of ch7 after copyedit checks - Snapshot of chapter 7 from copyedit, fix chapter 6 name - Update snapshot of chapter 7 - Messy snapshot of chapter 6 after copyedit check - Update snapshot of chapter 6 - Change my notes again - Messy snapshot of chapter 5 after checking copyedit - Snapshot of chapter 5 from copyedit - Messy snapshot of chapter 4 after copyedit check - Changing my notes again - Snapshot of ch4 from nostarch - Messy snapshot of chapter 3 after copyedit check, ch4 on start check - Snapshot of ch3 from nostarch - Updated snapshot of ch3 - reorder notes - Messy snapshot of chapter 1 after copyedit check - Snapshot of ch01 docx from nostarch - Updated snapshot of chapter 1 - Messy snapshot of frontmatter docx - Another snapshot to fix the crab pinchers description - Messy snapshot of chapter 2 docx - Get the latest snapshot of chapter 2 - Upgrade to rand 0.8.5 - Notes to self - Update xsl and take snapshots from docx, such as they are - Update instructions on docx -> md now that I've done it again - Propagate frontmatter edits to src - Updated snapshots extracted from frontmatter - Support different styles in the docx - Line wrap bio - Frontmatter from word doc - Edits to docx files for nostarch - docx files from nostarch ## rust-by-example 6 commits in 5e7b296d6c345addbd748f242aae28c42555c015..03491f33375c5a2a1661c7fa4be671fe95ce1249 2022-10-05 08:24:45 -0300 to 2022-10-21 07:30:08 -0300 - fix rust-lang/rust-by-example#1628: the box pointer is on stack not on heap (rust-lang/rust-by-example#1629) - fix rust-lang/rust-by-example#1608: out-of-bound indexing is a runtime error (not a compile-time error) (rust-lang/rust-by-example#1626 ) - Fix: Path internal representation and conversions (rust-lang/rust-by-example#1625) - fix crate name in example (rust-lang/rust-by-example#1620) - avoid reserved keyword try as crate name (rust-lang/rust-by-example#1619) - Fix typo in iter_result.md (rust-lang/rust-by-example#1614) ## rustc-dev-guide 7 commits in 7518c3445dc02df0d196f5f84e568d633c5141fb..51a37ad19a15709d0601afbac6581f5aea6a45da 2022-10-08 12:29:47 +0200 to 2022-10-25 10:18:58 -0700 - Update `traits/resolution.md` (rust-lang/rustc-dev-guide#1494) - Update diagnostics to flat fluent message paths - Update rust-analyzer suggestions (rust-lang/rustc-dev-guide#1487) - miri is no longer a submodule but a subtree. (rust-lang/rustc-dev-guide#1488) - fix some links (rust-lang/rustc-dev-guide#1490) - typo and grammar (rust-lang/rustc-dev-guide#1484) - Add missing prerequisite for some Linux distros (rust-lang/rustc-dev-guide#1481)
Update books ## reference 4 commits in f6ed74f582bddcec73f753eafaab3749c4f7df61..4ea7c5def38ac81df33a9e48e5637a82a5ac404d 2022-10-08 02:43:26 -0700 to 2022-10-25 15:14:36 -0700 - Document Half Open Range Patterns + Improve Range Patterns in General (rust-lang/reference#1274) - clarifying which row contains the example (rust-lang/reference#1287) - Add `sym` operands for inline assembly (rust-lang/reference#1270) - Add basic GATs reference information (rust-lang/reference#1265) ## book 141 commits in f1e5ad844d0c61738006cdef26227beeb136948e..aa5ee485bd6bd80d205da7c82fcdd776f92fdd51 2022-09-19 09:48:21 -0400 to 2022-10-20 16:49:55 -0400 - Remove Turkish translation - Update chapter 4 from latest print edits - Update chapter 3 from latest print edits - Clarify division truncates toward zero. Fixes rust-lang/book#2856. - Update chapter 2 from latest print edits - Fix a problem with literal style ending - Explain both kinds of format string arguments - Update chapter 1 from latest print edits - Snapshot consolidated appendices - Fix ListNumber0, newlines after lists - Don't match nodes without anything - Handle listing numbers in appendices too - Regenerate everything - Fix chapter numbers in word doc so they're in the XML - Number Table captions too - Handle figures too - Regenerate ch4 - Handle listing numbers - Regenerate ch13 - Regenerate ch12 - Regenerate ch11 - Regenerate chapter 10 - Fix ListBullet0 - Handle ending of BoxCode better - Regenerate chapter 9 - Regenerate ch8 - Make RunInHead consistent-ish - Fix extra newline before boxes - Fix Box RunIn Head/Para - Fix newline after RunInHead/Para - Regenerate ch7 - Fix QuotePara - Fix ListPlain - Regenerate ch6 - Fix BoxCode - Regenerate chapter 5 - Fix GraphicSlug and CaptionLine - Regenerate snapshot of chapter 4 - Fix boxes a bit - Add a shellcheck ignore - Handle BoxListBullet - Handle superscript - Regenerate ch3 from xml and fix tables - Fix italics and whitespace interactions - Fix italic preceding/following - Fix preceding/following xpaths again - Fix italics - Fix code blocks - Fix more last bullets in lists - Fix box newlines - Fix last bullet in a list - Fix BoxType - Fix notes - Fix literals - Add the no editing warning at the top when getting snapshots from docx - Make the snapshot of the frontmatter nicer - Updates to appendixes C, D, and E after copyedit checks - Snapshots after copyedit checks of appendices a and b + recheck of 20 - Snapshot of appendices from copyedit - Updated snapshot of the appendices - Re-checks of chapter 19 - Re-checks of chapter 18 - Messy snapshot of chapter 20 after copyedit checks - Snapshot of ch20 after copyedit - Updated snapshot of chapter 20 - Messy snapshot of chapter 19 after copyedit checks - Snapshot of ch19 after copyedit - Updated snapshot of ch19 - Messy snapshot of ch 18 after copyedit review - Snapshot of ch 18 after copyedit - Update snapshot of ch18 - Messy snapshot of ch 17 after copyedit review - Snapshot of ch17 copyedit - Updated snapshot of ch17 - Messy snapshot of ch16 after copyedit - Snapshot of ch16 copyedited - Updated snapshot of ch16 - Messy snapshot of ch 15 after copyedit checks - Re-review of earlier chapters - Snapshot of ch15 copyedit - Update snapshot of ch15 - Messy snapshots of other chapters with indentation fixed - Messy snapshot of ch2 with indentation fixed - Add unittests to the allowed words - Messy snapshot of chapter 14 after checking copyedit - Snapshot of chapter 14 after copyedit - Update snapshot of ch14 - Regenerate manual output for chapter 14 - Messy snapshot of chapter 13 after copyedit check - Updated snapshot of ch13 after copyedit - Updated snapshot of ch13 - Messy snapshot of chapter 12 after copyedit checks - Snapshot of chapter 12 copyedited - Update snapshot for chapter 12 - Messy snapshot of chapter 11 after copyedit check - Snapshot of chapter 11 copyedited - Updated snapshot of chapter 11 - Messy snapshot of chapter 10 after copyedit check - Snapshot of chapter 10 copyedit - Updated snapshot of chapter 10 - Messy snapshot of ch9 after copyedit checks - Snapshot of ch 9 copyedit - Update snapshot of chapter 9 - Messy snapshot of chapter 8 - Update println style in ch8 - Snapshot of chapter 8 from copyedit - Updated snapshot of chapter 8 - Rearrange my notes yet again - Messy snapshot of ch7 after copyedit checks - Snapshot of chapter 7 from copyedit, fix chapter 6 name - Update snapshot of chapter 7 - Messy snapshot of chapter 6 after copyedit check - Update snapshot of chapter 6 - Change my notes again - Messy snapshot of chapter 5 after checking copyedit - Snapshot of chapter 5 from copyedit - Messy snapshot of chapter 4 after copyedit check - Changing my notes again - Snapshot of ch4 from nostarch - Messy snapshot of chapter 3 after copyedit check, ch4 on start check - Snapshot of ch3 from nostarch - Updated snapshot of ch3 - reorder notes - Messy snapshot of chapter 1 after copyedit check - Snapshot of ch01 docx from nostarch - Updated snapshot of chapter 1 - Messy snapshot of frontmatter docx - Another snapshot to fix the crab pinchers description - Messy snapshot of chapter 2 docx - Get the latest snapshot of chapter 2 - Upgrade to rand 0.8.5 - Notes to self - Update xsl and take snapshots from docx, such as they are - Update instructions on docx -> md now that I've done it again - Propagate frontmatter edits to src - Updated snapshots extracted from frontmatter - Support different styles in the docx - Line wrap bio - Frontmatter from word doc - Edits to docx files for nostarch - docx files from nostarch ## rust-by-example 6 commits in 5e7b296d6c345addbd748f242aae28c42555c015..03491f33375c5a2a1661c7fa4be671fe95ce1249 2022-10-05 08:24:45 -0300 to 2022-10-21 07:30:08 -0300 - fix rust-lang/rust-by-example#1628: the box pointer is on stack not on heap (rust-lang/rust-by-example#1629) - fix rust-lang/rust-by-example#1608: out-of-bound indexing is a runtime error (not a compile-time error) (rust-lang/rust-by-example#1626 ) - Fix: Path internal representation and conversions (rust-lang/rust-by-example#1625) - fix crate name in example (rust-lang/rust-by-example#1620) - avoid reserved keyword try as crate name (rust-lang/rust-by-example#1619) - Fix typo in iter_result.md (rust-lang/rust-by-example#1614) ## rustc-dev-guide 7 commits in 7518c3445dc02df0d196f5f84e568d633c5141fb..51a37ad19a15709d0601afbac6581f5aea6a45da 2022-10-08 12:29:47 +0200 to 2022-10-25 10:18:58 -0700 - Update `traits/resolution.md` (rust-lang/rustc-dev-guide#1494) - Update diagnostics to flat fluent message paths - Update rust-analyzer suggestions (rust-lang/rustc-dev-guide#1487) - miri is no longer a submodule but a subtree. (rust-lang/rustc-dev-guide#1488) - fix some links (rust-lang/rustc-dev-guide#1490) - typo and grammar (rust-lang/rustc-dev-guide#1484) - Add missing prerequisite for some Linux distros (rust-lang/rustc-dev-guide#1481)
There really isn't a ton to add here. Almost all of the syntax related to GATs falls out from existing syntax.