Skip to content

Commit

Permalink
Remove the second lifetime from DiagnosticArg.
Browse files Browse the repository at this point in the history
Because it's always static.

I'm surprised the compiler allowed this unused lifetime without any
complaint.
  • Loading branch information
nnethercote committed Jan 30, 2024
1 parent f0426b7 commit 514a5d8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct SuggestionsDisabled;
/// Simplified version of `FluentArg` that can implement `Encodable` and `Decodable`. Collection of
/// `DiagnosticArg` are converted to `FluentArgs` (consuming the collection) at the start of
/// diagnostic emission.
pub type DiagnosticArg<'iter, 'source> = (&'iter DiagnosticArgName, &'iter DiagnosticArgValue);
pub type DiagnosticArg<'iter> = (&'iter DiagnosticArgName, &'iter DiagnosticArgValue);

/// Name of a diagnostic argument.
pub type DiagnosticArgName = Cow<'static, str>;
Expand Down Expand Up @@ -909,7 +909,7 @@ impl Diagnostic {
// Exact iteration order of diagnostic arguments shouldn't make a difference to output because
// they're only used in interpolation.
#[allow(rustc::potential_query_instability)]
pub fn args(&self) -> impl Iterator<Item = DiagnosticArg<'_, 'static>> {
pub fn args(&self) -> impl Iterator<Item = DiagnosticArg<'_>> {
self.args.iter()
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ impl DiagCtxt {
pub fn eagerly_translate<'a>(
&self,
message: DiagnosticMessage,
args: impl Iterator<Item = DiagnosticArg<'a, 'static>>,
args: impl Iterator<Item = DiagnosticArg<'a>>,
) -> SubdiagnosticMessage {
SubdiagnosticMessage::Eager(Cow::from(self.eagerly_translate_to_string(message, args)))
}
Expand All @@ -637,7 +637,7 @@ impl DiagCtxt {
pub fn eagerly_translate_to_string<'a>(
&self,
message: DiagnosticMessage,
args: impl Iterator<Item = DiagnosticArg<'a, 'static>>,
args: impl Iterator<Item = DiagnosticArg<'a>>,
) -> String {
let inner = self.inner.borrow();
let args = crate::translation::to_fluent_args(args);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::error::Report;
/// Typically performed once for each diagnostic at the start of `emit_diagnostic` and then
/// passed around as a reference thereafter.
pub fn to_fluent_args<'iter>(
iter: impl Iterator<Item = DiagnosticArg<'iter, 'static>>,
iter: impl Iterator<Item = DiagnosticArg<'iter>>,
) -> FluentArgs<'static> {
let mut args = if let Some(size) = iter.size_hint().1 {
FluentArgs::with_capacity(size)
Expand Down

0 comments on commit 514a5d8

Please sign in to comment.