Add lint againts invalid runtime symbol definitions#155521
Add lint againts invalid runtime symbol definitions#155521Urgau wants to merge 6 commits intorust-lang:mainfrom
Conversation
|
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| /// | ||
| /// ### Explanation | ||
| /// | ||
| /// Up-most care is required when defining runtime symbols assumed and |
There was a problem hiding this comment.
Nit:
| /// Up-most care is required when defining runtime symbols assumed and | |
| /// Utmost care is required when defining runtime symbols assumed and |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment was marked as duplicate.
This comment was marked as duplicate.
|
Should this also include |
|
As far as I understood the lang meeting discussion, there was no concern with this PR. But some opinion that it doesn’t fully replace the previous PR, since some warn-by-default lint more generally applicable (and to actually address the user reports, which were about |
|
My interpretation here: this lint is valuable because the wrong signature for something on the well-known list is clearly and always wrong, so deny makes sense. We should have this lint. (And I'm find expanding to more functions so long as they meet that "definitely incontrovertibly wrong signature for that name that rustc or one of your linked libraries uses" bar. I don't know if we include Another lint, for "it's very suspicious that you're defining an unmangled |
|
(The bot has been fixed.) @rfcbot fcp merge lang |
|
Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
This PR adds a deny-by-default lint againts invalid runtime symbol definitions, those runtime symbols are assumed and used by
core1 andrustcwith a specific definition.We have had multiple reports of users tripping over
stdsymbols (addressed in a future PR):#[no_mangle] fn open() {}makecargo thang?no_mangleThis PR is a second attempt after #146505, where T-lang had some reservations about a blanket lint that does not check the signature, which is now done with this PR, and about linting of
stdruntime symbols when std is not linked, which this PR omits by not including any std runtime symbols (for now).invalid_runtime_symbol_definitions(deny-by-default)
The
invalid_runtime_symbol_definitionslint checks the signature of items whose symbol name is a runtime symbols expected bycore.Example
Explanation
Up-most care is required when defining runtime symbols assumed and used by the standard library. They must follow the C specification, not use any standard-library facility or undefined behavior may occur.
The symbols currently checked are
memcpy,memmove,memset,memcmp,bcmpandstrlen.@rustbot labels +I-lang-nominated +T-lang +needs-fcp +A-lints
cc @rust-lang/lang-ops
r? compiler
Footnotes
https://doc.rust-lang.org/core/index.html#how-to-use-the-core-library ↩