Skip to content

Add documentation for the no_main and repr attributes - #163627

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
literally-user:docs-repr-no_main_attribute
Oct 4, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
literally-user:docs-repr-no_main_attribute

Conversation

@literally-user

@literally-user literally-user commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

Part of #157604.

This PR documents no_main and repr attributes in library/core/src/attribute_docs.rs with some examples.

Tested with: ./x doc

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 1, 2026
@rustbot

rustbot commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from Darksonn, JohnTitor, Mark-Simulacrum, clarfonthey

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 1, 2026
@rust-log-analyzer

This comment has been minimized.

@literally-user
literally-user force-pushed the docs-repr-no_main_attribute branch from b207bc2 to a09c4c7 Compare October 1, 2026 23:26
@rustbot

rustbot commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. has-merge-commits PR has merge commits, merge with caution. labels Oct 1, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bushrat011899 bushrat011899 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good documentation in general! Just some minor mistakes to fix up.

View changes since this review

Comment thread library/core/src/attribute_docs.rs Outdated
/// [representation]: ../reference/type-layout.html#representations
/// [`Rust`]: ../reference/type-layout.html#the-rust-representation
/// [`C`]: ../reference/type-layout.html#the-c-representation
/// [primitive representations]: ../reference/type-layout.html#primitiv

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// [primitive representations]: ../reference/type-layout.html#primitiv
/// [primitive representations]: ../reference/type-layout.html#primitive-representations

I assume this is the link you're aiming for?

Comment thread library/core/src/attribute_docs.rs Outdated
Comment on lines +492 to +493
///
///

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
///
///

Added lines appear superfluous.

Comment thread library/core/src/attribute_docs.rs Outdated
Comment on lines +417 to +418
/// If you define it yourself, it must use the platform's C ABI and be exported under an
/// unmangled name with the [`no_mangle` attribute]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this actually true? I agree it's almost certainly what you should do, but I don't know if it's a "must" (e.g., you could use a naked ABI).

@literally-user literally-user Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So, there's no strict requirement for this, I think I'll rewrite this part. Good point, thanks!

Comment thread library/core/src/attribute_docs.rs Outdated
/// If you define it yourself, it must use the platform's C ABI and be exported under an
/// unmangled name with the [`no_mangle` attribute]:
///
/// ```rust,ignore (needs to be built as a binary crate)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// ```rust,ignore (needs to be built as a binary crate)
/// ```standalone_crate

I believe standalone_crate is sufficient to have this test compile?

Comment thread library/core/src/attribute_docs.rs
Comment thread library/core/src/attribute_docs.rs
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 2, 2026
@rustbot

rustbot commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rust-log-analyzer

This comment has been minimized.

@literally-user

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 2, 2026

@bushrat011899 bushrat011899 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing that up, looks good to me!

@bors r+

View changes since this review

@rust-bors

rust-bors Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 4abaac9 has been approved by bushrat011899

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 2, 2026
@literally-user

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 3, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors try jobs=dist-various-1,test-various,test-x86_64-gnu-aux,test-x86_64-msvc-1,test-aarch64-apple-1,test-aarch64-apple-2,test-x86_64-mingw-1,test-i686-msvc,test-armhf-gnu

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 3, 2026
…=<try>

Add documentation for the `no_main` and `repr` attributes


try-job: dist-various-1
try-job: test-various
try-job: test-x86_64-gnu-aux
try-job: test-x86_64-msvc-1
try-job: test-aarch64-apple-1
try-job: test-aarch64-apple-2
try-job: test-x86_64-mingw-1
try-job: test-i686-msvc
try-job: test-armhf-gnu
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@literally-user
literally-user force-pushed the docs-repr-no_main_attribute branch from 3d16c35 to f679d53 Compare October 3, 2026 13:28
@literally-user

Copy link
Copy Markdown
Contributor Author

@JonathanBrouwer Can you run them again, please?

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors try jobs=dist-various-1,test-various,test-x86_64-gnu-aux,test-x86_64-msvc-1,test-aarch64-apple-1,test-aarch64-apple-2,test-x86_64-mingw-1,test-i686-msvc,test-armhf-gnu

rust-bors Bot pushed a commit that referenced this pull request Oct 3, 2026
…=<try>

Add documentation for the `no_main` and `repr` attributes


try-job: dist-various-1
try-job: test-various
try-job: test-x86_64-gnu-aux
try-job: test-x86_64-msvc-1
try-job: test-aarch64-apple-1
try-job: test-aarch64-apple-2
try-job: test-x86_64-mingw-1
try-job: test-i686-msvc
try-job: test-armhf-gnu
@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 8587fed (8587feda3991a1b0739792e0602b94f03fd1d909)
Base parent: d6b6dc7 (d6b6dc7982ef5d9117d96d018dfd83098d0471a1)

Comment thread library/core/src/attribute_docs.rs Outdated
/// If you define an entry point symbol that is suitable for your target, it must also be exported
/// under an unmangled name using the [`no_mangle` attribute]:
///
/// ```rust, ignore (no_main)

@JonathanBrouwer JonathanBrouwer Oct 3, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it work to make this no_run instead of ignore?
Then we can at least test that the example checks

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is actually good idea

Fix test-tidy

review changes

review changes

review changes

fix llvm build

ignore attribute documentation example

fix tidy

use no_run instead of ignore
@literally-user
literally-user force-pushed the docs-repr-no_main_attribute branch from f679d53 to 17f3f9c Compare October 3, 2026 22:26
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors try jobs=test-various

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
…=<try>

Add documentation for the `no_main` and `repr` attributes


try-job: test-various
@rust-bors

rust-bors Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: a46c290 (a46c2901cc0ebd89d7262523ca634d44d35b129a)
Base parent: 56343b1 (56343b1a7d3fed3f349a5c2dc474f65b504f5221)

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors r=bushrat011899,JonathanBrouwer rollup

@rust-bors

rust-bors Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 17f3f9c has been approved by bushrat011899,JonathanBrouwer

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 4, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #162974 (FCW for `#[panic_handler]` on `unsafe fn`.)
 - #163627 (Add documentation for the `no_main` and `repr` attributes)
 - #163671 (Add `--frontend-threads` option to `./x perf`)
 - #163694 (c_str_alloc_error test: mention why this is mostly Miri-only)
 - #163711 (Stabilize `CStr::display`)
 - #163723 ([tiny] Remove useless `.into()` calls)
@rust-bors
rust-bors Bot merged commit 593a42b into rust-lang:main Oct 4, 2026
15 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 4, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
Rollup merge of #163627 - literally-user:docs-repr-no_main_attribute, r=bushrat011899,JonathanBrouwer

Add documentation for the `no_main` and `repr` attributes

Part of #157604.

This PR documents `no_main` and `repr` attributes in `library/core/src/attribute_docs.rs` with some examples.

Tested with: `./x doc`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants