-
Notifications
You must be signed in to change notification settings - Fork 521
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
Document lang items #1119
Document lang items #1119
Conversation
This is nice. I want to cc @roxelo who recently had to add lang-items and so forth. Would this text have been helpful? Are there things you had to figure out that are worth including? One thing I would like to see:
|
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 left a few copy edits and clarifications of things that seemed ambiguous.
|
||
You can find language items in the following places: | ||
- An exhaustive reference in the compiler documentation: [`rustc_hir::LangItem`] | ||
- An auto-generated list with source locations by using ripgrep: `rg '#\[.*lang =' library/` |
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.
- An auto-generated list with source locations by using ripgrep: `rg '#\[.*lang =' library/` | |
- An auto-generated list with source locations in the standard library by using ripgrep: `rg '#\[.*lang =' library/` |
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 don't think this is more clear. I could say "A list of items in the standard library, along with their sources, by using ripgrep" if you like.
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 suggested that just to make it clear that language items can be defined outside of the standard library, and that these source locations are specifically the ones defined by the standard library.
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 that's too much nuance to pack into 4 words. Defining lang-items outside the standard library is pretty rare - I can add a section if you like, but I don't think it belongs here.
Co-authored-by: Camelid <camelidcamel@gmail.com>
@nikomatsakis when should someone create a lang item instead of using a |
I don't know, but just guessing, I would say that the compiler may give special behavior for a lang item (e.g., for Also, lang items can be used by the standard library or by user libraries, whereas
|
|
||
You can find language items in the following places: | ||
- An exhaustive reference in the compiler documentation: [`rustc_hir::LangItem`] | ||
- An auto-generated list with source locations by using ripgrep: `rg '#\[.*lang =' library/` |
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 suggested that just to make it clear that language items can be defined outside of the standard library, and that these source locations are specifically the ones defined by the standard library.
@nikomatsakis Yes, this would have been useful. The only other thing that I think could have helped would have been a basic example of how to add a new lang item, but at the same time that didn't take me too long to figure out with a quick grep. |
I won't have time to follow up on this for at least a month. If @camelid or someone wants to work on this I'm happy for them to do so :) |
That seems good to me! |
Somewhere I had written up a partial answer to Niko's questions, but I seem to have lost it ... anyway, if you're happy with how it is now, could you approve it so I can merge? |
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.
🎉
Update books ## nomicon 8 commits in b9ca313e687c991223e23e5520529815dc281205..7a13537f96af4b9b8e3ea296d6e5c3c7ab72ce9f 2021-06-22 12:02:20 -0400 to 2021-07-05 23:34:47 -0400 - Apply review comments - Fix some style issues - Move the list of coercions to the reference - Add an example that shows the null-pointer opt does not happen - Remove casting list from the nomicon (rust-lang/nomicon#287) - Audit `ignore` annotations (rust-lang/nomicon#288) - rename typo "lifetime" to "reference" (rust-lang/nomicon#286) - Add an incomplete warning to the top page (rust-lang/nomicon#274) ## reference 7 commits in d9699fa8f3186440fdaadd703d63d8d42322c176..ab60513a3a5a0591e237fddff5d027a982648392 2021-06-21 12:23:10 -0700 to 2021-07-05 08:27:31 -0700 - fix grammar in Expressions (rust-lang/reference#1057) - fix comment in function parameter drop scope example (rust-lang/reference#1056) - fix typo in macro-ambiguity.md (rust-lang/reference#1058) - Mention (negative) infinity values on float-to-int casting (rust-lang/reference#1054) - (rust-lang/reference#841) - Missing TypeParamBounds in TypeAlias (rust-lang/reference#1036) - Be more precise about array offset in type layouts (rust-lang/reference#1034) ## book 34 commits in 55a26488ddefc8433e73a2e8352d70f7a5c7fc2b..a90f07f1e9a7fc75dc9105a6c6f16d5c13edceb0 2021-05-09 12:03:18 -0500 to 2021-07-05 14:43:12 -0400 - Clarify ?Sized syntax. Fixes rust-lang/book#2422. - Add some notes that macros are different than functions - Break up a long sentence. Fixes rust-lang/book#2329. - Further clarify and make consistent the reference to deref coercion - Update ch04-03-slices.md - add usage for `String` reference - Update ch15-02-deref.md (rust-lang/book#2780) - Remove claim about performance of i32 - Reword to avoid awkward pluralization - Make the link to the reference relative - Merge remote-tracking branch 'origin/pr/2753' - Reword number of library crates a package contains (rust-lang/book#2750) - Clarify explanation of why you can test private functions; add link - Merge remote-tracking branch 'origin/pr/2743' - Fix code hiding that I broke in eb60fedc9 - Link to the exact later section we're talking about - improve cross-references for newtype pattern - ch12-05, listing 12-20: Add missing "does not compile" warning (rust-lang/book#2731) - cargo format - Merge remote-tracking branch 'origin/pr/2724' - Remove ordinal numbers and only refer to indexes to avoid confusion - Let's mention the former and current authors of tlborm. - Update tlborm link to point to Veykril's up-to-date version (rust-lang/book#2722) - Merge remote-tracking branch 'origin/pr/2720' - Describe the ferris pictures in the alt text - Merge remote-tracking branch 'origin/pr/2707' - Reword ... explanation to include the word deprecated, list that first - Precise that the `...` inclusive range pattern has been replaces (rust-lang/book#2714) - (rust-lang/book#2696) - fix typo: missing "type" after generic (rust-lang/book#2777) - (rust-lang/book#2709) - Remove sentence about how Rust used to be - Fix a potentially confusing statement about static lifetimes of static variables. (rust-lang/book#2692) - Replace 'which'. (rust-lang/book#2663) ## rust-by-example 2 commits in 805e016c5792ad2adabb66e348233067d5ea9f10..028f93a61500fe8f746ee7cc6b204ea6c9f42935 2021-05-20 17:08:34 -0300 to 2021-07-06 06:28:53 -0300 - Fix a couple of typos in the `integration_testing.md` file (rust-lang/rust-by-example#1448) - Fix Structures type list (rust-lang/rust-by-example#1446) ## rustc-dev-guide 13 commits in fe34bed..60e2825 2021-06-21 21:50:12 +0200 to 2021-07-05 11:21:03 -0400 - Fixed typos in inline code - Document lang items (rust-lang/rustc-dev-guide#1119) - More specifics on what future-incompatible lints are used for - Fix line lens - Update information on lints particularly on future-incompatible - Update section of lint store - Update around half of the January 2021 date references (rust-lang/rustc-dev-guide#1155) - Create issues for many TODOs (rust-lang/rustc-dev-guide#1163) - Links from rustc-dev-guide to std-dev-guide (rust-lang/rustc-dev-guide#1152) - Document how to mark features as incomplete (rust-lang/rustc-dev-guide#1151) - Remove requests or suggestions about rebase and fixup contradictory to rust-highfive bot comment (rust-lang/rustc-dev-guide#1111) - Generate glossary table correctly (rust-lang/rustc-dev-guide#1146) - Correct the wrong serial number (rust-lang/rustc-dev-guide#1147) ## edition-guide 3 commits in c74b2a0d6bf55774cf15d69f05dfe05408b8f81a..5d57b3832f8d308a9f478ce0a69799548f27ad4d 2021-06-14 10:48:27 -0700 to 2021-07-05 10:33:32 +0200 - Add more info for warnings promoted to errors (rust-lang/edition-guide#247) - Create triagebot.toml - Clarify snippets in 2021 panic docs. (rust-lang/edition-guide#245) ## embedded-book 1 commits in cbec77fbd8eea0c13e390dd9eded1ae200e811d1..506840eb73b0749336e1d5274e16d6393892ee82 2021-06-10 06:26:32 +0000 to 2021-06-24 00:01:32 +0000 - Update book to track quickstart changes (rust-embedded/book#296)
This is mostly the text from #978 with the exhaustive list of lang items removed.
cc @MikailBag, @nikomatsakis, @camelid