1
Fork 0
rust/compiler/rustc_expand/src
Nicholas Nethercote 01e33a3600 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`).
2023-05-16 17:59:56 +10:00
..
mbe Avoid &format("...") calls in error message code. 2023-05-16 17:59:56 +10:00
mut_visit rustc_ast: Turn MutVisitor::token_visiting_enabled into a constant 2021-10-18 00:23:24 +03:00
parse various: translation resources from cg backend 2023-02-22 09:15:54 +00:00
tokenstream Remove TokenStreamBuilder. 2022-10-05 12:42:54 +11:00
base.rs Avoid &format("...") calls in error message code. 2023-05-16 17:59:56 +10:00
build.rs Rename ast::Static to ast::StaticItem to match ast::ConstItem 2023-04-04 15:34:40 +00:00
config.rs Fix some clippy::complexity 2023-04-09 23:22:14 +02:00
errors.rs Fix static string lints 2023-04-25 18:59:55 +01:00
expand.rs Avoid &format("...") calls in error message code. 2023-05-16 17:59:56 +10:00
lib.rs Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
mbe.rs Move macro_rules diagnostics to diagnostics module 2022-11-20 13:06:44 +01:00
module.rs Use ThinVec in a few more AST types. 2023-02-21 11:51:56 +11:00
placeholders.rs Rip it out 2023-05-01 16:15:13 +08:00
proc_macro.rs Restrict From<S> for {D,Subd}iagnosticMessage. 2023-05-03 08:44:39 +10:00
proc_macro_server.rs fix TODO comments 2023-05-02 10:32:07 +00:00
tests.rs Spelling - compiler 2023-04-17 16:09:18 -04:00