Skip to content

Commit b16f803

Browse files
committed
Make DiagSymbolList more generic
1 parent cf7032f commit b16f803

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

compiler/rustc_errors/src/diagnostic_impls.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,15 +298,21 @@ impl IntoDiagArg for hir::def::Namespace {
298298
}
299299

300300
#[derive(Clone)]
301-
pub struct DiagSymbolList(Vec<Symbol>);
301+
pub struct DiagSymbolList<S = Symbol>(Vec<S>);
302302

303-
impl From<Vec<Symbol>> for DiagSymbolList {
304-
fn from(v: Vec<Symbol>) -> Self {
303+
impl<S> From<Vec<S>> for DiagSymbolList<S> {
304+
fn from(v: Vec<S>) -> Self {
305305
DiagSymbolList(v)
306306
}
307307
}
308308

309-
impl IntoDiagArg for DiagSymbolList {
309+
impl<S> FromIterator<S> for DiagSymbolList<S> {
310+
fn from_iter<T: IntoIterator<Item = S>>(iter: T) -> Self {
311+
iter.into_iter().collect::<Vec<_>>().into()
312+
}
313+
}
314+
315+
impl<S: std::fmt::Display> IntoDiagArg for DiagSymbolList<S> {
310316
fn into_diag_arg(self) -> DiagArgValue {
311317
DiagArgValue::StrListSepByAnd(
312318
self.0.into_iter().map(|sym| Cow::Owned(format!("`{sym}`"))).collect(),

0 commit comments

Comments
 (0)