Skip to content

Commit d7d5a0b

Browse files
committed
typeck: use typed fluent identifiers for diags
Use new typed Fluent identifiers for the "missing type parameters" diagnostic in the typeck crate which was manually creating `DiagnosticMessage`s previously. Signed-off-by: David Wood <david.wood@huawei.com>
1 parent 7e6b617 commit d7d5a0b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

compiler/rustc_typeck/src/errors.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Errors emitted by typeck.
2-
use rustc_errors::{
3-
error_code, Applicability, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed,
4-
};
2+
use rustc_errors::{error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed};
53
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
64
use rustc_middle::ty::Ty;
75
use rustc_session::{parse::ParseSess, SessionDiagnostic};
@@ -264,10 +262,9 @@ pub struct MissingTypeParams {
264262
// Manual implementation of `SessionDiagnostic` to be able to call `span_to_snippet`.
265263
impl<'a> SessionDiagnostic<'a> for MissingTypeParams {
266264
fn into_diagnostic(self, sess: &'a ParseSess) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
267-
static SLUG: &'static str = "typeck-missing-type-params";
268265
let mut err = sess.span_diagnostic.struct_span_err_with_code(
269266
self.span,
270-
DiagnosticMessage::fluent(SLUG),
267+
rustc_errors::fluent::typeck::missing_type_params,
271268
error_code!(E0393),
272269
);
273270
err.set_arg("parameterCount", self.missing_type_params.len());
@@ -280,7 +277,7 @@ impl<'a> SessionDiagnostic<'a> for MissingTypeParams {
280277
.join(", "),
281278
);
282279

283-
err.span_label(self.def_span, DiagnosticMessage::fluent_attr(SLUG, "label"));
280+
err.span_label(self.def_span, rustc_errors::fluent::typeck::missing_type_params_label);
284281

285282
let mut suggested = false;
286283
if let (Ok(snippet), true) = (
@@ -298,18 +295,21 @@ impl<'a> SessionDiagnostic<'a> for MissingTypeParams {
298295
// least we can clue them to the correct syntax `Iterator<Type>`.
299296
err.span_suggestion(
300297
self.span,
301-
DiagnosticMessage::fluent_attr(SLUG, "suggestion"),
298+
rustc_errors::fluent::typeck::missing_type_params_suggestion,
302299
format!("{}<{}>", snippet, self.missing_type_params.join(", ")),
303300
Applicability::HasPlaceholders,
304301
);
305302
suggested = true;
306303
}
307304
}
308305
if !suggested {
309-
err.span_label(self.span, DiagnosticMessage::fluent_attr(SLUG, "no-suggestion-label"));
306+
err.span_label(
307+
self.span,
308+
rustc_errors::fluent::typeck::missing_type_params_no_suggestion_label,
309+
);
310310
}
311311

312-
err.note(DiagnosticMessage::fluent_attr(SLUG, "note"));
312+
err.note(rustc_errors::fluent::typeck::missing_type_params_note);
313313
err
314314
}
315315
}

0 commit comments

Comments
 (0)