rust/compiler/rustc_resolve/src
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
..
diagnostics Implement the unused_macro_rules lint 2022-05-05 19:13:00 +02:00
late Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00
build_reduced_graph.rs Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
check_unused.rs Use is_some_and/is_ok_and in less obvious spots 2023-05-24 14:33:43 +00:00
def_collector.rs Remove the NodeId of ast::ExprKind::Async 2023-03-19 19:01:31 +01:00
diagnostics.rs Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00
effective_visibilities.rs Populate effective visibilities in rustc_privacy 2023-05-11 14:51:01 +03:00
errors.rs Improve error for self: Box<self> 2023-05-11 13:21:10 +01:00
ident.rs fix(resolve): only disambiguate binding key during define 2023-05-18 09:29:48 +08:00
imports.rs Add warn-by-default lint for local binding shadowing exported glob re-export item 2023-05-27 18:49:07 +08:00
late.rs Ignore "non-real" type Res in rustdoc intra doc link resolution 2023-05-23 15:33:34 +02:00
lib.rs Add warn-by-default lint for local binding shadowing exported glob re-export item 2023-05-27 18:49:07 +08:00
macros.rs Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00
rustdoc.rs rustdoc: fix ICE from rustc_resolve and librustdoc parse divergence 2023-04-18 12:22:13 -07:00