diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-05-16 16:04:03 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-05-16 17:59:56 +1000 |
| commit | 8a9b38fd3bbf9d57cddb824f104fad592c7377e0 (patch) | |
| tree | ce6e39782dd55e5aee9d49be52bad4069849e3c3 /tests/codegen/src-hash-algorithm | |
| parent | db3faa78d0cdba3d90f559ce4d7a4e56a341950b (diff) | |
| download | rust-8a9b38fd3bbf9d57cddb824f104fad592c7377e0.tar.gz rust-8a9b38fd3bbf9d57cddb824f104fad592c7377e0.zip | |
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`).
Diffstat (limited to 'tests/codegen/src-hash-algorithm')
0 files changed, 0 insertions, 0 deletions
