Skip to content

Commit 45dc197

Browse files
committed
Remove lifetimes from some diagnostics.
Because the `&'a str` fields can be trivially converted to `String` without causing any extra allocations.
1 parent 5350edb commit 45dc197

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

compiler/rustc_mir_build/src/check_unsafety.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ impl UnsafeOpKind {
605605
span,
606606
UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
607607
span,
608-
function: &with_no_trimmed_paths!(tcx.def_path_str(*did)),
608+
function: with_no_trimmed_paths!(tcx.def_path_str(*did)),
609609
unsafe_not_inherited_note,
610610
},
611611
),
@@ -696,7 +696,7 @@ impl UnsafeOpKind {
696696
span,
697697
UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
698698
span,
699-
function: &with_no_trimmed_paths!(tcx.def_path_str(*function)),
699+
function: with_no_trimmed_paths!(tcx.def_path_str(*function)),
700700
missing_target_features: DiagnosticArgValue::StrListSepByAnd(
701701
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
702702
),
@@ -750,14 +750,14 @@ impl UnsafeOpKind {
750750
dcx.emit_err(CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
751751
span,
752752
unsafe_not_inherited_note,
753-
function: &tcx.def_path_str(*did),
753+
function: tcx.def_path_str(*did),
754754
});
755755
}
756756
CallToUnsafeFunction(Some(did)) => {
757757
dcx.emit_err(CallToUnsafeFunctionRequiresUnsafe {
758758
span,
759759
unsafe_not_inherited_note,
760-
function: &tcx.def_path_str(*did),
760+
function: tcx.def_path_str(*did),
761761
});
762762
}
763763
CallToUnsafeFunction(None) if unsafe_op_in_unsafe_fn_allowed => {
@@ -875,7 +875,7 @@ impl UnsafeOpKind {
875875
),
876876
build_target_features_count: build_enabled.len(),
877877
unsafe_not_inherited_note,
878-
function: &tcx.def_path_str(*function),
878+
function: tcx.def_path_str(*function),
879879
});
880880
}
881881
CallToFunctionWith { function, missing, build_enabled } => {
@@ -894,7 +894,7 @@ impl UnsafeOpKind {
894894
),
895895
build_target_features_count: build_enabled.len(),
896896
unsafe_not_inherited_note,
897-
function: &tcx.def_path_str(*function),
897+
function: tcx.def_path_str(*function),
898898
});
899899
}
900900
}

compiler/rustc_mir_build/src/errors.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ pub struct UnconditionalRecursion {
2323
#[derive(LintDiagnostic)]
2424
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe)]
2525
#[note]
26-
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe<'a> {
26+
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
2727
#[label]
2828
pub span: Span,
29-
pub function: &'a str,
29+
pub function: String,
3030
#[subdiagnostic]
3131
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
3232
}
@@ -123,10 +123,10 @@ pub struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
123123
#[derive(LintDiagnostic)]
124124
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe)]
125125
#[help]
126-
pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe<'a> {
126+
pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
127127
#[label]
128128
pub span: Span,
129-
pub function: &'a str,
129+
pub function: String,
130130
pub missing_target_features: DiagnosticArgValue,
131131
pub missing_target_features_count: usize,
132132
#[note]
@@ -140,11 +140,11 @@ pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe<'a> {
140140
#[derive(Diagnostic)]
141141
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe, code = E0133)]
142142
#[note]
143-
pub struct CallToUnsafeFunctionRequiresUnsafe<'a> {
143+
pub struct CallToUnsafeFunctionRequiresUnsafe {
144144
#[primary_span]
145145
#[label]
146146
pub span: Span,
147-
pub function: &'a str,
147+
pub function: String,
148148
#[subdiagnostic]
149149
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
150150
}
@@ -163,11 +163,11 @@ pub struct CallToUnsafeFunctionRequiresUnsafeNameless {
163163
#[derive(Diagnostic)]
164164
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
165165
#[note]
166-
pub struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
166+
pub struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
167167
#[primary_span]
168168
#[label]
169169
pub span: Span,
170-
pub function: &'a str,
170+
pub function: String,
171171
#[subdiagnostic]
172172
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
173173
}
@@ -374,11 +374,11 @@ pub struct BorrowOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed
374374
#[derive(Diagnostic)]
375375
#[diag(mir_build_call_to_fn_with_requires_unsafe, code = E0133)]
376376
#[help]
377-
pub struct CallToFunctionWithRequiresUnsafe<'a> {
377+
pub struct CallToFunctionWithRequiresUnsafe {
378378
#[primary_span]
379379
#[label]
380380
pub span: Span,
381-
pub function: &'a str,
381+
pub function: String,
382382
pub missing_target_features: DiagnosticArgValue,
383383
pub missing_target_features_count: usize,
384384
#[note]
@@ -392,11 +392,11 @@ pub struct CallToFunctionWithRequiresUnsafe<'a> {
392392
#[derive(Diagnostic)]
393393
#[diag(mir_build_call_to_fn_with_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
394394
#[help]
395-
pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
395+
pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
396396
#[primary_span]
397397
#[label]
398398
pub span: Span,
399-
pub function: &'a str,
399+
pub function: String,
400400
pub missing_target_features: DiagnosticArgValue,
401401
pub missing_target_features_count: usize,
402402
#[note]

0 commit comments

Comments
 (0)