rust/tests
Nicholas Nethercote 6b62f37402 Restrict From<S> for {D,Subd}iagnosticMessage.
Currently a `{D,Subd}iagnosticMessage` can be created from any type that
impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static,
str>`, which are reasonable. It also includes `&String`, which is pretty
weird, and results in many places making unnecessary allocations for
patterns like this:
```
self.fatal(&format!(...))
```
This creates a string with `format!`, takes a reference, passes the
reference to `fatal`, which does an `into()`, which clones the
reference, doing a second allocation. Two allocations for a single
string, bleh.

This commit changes the `From` impls so that you can only create a
`{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static,
str>`. This requires changing all the places that currently create one
from a `&String`. Most of these are of the `&format!(...)` form
described above; each one removes an unnecessary static `&`, plus an
allocation when executed. There are also a few places where the existing
use of `&String` was more reasonable; these now just use `clone()` at
the call site.

As well as making the code nicer and more efficient, this is a step
towards possibly using `Cow<'static, str>` in
`{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing
the `From<&'a str>` impls to `From<&'static str>`, which is doable, but
I'm not yet sure if it's worthwhile.
2023-05-03 08:44:39 +10:00
..
assembly Add loongarch64 asm! support 2023-04-25 14:15:31 +08:00
auxiliary
codegen Codegen fewer instructions in mem::replace 2023-04-30 22:33:04 -07:00
codegen-units Turn off inlining for codegen-unit tests 2023-04-07 15:46:45 -04:00
debuginfo Rollup merge of #108668 - gibbyfree:stabilizedebuggervisualizer, r=wesleywiser 2023-05-02 11:44:51 +05:30
incremental Turn on ConstDebugInfo pass. 2023-04-22 23:41:48 +02:00
mir-opt Auto merge of #109521 - tmiasko:const-prop-validation, r=wesleywiser 2023-05-02 03:42:37 +00:00
pretty Rollup merge of #111042 - Zalathar:no-coverage, r=wesleywiser 2023-05-01 17:10:24 +02:00
run-make Auto merge of #106075 - nbdd0121:ffi-unwind, r=joshtriplett 2023-05-02 00:45:04 +00:00
run-make-fulldeps Restrict From<S> for {D,Subd}iagnosticMessage. 2023-05-03 08:44:39 +10:00
run-pass-valgrind
rustdoc Rollup merge of #110631 - notriddle:notriddle/impl-trait-cycle, r=GuillaumeGomez 2023-04-30 16:25:46 +02:00
rustdoc-gui rustdoc: remove unneeded handleKey from settings.js 2023-04-21 16:42:23 -07:00
rustdoc-js rustdoc-search: add support for nested generics 2023-04-14 14:55:45 -07:00
rustdoc-js-std rustdoc-search: add support for nested generics 2023-04-14 14:55:45 -07:00
rustdoc-json Update tests 2023-04-29 13:01:46 +01:00
rustdoc-ui Don't use implied trait predicates in gather_explicit_predicates_of 2023-05-01 15:45:28 +00:00
ui Auto merge of #109128 - chenyukang:yukang/remove-type-ascription, r=estebank 2023-05-02 09:41:35 +00:00
ui-fulldeps Add Call terminator to SMIR 2023-04-20 12:00:41 -03:00
COMPILER_TESTS.md