1
Fork 0

Remove lifetimes from some diagnostics.

Because the `&'a str` fields can be trivially converted to `String`
without causing any extra allocations.
This commit is contained in:
Nicholas Nethercote 2024-01-30 15:44:37 +11:00
parent 5350edb9e8
commit 45dc19785d
2 changed files with 18 additions and 18 deletions

View file

@ -605,7 +605,7 @@ impl UnsafeOpKind {
span, span,
UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe { UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
span, span,
function: &with_no_trimmed_paths!(tcx.def_path_str(*did)), function: with_no_trimmed_paths!(tcx.def_path_str(*did)),
unsafe_not_inherited_note, unsafe_not_inherited_note,
}, },
), ),
@ -696,7 +696,7 @@ impl UnsafeOpKind {
span, span,
UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe { UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
span, span,
function: &with_no_trimmed_paths!(tcx.def_path_str(*function)), function: with_no_trimmed_paths!(tcx.def_path_str(*function)),
missing_target_features: DiagnosticArgValue::StrListSepByAnd( missing_target_features: DiagnosticArgValue::StrListSepByAnd(
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(), missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
), ),
@ -750,14 +750,14 @@ impl UnsafeOpKind {
dcx.emit_err(CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed { dcx.emit_err(CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span, span,
unsafe_not_inherited_note, unsafe_not_inherited_note,
function: &tcx.def_path_str(*did), function: tcx.def_path_str(*did),
}); });
} }
CallToUnsafeFunction(Some(did)) => { CallToUnsafeFunction(Some(did)) => {
dcx.emit_err(CallToUnsafeFunctionRequiresUnsafe { dcx.emit_err(CallToUnsafeFunctionRequiresUnsafe {
span, span,
unsafe_not_inherited_note, unsafe_not_inherited_note,
function: &tcx.def_path_str(*did), function: tcx.def_path_str(*did),
}); });
} }
CallToUnsafeFunction(None) if unsafe_op_in_unsafe_fn_allowed => { CallToUnsafeFunction(None) if unsafe_op_in_unsafe_fn_allowed => {
@ -875,7 +875,7 @@ impl UnsafeOpKind {
), ),
build_target_features_count: build_enabled.len(), build_target_features_count: build_enabled.len(),
unsafe_not_inherited_note, unsafe_not_inherited_note,
function: &tcx.def_path_str(*function), function: tcx.def_path_str(*function),
}); });
} }
CallToFunctionWith { function, missing, build_enabled } => { CallToFunctionWith { function, missing, build_enabled } => {
@ -894,7 +894,7 @@ impl UnsafeOpKind {
), ),
build_target_features_count: build_enabled.len(), build_target_features_count: build_enabled.len(),
unsafe_not_inherited_note, unsafe_not_inherited_note,
function: &tcx.def_path_str(*function), function: tcx.def_path_str(*function),
}); });
} }
} }

View file

@ -23,10 +23,10 @@ pub struct UnconditionalRecursion {
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe)] #[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe)]
#[note] #[note]
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe<'a> { pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
#[label] #[label]
pub span: Span, pub span: Span,
pub function: &'a str, pub function: String,
#[subdiagnostic] #[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>, pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
} }
@ -123,10 +123,10 @@ pub struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe)] #[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe)]
#[help] #[help]
pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe<'a> { pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
#[label] #[label]
pub span: Span, pub span: Span,
pub function: &'a str, pub function: String,
pub missing_target_features: DiagnosticArgValue, pub missing_target_features: DiagnosticArgValue,
pub missing_target_features_count: usize, pub missing_target_features_count: usize,
#[note] #[note]
@ -140,11 +140,11 @@ pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe, code = E0133)] #[diag(mir_build_call_to_unsafe_fn_requires_unsafe, code = E0133)]
#[note] #[note]
pub struct CallToUnsafeFunctionRequiresUnsafe<'a> { pub struct CallToUnsafeFunctionRequiresUnsafe {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
pub function: &'a str, pub function: String,
#[subdiagnostic] #[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>, pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
@ -163,11 +163,11 @@ pub struct CallToUnsafeFunctionRequiresUnsafeNameless {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)] #[diag(mir_build_call_to_unsafe_fn_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
#[note] #[note]
pub struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> { pub struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
pub function: &'a str, pub function: String,
#[subdiagnostic] #[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>, pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
@ -374,11 +374,11 @@ pub struct BorrowOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(mir_build_call_to_fn_with_requires_unsafe, code = E0133)] #[diag(mir_build_call_to_fn_with_requires_unsafe, code = E0133)]
#[help] #[help]
pub struct CallToFunctionWithRequiresUnsafe<'a> { pub struct CallToFunctionWithRequiresUnsafe {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
pub function: &'a str, pub function: String,
pub missing_target_features: DiagnosticArgValue, pub missing_target_features: DiagnosticArgValue,
pub missing_target_features_count: usize, pub missing_target_features_count: usize,
#[note] #[note]
@ -392,11 +392,11 @@ pub struct CallToFunctionWithRequiresUnsafe<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(mir_build_call_to_fn_with_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)] #[diag(mir_build_call_to_fn_with_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
#[help] #[help]
pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> { pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
pub function: &'a str, pub function: String,
pub missing_target_features: DiagnosticArgValue, pub missing_target_features: DiagnosticArgValue,
pub missing_target_features_count: usize, pub missing_target_features_count: usize,
#[note] #[note]