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:
parent
fb4bca04fa
commit
5350edb9e8
38 changed files with 113 additions and 116 deletions
|
@ -698,12 +698,15 @@ impl UnsafeOpKind {
|
|||
span,
|
||||
function: &with_no_trimmed_paths!(tcx.def_path_str(*function)),
|
||||
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(),
|
||||
),
|
||||
missing_target_features_count: missing.len(),
|
||||
note: if build_enabled.is_empty() { None } else { Some(()) },
|
||||
build_target_features: DiagnosticArgValue::StrListSepByAnd(
|
||||
build_enabled.iter().map(|feature| Cow::from(feature.as_str())).collect(),
|
||||
build_enabled
|
||||
.iter()
|
||||
.map(|feature| Cow::from(feature.to_string()))
|
||||
.collect(),
|
||||
),
|
||||
build_target_features_count: build_enabled.len(),
|
||||
unsafe_not_inherited_note,
|
||||
|
@ -860,12 +863,15 @@ impl UnsafeOpKind {
|
|||
dcx.emit_err(CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||
span,
|
||||
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(),
|
||||
),
|
||||
missing_target_features_count: missing.len(),
|
||||
note: if build_enabled.is_empty() { None } else { Some(()) },
|
||||
build_target_features: DiagnosticArgValue::StrListSepByAnd(
|
||||
build_enabled.iter().map(|feature| Cow::from(feature.as_str())).collect(),
|
||||
build_enabled
|
||||
.iter()
|
||||
.map(|feature| Cow::from(feature.to_string()))
|
||||
.collect(),
|
||||
),
|
||||
build_target_features_count: build_enabled.len(),
|
||||
unsafe_not_inherited_note,
|
||||
|
@ -876,12 +882,15 @@ impl UnsafeOpKind {
|
|||
dcx.emit_err(CallToFunctionWithRequiresUnsafe {
|
||||
span,
|
||||
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(),
|
||||
),
|
||||
missing_target_features_count: missing.len(),
|
||||
note: if build_enabled.is_empty() { None } else { Some(()) },
|
||||
build_target_features: DiagnosticArgValue::StrListSepByAnd(
|
||||
build_enabled.iter().map(|feature| Cow::from(feature.as_str())).collect(),
|
||||
build_enabled
|
||||
.iter()
|
||||
.map(|feature| Cow::from(feature.to_string()))
|
||||
.collect(),
|
||||
),
|
||||
build_target_features_count: build_enabled.len(),
|
||||
unsafe_not_inherited_note,
|
||||
|
|
|
@ -127,11 +127,11 @@ pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe<'a> {
|
|||
#[label]
|
||||
pub span: Span,
|
||||
pub function: &'a str,
|
||||
pub missing_target_features: DiagnosticArgValue<'a>,
|
||||
pub missing_target_features: DiagnosticArgValue,
|
||||
pub missing_target_features_count: usize,
|
||||
#[note]
|
||||
pub note: Option<()>,
|
||||
pub build_target_features: DiagnosticArgValue<'a>,
|
||||
pub build_target_features: DiagnosticArgValue,
|
||||
pub build_target_features_count: usize,
|
||||
#[subdiagnostic]
|
||||
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
||||
|
@ -379,11 +379,11 @@ pub struct CallToFunctionWithRequiresUnsafe<'a> {
|
|||
#[label]
|
||||
pub span: Span,
|
||||
pub function: &'a str,
|
||||
pub missing_target_features: DiagnosticArgValue<'a>,
|
||||
pub missing_target_features: DiagnosticArgValue,
|
||||
pub missing_target_features_count: usize,
|
||||
#[note]
|
||||
pub note: Option<()>,
|
||||
pub build_target_features: DiagnosticArgValue<'a>,
|
||||
pub build_target_features: DiagnosticArgValue,
|
||||
pub build_target_features_count: usize,
|
||||
#[subdiagnostic]
|
||||
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
||||
|
@ -397,11 +397,11 @@ pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
|
|||
#[label]
|
||||
pub span: Span,
|
||||
pub function: &'a str,
|
||||
pub missing_target_features: DiagnosticArgValue<'a>,
|
||||
pub missing_target_features: DiagnosticArgValue,
|
||||
pub missing_target_features_count: usize,
|
||||
#[note]
|
||||
pub note: Option<()>,
|
||||
pub build_target_features: DiagnosticArgValue<'a>,
|
||||
pub build_target_features: DiagnosticArgValue,
|
||||
pub build_target_features_count: usize,
|
||||
#[subdiagnostic]
|
||||
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue