Skip to content

Minor fixes to $crate behavior #1816

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

Merged
merged 2 commits into from
May 31, 2025
Merged

Conversation

Daniel-Aaron-Bloom
Copy link
Contributor

@Daniel-Aaron-Bloom Daniel-Aaron-Bloom commented May 8, 2025

The description of the behavior of passing $crate to a proc-macro is missing, this PR adds one.

Similarly the behavior of ident matching $crate isn't captured. Every other fragment specifier which matches $crate goes through PathIdentSegment which does contain $crate, but neither IDENTIFIER_OR_KEYWORD nor RAW_IDENTIFIER can (or should) match against $crate. Introducing a new definition just to capture this behavior seems like overkill, especially since it would only be used once, so adding an inline or-clause seems like the cleanest solution.

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label May 8, 2025
@joshtriplett
Copy link
Member

This looks correct to me.

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

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

Thanks!

I noticed there were quite a few changes to $crate behavior in rust-lang/rust#37213 in 1.14.

I'm slightly uneasy with this because I don't know what is going to happen in the future with RFC 3243 where a crate may end up being a path (foo::bar). I suppose since it will be opaque it's probably not a big deal, but still feels a little weird.

I'm not super happy with how $crate is defined, because it is a bit scattered (in paths.md, macro.decl.meta.dollar-crate, and macro.decl.hygiene.crate). For example, a naive reading could make one think that they could pass $crate into an ident from outside a macro definition, but that is not the case. Only the text in paths.md makes that really clear that it can only be passed in from a transcriber. Anyway, maybe for another day.

@ehuss ehuss added this pull request to the merge queue May 31, 2025
Merged via the queue into rust-lang:master with commit 8e0f593 May 31, 2025
5 checks passed
@Daniel-Aaron-Bloom Daniel-Aaron-Bloom deleted the dollar-crate branch June 2, 2025 07:13
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 3, 2025
Update books

## rust-lang/book

4 commits in 230c68bc1e08f5f3228384a28cc228c81dfbd10d..634724ea85ebb08a542970bf8871ac8b0f77fd15
2025-05-29 13:16:14 UTC to 2025-05-22 21:35:03 UTC

- Chapter 10 from tech review (rust-lang/book#4379)
- Chapter 9 from tech review (rust-lang/book#4377)
- Chapter 8 from tech review (rust-lang/book#4378)
- Chapter 7 from tech review (rust-lang/book#4374)

## rust-embedded/book

3 commits in 0b8219ac23a3e09464e4e0166c768cf1c4bba0d5..10fa1e084365f23f24ad0000df541923385b73b6
2025-05-27 18:37:30 UTC to 2025-05-27 18:26:36 UTC

- portability: add reference to embedded-hal docs (rust-embedded/book#391)
- remove the unused and deprecated `multilingual` field from `book.toml` (rust-embedded/book#388)
- Ci upgrade 20250522 (rust-embedded/book#393)

## rust-lang/nomicon

4 commits in c76a20f0d987145dcedf05c5c073ce8d91f2e82a..8b61acfaea822e9ac926190bc8f15791c33336e8
2025-05-26 10:16:09 UTC to 2025-05-23 15:03:00 UTC

- Use inline const expression in unchecked-uninit.md (rust-lang/nomicon#492)
- Fix code sample output in unchecked-uninit.md (rust-lang/nomicon#491)
- Use consistent type parameters in subtyping.md (rust-lang/nomicon#493)
- Fix typo in atomics.md (rust-lang/nomicon#494)

## rust-lang/reference

1 commits in 118fd1f1f0854f50e3ae1fe4b64862aad23009ca..8e0f593a30f3b56ddb0908fb7ab9249974e08738
2025-05-31 20:12:39 UTC to 2025-05-31 20:12:39 UTC

- Minor fixes to `$crate` behavior (rust-lang/reference#1816)

## rust-lang/rust-by-example

4 commits in c9d151f9147c4808c77f0375ba3fa5d54443cb9e..21f4e32b8b40d36453fae16ec07ad4b857c445b6
2025-05-29 12:45:08 UTC to 2025-05-29 12:44:23 UTC

- Update book.toml rename `author` field to `authors` (rust-lang/rust-by-example#1917)
- Add example to comment.md to teach how to toggle a whole code block using block comments (rust-lang/rust-by-example#1919)
- The example is not meant to be compiled with out passing arguments. (rust-lang/rust-by-example#1930)
- added a shorthand for the #[should_panic(expected = "msg") (rust-lang/rust-by-example#1931)
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 3, 2025
Update books

## rust-lang/book

4 commits in 230c68bc1e08f5f3228384a28cc228c81dfbd10d..634724ea85ebb08a542970bf8871ac8b0f77fd15
2025-05-29 13:16:14 UTC to 2025-05-22 21:35:03 UTC

- Chapter 10 from tech review (rust-lang/book#4379)
- Chapter 9 from tech review (rust-lang/book#4377)
- Chapter 8 from tech review (rust-lang/book#4378)
- Chapter 7 from tech review (rust-lang/book#4374)

## rust-embedded/book

3 commits in 0b8219ac23a3e09464e4e0166c768cf1c4bba0d5..10fa1e084365f23f24ad0000df541923385b73b6
2025-05-27 18:37:30 UTC to 2025-05-27 18:26:36 UTC

- portability: add reference to embedded-hal docs (rust-embedded/book#391)
- remove the unused and deprecated `multilingual` field from `book.toml` (rust-embedded/book#388)
- Ci upgrade 20250522 (rust-embedded/book#393)

## rust-lang/nomicon

4 commits in c76a20f0d987145dcedf05c5c073ce8d91f2e82a..8b61acfaea822e9ac926190bc8f15791c33336e8
2025-05-26 10:16:09 UTC to 2025-05-23 15:03:00 UTC

- Use inline const expression in unchecked-uninit.md (rust-lang/nomicon#492)
- Fix code sample output in unchecked-uninit.md (rust-lang/nomicon#491)
- Use consistent type parameters in subtyping.md (rust-lang/nomicon#493)
- Fix typo in atomics.md (rust-lang/nomicon#494)

## rust-lang/reference

1 commits in 118fd1f1f0854f50e3ae1fe4b64862aad23009ca..8e0f593a30f3b56ddb0908fb7ab9249974e08738
2025-05-31 20:12:39 UTC to 2025-05-31 20:12:39 UTC

- Minor fixes to `$crate` behavior (rust-lang/reference#1816)

## rust-lang/rust-by-example

4 commits in c9d151f9147c4808c77f0375ba3fa5d54443cb9e..21f4e32b8b40d36453fae16ec07ad4b857c445b6
2025-05-29 12:45:08 UTC to 2025-05-29 12:44:23 UTC

- Update book.toml rename `author` field to `authors` (rust-lang/rust-by-example#1917)
- Add example to comment.md to teach how to toggle a whole code block using block comments (rust-lang/rust-by-example#1919)
- The example is not meant to be compiled with out passing arguments. (rust-lang/rust-by-example#1930)
- added a shorthand for the #[should_panic(expected = "msg") (rust-lang/rust-by-example#1931)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 3, 2025
Update books

## rust-lang/book

4 commits in 230c68bc1e08f5f3228384a28cc228c81dfbd10d..634724ea85ebb08a542970bf8871ac8b0f77fd15
2025-05-29 13:16:14 UTC to 2025-05-22 21:35:03 UTC

- Chapter 10 from tech review (rust-lang/book#4379)
- Chapter 9 from tech review (rust-lang/book#4377)
- Chapter 8 from tech review (rust-lang/book#4378)
- Chapter 7 from tech review (rust-lang/book#4374)

## rust-embedded/book

3 commits in 0b8219ac23a3e09464e4e0166c768cf1c4bba0d5..10fa1e084365f23f24ad0000df541923385b73b6
2025-05-27 18:37:30 UTC to 2025-05-27 18:26:36 UTC

- portability: add reference to embedded-hal docs (rust-embedded/book#391)
- remove the unused and deprecated `multilingual` field from `book.toml` (rust-embedded/book#388)
- Ci upgrade 20250522 (rust-embedded/book#393)

## rust-lang/nomicon

4 commits in c76a20f0d987145dcedf05c5c073ce8d91f2e82a..8b61acfaea822e9ac926190bc8f15791c33336e8
2025-05-26 10:16:09 UTC to 2025-05-23 15:03:00 UTC

- Use inline const expression in unchecked-uninit.md (rust-lang/nomicon#492)
- Fix code sample output in unchecked-uninit.md (rust-lang/nomicon#491)
- Use consistent type parameters in subtyping.md (rust-lang/nomicon#493)
- Fix typo in atomics.md (rust-lang/nomicon#494)

## rust-lang/reference

1 commits in 118fd1f1f0854f50e3ae1fe4b64862aad23009ca..8e0f593a30f3b56ddb0908fb7ab9249974e08738
2025-05-31 20:12:39 UTC to 2025-05-31 20:12:39 UTC

- Minor fixes to `$crate` behavior (rust-lang/reference#1816)

## rust-lang/rust-by-example

4 commits in c9d151f9147c4808c77f0375ba3fa5d54443cb9e..21f4e32b8b40d36453fae16ec07ad4b857c445b6
2025-05-29 12:45:08 UTC to 2025-05-29 12:44:23 UTC

- Update book.toml rename `author` field to `authors` (rust-lang/rust-by-example#1917)
- Add example to comment.md to teach how to toggle a whole code block using block comments (rust-lang/rust-by-example#1919)
- The example is not meant to be compiled with out passing arguments. (rust-lang/rust-by-example#1930)
- added a shorthand for the #[should_panic(expected = "msg") (rust-lang/rust-by-example#1931)
rust-timer added a commit to rust-lang/rust that referenced this pull request Jun 3, 2025
Rollup merge of #141923 - rustbot:docs-update, r=ehuss

Update books

## rust-lang/book

4 commits in 230c68bc1e08f5f3228384a28cc228c81dfbd10d..634724ea85ebb08a542970bf8871ac8b0f77fd15
2025-05-29 13:16:14 UTC to 2025-05-22 21:35:03 UTC

- Chapter 10 from tech review (rust-lang/book#4379)
- Chapter 9 from tech review (rust-lang/book#4377)
- Chapter 8 from tech review (rust-lang/book#4378)
- Chapter 7 from tech review (rust-lang/book#4374)

## rust-embedded/book

3 commits in 0b8219ac23a3e09464e4e0166c768cf1c4bba0d5..10fa1e084365f23f24ad0000df541923385b73b6
2025-05-27 18:37:30 UTC to 2025-05-27 18:26:36 UTC

- portability: add reference to embedded-hal docs (rust-embedded/book#391)
- remove the unused and deprecated `multilingual` field from `book.toml` (rust-embedded/book#388)
- Ci upgrade 20250522 (rust-embedded/book#393)

## rust-lang/nomicon

4 commits in c76a20f0d987145dcedf05c5c073ce8d91f2e82a..8b61acfaea822e9ac926190bc8f15791c33336e8
2025-05-26 10:16:09 UTC to 2025-05-23 15:03:00 UTC

- Use inline const expression in unchecked-uninit.md (rust-lang/nomicon#492)
- Fix code sample output in unchecked-uninit.md (rust-lang/nomicon#491)
- Use consistent type parameters in subtyping.md (rust-lang/nomicon#493)
- Fix typo in atomics.md (rust-lang/nomicon#494)

## rust-lang/reference

1 commits in 118fd1f1f0854f50e3ae1fe4b64862aad23009ca..8e0f593a30f3b56ddb0908fb7ab9249974e08738
2025-05-31 20:12:39 UTC to 2025-05-31 20:12:39 UTC

- Minor fixes to `$crate` behavior (rust-lang/reference#1816)

## rust-lang/rust-by-example

4 commits in c9d151f9147c4808c77f0375ba3fa5d54443cb9e..21f4e32b8b40d36453fae16ec07ad4b857c445b6
2025-05-29 12:45:08 UTC to 2025-05-29 12:44:23 UTC

- Update book.toml rename `author` field to `authors` (rust-lang/rust-by-example#1917)
- Add example to comment.md to teach how to toggle a whole code block using block comments (rust-lang/rust-by-example#1919)
- The example is not meant to be compiled with out passing arguments. (rust-lang/rust-by-example#1930)
- added a shorthand for the #[should_panic(expected = "msg") (rust-lang/rust-by-example#1931)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: The marked PR is awaiting review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants