]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_errors/src/diagnostic.rs
Rollup merge of #104927 - compiler-errors:binder-shifting-logic, r=oli-obk
[rust.git] / compiler / rustc_errors / src / diagnostic.rs
index 66c986977eccb78c1ad58e2c9adc9c22a69f93e4..7d5e4723a6d883b6b22bf24c19259c93f210c3fa 100644 (file)
@@ -4,6 +4,7 @@
     SubdiagnosticMessage, Substitution, SubstitutionPart, SuggestionStyle,
 };
 use rustc_data_structures::fx::FxHashMap;
+use rustc_error_messages::fluent_value_from_str_list_sep_by_and;
 use rustc_error_messages::FluentValue;
 use rustc_lint_defs::{Applicability, LintExpectationId};
 use rustc_span::edition::LATEST_STABLE_EDITION;
@@ -34,6 +35,7 @@
 pub enum DiagnosticArgValue<'source> {
     Str(Cow<'source, str>),
     Number(usize),
+    StrListSepByAnd(Vec<Cow<'source, str>>),
 }
 
 /// Converts a value of a type into a `DiagnosticArg` (typically a field of an `IntoDiagnostic`
@@ -49,6 +51,9 @@ fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
         match self {
             DiagnosticArgValue::Str(s) => DiagnosticArgValue::Str(Cow::Owned(s.into_owned())),
             DiagnosticArgValue::Number(n) => DiagnosticArgValue::Number(n),
+            DiagnosticArgValue::StrListSepByAnd(l) => DiagnosticArgValue::StrListSepByAnd(
+                l.into_iter().map(|s| Cow::Owned(s.into_owned())).collect(),
+            ),
         }
     }
 }
@@ -58,6 +63,7 @@ fn into(self) -> FluentValue<'source> {
         match self {
             DiagnosticArgValue::Str(s) => From::from(s),
             DiagnosticArgValue::Number(n) => From::from(n),
+            DiagnosticArgValue::StrListSepByAnd(l) => fluent_value_from_str_list_sep_by_and(l),
         }
     }
 }