2022-08-18 16:51:47 -05:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2022-10-13 04:13:02 -05:00
|
|
|
use crate::fluent_generated as fluent;
|
2022-08-18 16:51:47 -05:00
|
|
|
use rustc_errors::ErrorGuaranteed;
|
2022-09-14 23:01:44 -05:00
|
|
|
use rustc_errors::IntoDiagnostic;
|
2022-09-18 10:46:56 -05:00
|
|
|
use rustc_macros::{Diagnostic, LintDiagnostic};
|
2022-08-18 16:51:47 -05:00
|
|
|
use rustc_span::Span;
|
|
|
|
|
2022-09-18 10:46:56 -05:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[diag(monomorphize_recursion_limit)]
|
2022-08-18 16:51:47 -05:00
|
|
|
pub struct RecursionLimit {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub shrunk: String,
|
|
|
|
#[note]
|
|
|
|
pub def_span: Span,
|
|
|
|
pub def_path_str: String,
|
2022-10-22 04:07:54 -05:00
|
|
|
#[note(monomorphize_written_to_path)]
|
2022-08-18 16:51:47 -05:00
|
|
|
pub was_written: Option<()>,
|
|
|
|
pub path: PathBuf,
|
|
|
|
}
|
|
|
|
|
2022-09-18 10:46:56 -05:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[diag(monomorphize_type_length_limit)]
|
|
|
|
#[help(monomorphize_consider_type_length_limit)]
|
2022-08-18 16:51:47 -05:00
|
|
|
pub struct TypeLengthLimit {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub shrunk: String,
|
2022-10-22 04:07:54 -05:00
|
|
|
#[note(monomorphize_written_to_path)]
|
2022-08-18 16:51:47 -05:00
|
|
|
pub was_written: Option<()>,
|
|
|
|
pub path: PathBuf,
|
|
|
|
pub type_length: usize,
|
|
|
|
}
|
|
|
|
|
2022-12-01 11:57:53 -06:00
|
|
|
pub struct UnusedGenericParamsHint {
|
2022-08-18 16:51:47 -05:00
|
|
|
pub span: Span,
|
|
|
|
pub param_spans: Vec<Span>,
|
|
|
|
pub param_names: Vec<String>,
|
|
|
|
}
|
|
|
|
|
2022-12-01 11:57:53 -06:00
|
|
|
impl IntoDiagnostic<'_> for UnusedGenericParamsHint {
|
2022-10-31 10:14:29 -05:00
|
|
|
#[track_caller]
|
2022-08-18 16:51:47 -05:00
|
|
|
fn into_diagnostic(
|
|
|
|
self,
|
2022-09-04 23:15:50 -05:00
|
|
|
handler: &'_ rustc_errors::Handler,
|
2022-08-18 16:51:47 -05:00
|
|
|
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
2022-10-13 04:13:02 -05:00
|
|
|
let mut diag = handler.struct_err(fluent::monomorphize_unused_generic_params);
|
2022-08-18 16:51:47 -05:00
|
|
|
diag.set_span(self.span);
|
|
|
|
for (span, name) in self.param_spans.into_iter().zip(self.param_names) {
|
|
|
|
// FIXME: I can figure out how to do a label with a fluent string with a fixed message,
|
|
|
|
// or a label with a dynamic value in a hard-coded string, but I haven't figured out
|
|
|
|
// how to combine the two. 😢
|
2022-12-19 03:31:55 -06:00
|
|
|
diag.span_label(span, format!("generic parameter `{name}` is unused"));
|
2022-08-18 16:51:47 -05:00
|
|
|
}
|
|
|
|
diag
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[diag(monomorphize_large_assignments)]
|
2022-08-18 16:51:47 -05:00
|
|
|
#[note]
|
|
|
|
pub struct LargeAssignmentsLint {
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
pub size: u64,
|
|
|
|
pub limit: u64,
|
|
|
|
}
|
2022-08-23 12:20:01 -05:00
|
|
|
|
2022-09-18 10:46:56 -05:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[diag(monomorphize_unknown_partition_strategy)]
|
2022-08-23 12:20:01 -05:00
|
|
|
pub struct UnknownPartitionStrategy;
|
|
|
|
|
2022-09-18 10:46:56 -05:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[diag(monomorphize_symbol_already_defined)]
|
2022-08-23 12:20:01 -05:00
|
|
|
pub struct SymbolAlreadyDefined {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Option<Span>,
|
|
|
|
pub symbol: String,
|
|
|
|
}
|
2022-12-08 13:21:08 -06:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(monomorphize_couldnt_dump_mono_stats)]
|
|
|
|
pub struct CouldntDumpMonoStats {
|
|
|
|
pub error: String,
|
|
|
|
}
|
2022-08-19 08:48:15 -05:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(monomorphize_encountered_error_while_instantiating)]
|
|
|
|
pub struct EncounteredErrorWhileInstantiating {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub formatted_item: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(monomorphize_unknown_cgu_collection_mode)]
|
|
|
|
pub struct UnknownCguCollectionMode<'a> {
|
|
|
|
pub mode: &'a str,
|
|
|
|
}
|