]>
Commit | Line | Data |
---|---|---|
f2b60f7d FG |
1 | use std::path::PathBuf; |
2 | ||
9ffffee4 | 3 | use crate::fluent_generated as fluent; |
f2b60f7d | 4 | use rustc_errors::ErrorGuaranteed; |
2b03887a FG |
5 | use rustc_errors::IntoDiagnostic; |
6 | use rustc_macros::{Diagnostic, LintDiagnostic}; | |
781aab86 | 7 | use rustc_span::{Span, Symbol}; |
f2b60f7d | 8 | |
2b03887a FG |
9 | #[derive(Diagnostic)] |
10 | #[diag(monomorphize_recursion_limit)] | |
f2b60f7d FG |
11 | pub struct RecursionLimit { |
12 | #[primary_span] | |
13 | pub span: Span, | |
14 | pub shrunk: String, | |
15 | #[note] | |
16 | pub def_span: Span, | |
17 | pub def_path_str: String, | |
2b03887a | 18 | #[note(monomorphize_written_to_path)] |
f2b60f7d FG |
19 | pub was_written: Option<()>, |
20 | pub path: PathBuf, | |
21 | } | |
22 | ||
2b03887a FG |
23 | #[derive(Diagnostic)] |
24 | #[diag(monomorphize_type_length_limit)] | |
25 | #[help(monomorphize_consider_type_length_limit)] | |
f2b60f7d FG |
26 | pub struct TypeLengthLimit { |
27 | #[primary_span] | |
28 | pub span: Span, | |
29 | pub shrunk: String, | |
2b03887a | 30 | #[note(monomorphize_written_to_path)] |
f2b60f7d FG |
31 | pub was_written: Option<()>, |
32 | pub path: PathBuf, | |
33 | pub type_length: usize, | |
34 | } | |
35 | ||
781aab86 FG |
36 | #[derive(Diagnostic)] |
37 | #[diag(monomorphize_no_optimized_mir)] | |
38 | pub struct NoOptimizedMir { | |
39 | #[note] | |
40 | pub span: Span, | |
41 | pub crate_name: Symbol, | |
42 | } | |
43 | ||
9c376795 | 44 | pub struct UnusedGenericParamsHint { |
f2b60f7d FG |
45 | pub span: Span, |
46 | pub param_spans: Vec<Span>, | |
47 | pub param_names: Vec<String>, | |
48 | } | |
49 | ||
9c376795 | 50 | impl IntoDiagnostic<'_> for UnusedGenericParamsHint { |
487cf647 | 51 | #[track_caller] |
f2b60f7d FG |
52 | fn into_diagnostic( |
53 | self, | |
54 | handler: &'_ rustc_errors::Handler, | |
55 | ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> { | |
9ffffee4 | 56 | let mut diag = handler.struct_err(fluent::monomorphize_unused_generic_params); |
f2b60f7d FG |
57 | diag.set_span(self.span); |
58 | for (span, name) in self.param_spans.into_iter().zip(self.param_names) { | |
59 | // FIXME: I can figure out how to do a label with a fluent string with a fixed message, | |
60 | // or a label with a dynamic value in a hard-coded string, but I haven't figured out | |
61 | // how to combine the two. 😢 | |
9c376795 | 62 | diag.span_label(span, format!("generic parameter `{name}` is unused")); |
f2b60f7d FG |
63 | } |
64 | diag | |
65 | } | |
66 | } | |
67 | ||
68 | #[derive(LintDiagnostic)] | |
2b03887a | 69 | #[diag(monomorphize_large_assignments)] |
f2b60f7d FG |
70 | #[note] |
71 | pub struct LargeAssignmentsLint { | |
72 | #[label] | |
73 | pub span: Span, | |
74 | pub size: u64, | |
75 | pub limit: u64, | |
76 | } | |
77 | ||
2b03887a FG |
78 | #[derive(Diagnostic)] |
79 | #[diag(monomorphize_unknown_partition_strategy)] | |
f2b60f7d FG |
80 | pub struct UnknownPartitionStrategy; |
81 | ||
2b03887a FG |
82 | #[derive(Diagnostic)] |
83 | #[diag(monomorphize_symbol_already_defined)] | |
f2b60f7d FG |
84 | pub struct SymbolAlreadyDefined { |
85 | #[primary_span] | |
86 | pub span: Option<Span>, | |
87 | pub symbol: String, | |
88 | } | |
9c376795 FG |
89 | |
90 | #[derive(Diagnostic)] | |
91 | #[diag(monomorphize_couldnt_dump_mono_stats)] | |
92 | pub struct CouldntDumpMonoStats { | |
93 | pub error: String, | |
94 | } | |
9ffffee4 FG |
95 | |
96 | #[derive(Diagnostic)] | |
97 | #[diag(monomorphize_encountered_error_while_instantiating)] | |
98 | pub struct EncounteredErrorWhileInstantiating { | |
99 | #[primary_span] | |
100 | pub span: Span, | |
101 | pub formatted_item: String, | |
102 | } | |
103 | ||
104 | #[derive(Diagnostic)] | |
105 | #[diag(monomorphize_unknown_cgu_collection_mode)] | |
106 | pub struct UnknownCguCollectionMode<'a> { | |
107 | pub mode: &'a str, | |
108 | } |