rust/compiler/rustc_lint/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
..
nonstandard_style
array_into_iter.rs
builtin.rs Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
context.rs Add warn-by-default lint for local binding shadowing exported glob re-export item 2023-05-27 18:49:07 +08:00
deref_into_dyn_supertrait.rs
drop_forget_useless.rs Rename forget_ref lint to forgetting_references 2023-05-21 14:28:09 +02:00
early.rs Restrict From<S> for {D,Subd}iagnosticMessage. 2023-05-03 08:44:39 +10:00
enum_intrinsics_non_enums.rs rename needs_subst to has_param 2023-04-27 08:35:19 +01:00
errors.rs Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00
expect.rs Move expansion of query macros in rustc_middle to rustc_middle::query 2023-05-15 08:49:13 +02:00
for_loops_over_fallibles.rs
hidden_unicode_codepoints.rs
internal.rs Use is_some_and/is_ok_and in less obvious spots 2023-05-24 14:33:43 +00:00
late.rs Consider lint check attributes on match arms in late lints 2023-05-19 19:04:10 +09:00
let_underscore.rs
levels.rs Stop confusing specification levels when computing expectations. 2023-05-18 08:52:54 +00:00
lib.rs Move expansion of query macros in rustc_middle to rustc_middle::query 2023-05-15 08:49:13 +02:00
lints.rs Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00
map_unit_fn.rs
methods.rs
multiple_supertrait_upcastable.rs
non_ascii_idents.rs
non_fmt_panic.rs Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
nonstandard_style.rs reimpl make non_upper_case_globals lint not report trait impls 2023-04-20 16:28:49 +12:00
noop_method_call.rs add match to diagnostic messages 2023-04-29 15:47:23 +00:00
opaque_hidden_inferred_bound.rs add subst_identity_iter and subst_identity_iter_copied methods on EarlyBinder; use this to simplify some EarlyBinder noise around explicit_item_bounds calls 2023-04-20 12:36:50 -06:00
pass_by_value.rs
passes.rs
redundant_semicolon.rs
tests.rs
traits.rs
types.rs Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
unused.rs Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00