-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Avoid ref when using format! in compiler #127980
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt This PR changes Stable MIR cc @oli-obk, @celinval, @ouz-a Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred in exhaustiveness checking cc @Nadrieril Some changes occurred in compiler/rustc_sanitizers cc @rust-lang/project-exploit-mitigations, @rcvalle |
Is there a clippy lint for this? I know it can detect opportunity to put the args inline, but not sure if it flags needless refs here. Seems like it should if this has impact. |
sorry, must have accidentally closed it |
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
@bors r+ rollup |
Avoid ref when using format! in compiler Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse. See also rust-lang/rust-clippy#10851
Rollup of 8 pull requests Successful merges: - rust-lang#123196 (Add Process support for UEFI) - rust-lang#127523 (Migrate `dump-ice-to-disk` and `panic-abort-eh_frame` `run-make` tests to rmake) - rust-lang#127556 (Replace a long inline "autoref" comment with method docs) - rust-lang#127693 (Migrate `crate-hash-rustc-version` to `rmake`) - rust-lang#127866 (Conditionally build `wasm-component-ld` ) - rust-lang#127918 (Safely enforce thread name requirements) - rust-lang#127948 (fixes panic error `index out of bounds` in conflicting error) - rust-lang#127980 (Avoid ref when using format! in compiler) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#123196 (Add Process support for UEFI) - rust-lang#127556 (Replace a long inline "autoref" comment with method docs) - rust-lang#127693 (Migrate `crate-hash-rustc-version` to `rmake`) - rust-lang#127866 (Conditionally build `wasm-component-ld` ) - rust-lang#127918 (Safely enforce thread name requirements) - rust-lang#127948 (fixes panic error `index out of bounds` in conflicting error) - rust-lang#127980 (Avoid ref when using format! in compiler) - rust-lang#127984 (Avoid ref when using format! in src) - rust-lang#127987 (More accurate suggestion for `-> Box<dyn Trait>` or `-> impl Trait`) r? `@ghost` `@rustbot` modify labels: rollup
@@ -759,7 +759,7 @@ fn link_natively( | |||
sess.dcx().abort_if_errors(); | |||
|
|||
// Invoke the system linker | |||
info!("{:?}", &cmd); | |||
info!("{cmd:?}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
info!("{cmd:?}"); | |
info!(?cmd); |
Maybe it should be another clippy lint to turn to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not exactly the same, the latter prints cmd = xxzzzzz
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#123196 (Add Process support for UEFI) - rust-lang#127556 (Replace a long inline "autoref" comment with method docs) - rust-lang#127693 (Migrate `crate-hash-rustc-version` to `rmake`) - rust-lang#127866 (Conditionally build `wasm-component-ld` ) - rust-lang#127918 (Safely enforce thread name requirements) - rust-lang#127948 (fixes panic error `index out of bounds` in conflicting error) - rust-lang#127980 (Avoid ref when using format! in compiler) - rust-lang#127984 (Avoid ref when using format! in src) - rust-lang#127987 (More accurate suggestion for `-> Box<dyn Trait>` or `-> impl Trait`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#127980 - nyurik:compiler-refs, r=oli-obk Avoid ref when using format! in compiler Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse. See also rust-lang/rust-clippy#10851
Clean up a few minor refs in
format!
macro, as it has a performance cost. Apparently the compiler is unable to inlineformat!("{}", &variable)
, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental&
misuse.See also rust-lang/rust-clippy#10851