1
Fork 0

Remove the lifetime from DiagnosticArgValue.

Because it's almost always static.

This makes `impl IntoDiagnosticArg for DiagnosticArgValue` trivial,
which is nice.

There are a few diagnostics constructed in
`compiler/rustc_mir_build/src/check_unsafety.rs` and
`compiler/rustc_mir_transform/src/errors.rs` that now need symbols
converted to `String` with `to_string` instead of `&str` with `as_str`,
but that' no big deal, and worth it for the simplifications elsewhere.
This commit is contained in:
Nicholas Nethercote 2024-01-30 15:27:16 +11:00
parent fb4bca04fa
commit 5350edb9e8
38 changed files with 113 additions and 116 deletions

View file

@ -34,7 +34,7 @@ pub(crate) macro throw_machine_stop_str($($tt:tt)*) {{
fn add_args(
self: Box<Self>,
_: &mut dyn FnMut(std::borrow::Cow<'static, str>, rustc_errors::DiagnosticArgValue<'static>),
_: &mut dyn FnMut(std::borrow::Cow<'static, str>, rustc_errors::DiagnosticArgValue),
) {}
}
throw_machine_stop!(Zst)

View file

@ -125,7 +125,7 @@ impl RequiresUnsafeDetail {
diag.arg(
"missing_target_features",
DiagnosticArgValue::StrListSepByAnd(
missing.iter().map(|feature| Cow::from(feature.as_str())).collect(),
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
),
);
diag.arg("missing_target_features_count", missing.len());
@ -136,7 +136,7 @@ impl RequiresUnsafeDetail {
DiagnosticArgValue::StrListSepByAnd(
build_enabled
.iter()
.map(|feature| Cow::from(feature.as_str()))
.map(|feature| Cow::from(feature.to_string()))
.collect(),
),
);