-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Explicitly assign constructed C++ classes #122062
Merged
Merged
Conversation
This file contains 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
rustbot
added
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Mar 6, 2024
This comment has been minimized.
This comment has been minimized.
workingjubilee
force-pushed
the
initialize-my-fist
branch
from
March 6, 2024 05:15
e72b72c
to
23623a0
Compare
C++ style guides I am aware of recommend specifically preferring = syntax for any classes with fairly obvious constructors[^0] that do not perform any complicated logic in their constructor. I contend that all constructors that the `rustc_llvm` code uses qualify. This has only become more common since C++ 17 guaranteed many cases of copy initialization elision. The other detail is that I tried to ask another contributor with infinitely more C++ experience than me (i.e. any) what this constructor syntax was, and they thought it was a macro. I know of no other language that has adopted this same syntax. As the rustc codebase features many contributors experienced in many other languages, using a less... unique... style has many other benefits in making this code more lucid and maintainable, which is something it direly needs. [^0]: e.g. https://abseil.io/tips/88
Changing to the @bors r+ rollup |
bors
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
Mar 6, 2024
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 7, 2024
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#122015 (Add better explanation for `rustc_index::IndexVec`) - rust-lang#122061 (Clarify FatalErrorHandler) - rust-lang#122062 (Explicitly assign constructed C++ classes) - rust-lang#122072 (Refer to "slice" instead of "vector" in Ord and PartialOrd trait impl of slices) - rust-lang#122088 (Remove unnecessary fixme on new thread stack size) - rust-lang#122094 (Remove outdated footnote "missing-stack-probe" in platform-support) - rust-lang#122107 (Temporarily make allow-by-default the `non_local_definitions` lint) - rust-lang#122109 (compiletest: Add a `//@ needs-threads` directive) Failed merges: - rust-lang#122104 (Rust is a proper name: rust → Rust) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 7, 2024
Rollup merge of rust-lang#122062 - workingjubilee:initialize-my-fist, r=cuviper Explicitly assign constructed C++ classes C++ style guides I am aware of recommend specifically preferring = syntax for any classes with fairly obvious constructors[^0] that do not perform any complicated logic in their constructor. I contend that all constructors that the `rustc_llvm` code uses qualify. This has only become more common since C++ 17 guaranteed many cases of copy initialization elision. The other detail is that I tried to ask another contributor with infinitely more C++ experience than me (i.e. any) what this constructor syntax was, and they thought it was a macro. I know of no other language that has adopted this same syntax. As the rustc codebase features many contributors experienced in many other languages, using a less... unique... style has many other benefits in making this code more lucid and maintainable, which is something it direly needs. [^0]: e.g. https://abseil.io/tips/88
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-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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.
C++ style guides I am aware of recommend specifically preferring = syntax for any classes with fairly obvious constructors1 that do not perform any complicated logic in their constructor. I contend that all constructors that the
rustc_llvm
code uses qualify. This has only become more common since C++ 17 guaranteed many cases of copy initialization elision.The other detail is that I tried to ask another contributor with infinitely more C++ experience than me (i.e. any) what this constructor syntax was, and they thought it was a macro. I know of no other language that has adopted this same syntax. As the rustc codebase features many contributors experienced in many other languages, using a less... unique... style has many other benefits in making this code more lucid and maintainable, which is something it direly needs.
Footnotes
e.g. https://abseil.io/tips/88 ↩