rust/compiler/rustc_middle/src
bors 70e04bd88d Auto merge of #111748 - nnethercote:Cow-DiagnosticMessage, r=WaffleLapkin
Use `Cow` in `{D,Subd}iagnosticMessage`.

Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment:
```
// FIXME(davidtwco): can a `Cow<'static, str>` be used here?
```
This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging.

This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths.

Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile.

r? `@WaffleLapkin`
2023-05-29 07:10:44 +00:00
..
dep_graph Allow LocalDefId as the argument to def_path_str 2023-04-21 22:27:20 +00:00
hir Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
infer Use OpaqueTypeKey in query response 2023-05-10 23:41:06 +00:00
middle Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00
mir Auto merge of #111813 - scottmcm:pretty-mir, r=cjgillot 2023-05-28 21:53:56 +00:00
query Rollup merge of #111870 - WaffleLapkin:just_🌟traits🌟_query, r=compiler-errors 2023-05-24 06:05:38 +02:00
thir offset_of 2023-04-21 02:14:02 -07:00
traits Fallible<_> -> Result<_, NoSolution> 2023-05-25 17:29:22 +00:00
ty Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00
util Move expansion of query macros in rustc_middle to rustc_middle::query 2023-05-15 08:49:13 +02:00
arena.rs Prepopulate opaques in canonical input 2023-05-25 03:21:22 +00:00
error.rs Remove LangItems::require 2023-05-16 19:53:38 +02:00
lib.rs Finish move of query.rs 2023-05-17 01:57:21 +02:00
lint.rs Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00
macros.rs Simplify CloneLiftImpls and TrivialTypeTraversalImpls. 2023-04-16 14:19:50 +10:00
metadata.rs rustc_metadata: Remove Span from ModChild 2023-04-18 17:25:04 +03:00
tests.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
thir.rs Remove unused TypeFoldable/TypeVisitable impls. 2023-04-26 15:19:50 +10:00
values.rs Replace EarlyBinder(x) with EarlyBinder::new(x) 2023-05-28 10:44:50 -06:00