rust/compiler/rustc_middle/src/middle
Nicholas Nethercote 781111ef35 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.
2023-05-29 09:23:43 +10:00
..
codegen_fn_attrs.rs fix some lines, and do a consistency fix 2023-02-16 18:58:08 +02:00
debugger_visualizer.rs Move DebuggerVisualizerFile types from rustc_span to rustc_middle 2023-05-16 21:03:28 +02:00
dependency_format.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
exported_symbols.rs Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00
lang_items.rs Remove LangItems::require 2023-05-16 19:53:38 +02:00
limits.rs Move expansion of query macros in rustc_middle to rustc_middle::query 2023-05-15 08:49:13 +02:00
mod.rs Move DebuggerVisualizerFile types from rustc_span to rustc_middle 2023-05-16 21:03:28 +02:00
privacy.rs Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
region.rs Remove some unnecessary derives. 2023-04-28 18:34:55 +10:00
resolve_bound_vars.rs Move late-bound arg type checks to resolve_bound_vars 2023-02-18 03:28:54 +00:00
stability.rs Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00