Skip to content

Commit 8a9b38f

Browse files
committed
Avoid &format("...") calls in error message code.
Error message all end up passing into a function as an `impl Into<{D,Subd}iagnosticMessage>`. If an error message is creatd as `&format("...")` that means we allocate a string (in the `format!` call), then take a reference, and then clone (allocating again) the reference to produce the `{D,Subd}iagnosticMessage`, which is silly. This commit removes the leading `&` from a lot of these cases. This means the original `String` is moved into the `{D,Subd}iagnosticMessage`, avoiding the double allocations. This requires changing some function argument types from `&str` to `String` (when all arguments are `String`) or `impl Into<{D,Subd}iagnosticMessage>` (when some arguments are `String` and some are `&str`).
1 parent db3faa7 commit 8a9b38f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pretty_clif.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ pub(crate) fn write_ir_file(
227227
// Using early_warn as no Session is available here
228228
rustc_session::early_warn(
229229
rustc_session::config::ErrorOutputType::default(),
230-
&format!("error writing ir file: {}", err),
230+
format!("error writing ir file: {}", err),
231231
);
232232
}
233233
}

0 commit comments

Comments
 (0)