1 use std::path::PathBuf;
3 use rustc_errors::ErrorGuaranteed;
4 use rustc_macros::{LintDiagnostic, SessionDiagnostic};
5 use rustc_session::SessionDiagnostic;
8 #[derive(SessionDiagnostic)]
9 #[diag(monomorphize::recursion_limit)]
10 pub struct RecursionLimit {
16 pub def_path_str: String,
17 #[note(monomorphize::written_to_path)]
18 pub was_written: Option<()>,
22 #[derive(SessionDiagnostic)]
23 #[diag(monomorphize::type_length_limit)]
24 #[help(monomorphize::consider_type_length_limit)]
25 pub struct TypeLengthLimit {
29 #[note(monomorphize::written_to_path)]
30 pub was_written: Option<()>,
32 pub type_length: usize,
35 #[derive(SessionDiagnostic)]
36 #[diag(monomorphize::requires_lang_item)]
37 pub struct RequiresLangItem {
38 pub lang_item: String,
41 pub struct UnusedGenericParams {
43 pub param_spans: Vec<Span>,
44 pub param_names: Vec<String>,
47 impl SessionDiagnostic<'_> for UnusedGenericParams {
50 sess: &'_ rustc_session::parse::ParseSess,
51 ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
52 let mut diag = sess.struct_err(rustc_errors::fluent::monomorphize::unused_generic_params);
53 diag.set_span(self.span);
54 for (span, name) in self.param_spans.into_iter().zip(self.param_names) {
55 // FIXME: I can figure out how to do a label with a fluent string with a fixed message,
56 // or a label with a dynamic value in a hard-coded string, but I haven't figured out
57 // how to combine the two. 😢
58 diag.span_label(span, format!("generic parameter `{}` is unused", name));
64 #[derive(LintDiagnostic)]
65 #[diag(monomorphize::large_assignments)]
67 pub struct LargeAssignmentsLint {
74 #[derive(SessionDiagnostic)]
75 #[diag(monomorphize::unknown_partition_strategy)]
76 pub struct UnknownPartitionStrategy;
78 #[derive(SessionDiagnostic)]
79 #[diag(monomorphize::symbol_already_defined)]
80 pub struct SymbolAlreadyDefined {
82 pub span: Option<Span>,