Document symbol name attributes - #159758
Open
amirHdev wants to merge 2 commits into
Open
Conversation
This comment has been minimized.
This comment has been minimized.
amirHdev
force-pushed
the
docs-symbol-name-attributes
branch
from
August 1, 2026 12:19
fd9a817 to
652be0c
Compare
This comment has been minimized.
This comment has been minimized.
| /// well-known symbol, which may cause undefined behavior. | ||
| /// | ||
| /// Starting with the 2024 edition, the attribute must be written using the `unsafe(...)` syntax. | ||
| /// Earlier editions also permit `#[export_name = "..."]`. |
Member
There was a problem hiding this comment.
Why "also"?
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
amirHdev
force-pushed
the
docs-symbol-name-attributes
branch
from
September 1, 2026 10:21
652be0c to
c9d3bb5
Compare
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. |
GuillaumeGomez
requested changes
Sep 1, 2026
| /// pub extern "C" fn initialize() {} | ||
| /// ``` | ||
| /// | ||
| /// The attribute controls the symbol name and export behavior, but does not change the function's |
Member
There was a problem hiding this comment.
| /// | ||
| /// ```rust | ||
| /// #[unsafe(no_mangle)] | ||
| /// pub extern "C" fn initialize() {} |
Member
There was a problem hiding this comment.
Since below you mention that no_mangle is usually used on extern "C" function, maybe only write:
Suggested change
| /// pub extern "C" fn initialize() {} | |
| pub fn initialize() {} |
here?
| /// Rust normally changes an item's symbol name to encode information such as its module path. | ||
| /// Applying `no_mangle` instead uses the item's identifier as the exported symbol name. | ||
| /// | ||
| /// ```rust |
Member
There was a problem hiding this comment.
Suggested change
| /// ```rust | |
| /// ``` |
And same on all rust code blocks.
| /// ``` | ||
| /// | ||
| /// In this example, Rust code uses `name_in_rust`, while the linker resolves | ||
| /// `actual_symbol_name`. The attribute can only be applied to function and static declarations |
Member
There was a problem hiding this comment.
Suggested change
| /// `actual_symbol_name`. The attribute can only be applied to function and static declarations | |
| /// `actual_symbol_name`. The attribute can only be applied to declarations of static variables and of functions. |
Collaborator
|
Reminder, once the PR becomes ready for a review, use |
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Contributor
Author
|
@rustbot ready |
Contributor
Author
|
@GuillaumeGomez Thanks , updated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documents the no_mangle, export_name, link_name attributes
Part of #157604
r? @GuillaumeGomez