1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
use std::path::PathBuf;
use rustc_errors::ErrorGuaranteed;
use rustc_macros::{LintDiagnostic, SessionDiagnostic};
use rustc_session::SessionDiagnostic;
use rustc_span::Span;
#[derive(SessionDiagnostic)]
#[diag(monomorphize::recursion_limit)]
pub struct RecursionLimit {
#[primary_span]
pub span: Span,
pub shrunk: String,
#[note]
pub def_span: Span,
pub def_path_str: String,
#[note(monomorphize::written_to_path)]
pub was_written: Option<()>,
pub path: PathBuf,
}
#[derive(SessionDiagnostic)]
#[diag(monomorphize::type_length_limit)]
#[help(monomorphize::consider_type_length_limit)]
pub struct TypeLengthLimit {
#[primary_span]
pub span: Span,
pub shrunk: String,
#[note(monomorphize::written_to_path)]
pub was_written: Option<()>,
pub path: PathBuf,
pub type_length: usize,
}
#[derive(SessionDiagnostic)]
#[diag(monomorphize::requires_lang_item)]
pub struct RequiresLangItem {
pub lang_item: String,
}
pub struct UnusedGenericParams {
pub span: Span,
pub param_spans: Vec<Span>,
pub param_names: Vec<String>,
}
impl SessionDiagnostic<'_> for UnusedGenericParams {
fn into_diagnostic(
self,
handler: &'_ rustc_errors::Handler,
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag =
handler.struct_err(rustc_errors::fluent::monomorphize::unused_generic_params);
diag.set_span(self.span);
for (span, name) in self.param_spans.into_iter().zip(self.param_names) {
diag.span_label(span, format!("generic parameter `{}` is unused", name));
}
diag
}
}
#[derive(LintDiagnostic)]
#[diag(monomorphize::large_assignments)]
#[note]
pub struct LargeAssignmentsLint {
#[label]
pub span: Span,
pub size: u64,
pub limit: u64,
}
#[derive(SessionDiagnostic)]
#[diag(monomorphize::unknown_partition_strategy)]
pub struct UnknownPartitionStrategy;
#[derive(SessionDiagnostic)]
#[diag(monomorphize::symbol_already_defined)]
pub struct SymbolAlreadyDefined {
#[primary_span]
pub span: Option<Span>,
pub symbol: String,
}