2022-08-22 08:28:50 +02:00
|
|
|
use std::num::NonZeroU32;
|
|
|
|
|
2022-08-19 15:34:13 +02:00
|
|
|
use crate::cgu_reuse_tracker::CguReuse;
|
2022-09-15 00:01:44 -04:00
|
|
|
use rustc_errors::{
|
|
|
|
fluent, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, MultiSpan,
|
|
|
|
};
|
|
|
|
use rustc_macros::Diagnostic;
|
2022-08-22 08:28:50 +02:00
|
|
|
use rustc_span::{Span, Symbol};
|
2022-09-08 08:15:37 +02:00
|
|
|
use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple};
|
2022-08-19 15:34:13 +02:00
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-22 08:28:50 +02:00
|
|
|
#[diag(session::incorrect_cgu_reuse_type)]
|
2022-08-19 15:34:13 +02:00
|
|
|
pub struct IncorrectCguReuseType<'a> {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub cgu_user_name: &'a str,
|
|
|
|
pub actual_reuse: CguReuse,
|
|
|
|
pub expected_reuse: CguReuse,
|
2022-08-24 17:15:08 +02:00
|
|
|
pub at_least: u8,
|
2022-08-19 15:34:13 +02:00
|
|
|
}
|
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-24 17:15:08 +02:00
|
|
|
#[diag(session::cgu_not_recorded)]
|
|
|
|
pub struct CguNotRecorded<'a> {
|
|
|
|
pub cgu_user_name: &'a str,
|
|
|
|
pub cgu_name: &'a str,
|
|
|
|
}
|
2022-08-22 08:28:50 +02:00
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-22 08:28:50 +02:00
|
|
|
#[diag(session::feature_gate_error, code = "E0658")]
|
|
|
|
pub struct FeatureGateError<'a> {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: MultiSpan,
|
|
|
|
pub explain: &'a str,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:47:31 -04:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-08-22 08:28:50 +02:00
|
|
|
#[note(session::feature_diagnostic_for_issue)]
|
|
|
|
pub struct FeatureDiagnosticForIssue {
|
|
|
|
pub n: NonZeroU32,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:47:31 -04:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-08-22 08:28:50 +02:00
|
|
|
#[help(session::feature_diagnostic_help)]
|
|
|
|
pub struct FeatureDiagnosticHelp {
|
|
|
|
pub feature: Symbol,
|
|
|
|
}
|
2022-08-26 16:06:27 +02:00
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-26 16:06:27 +02:00
|
|
|
#[diag(session::not_circumvent_feature)]
|
|
|
|
pub struct NotCircumventFeature;
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-26 16:06:27 +02:00
|
|
|
#[diag(session::linker_plugin_lto_windows_not_supported)]
|
|
|
|
pub struct LinkerPluginToWindowsNotSupported;
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-26 16:06:27 +02:00
|
|
|
#[diag(session::profile_use_file_does_not_exist)]
|
|
|
|
pub struct ProfileUseFileDoesNotExist<'a> {
|
|
|
|
pub path: &'a std::path::Path,
|
|
|
|
}
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-26 16:06:27 +02:00
|
|
|
#[diag(session::profile_sample_use_file_does_not_exist)]
|
|
|
|
pub struct ProfileSampleUseFileDoesNotExist<'a> {
|
|
|
|
pub path: &'a std::path::Path,
|
|
|
|
}
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-26 16:06:27 +02:00
|
|
|
#[diag(session::target_requires_unwind_tables)]
|
|
|
|
pub struct TargetRequiresUnwindTables;
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-26 16:06:27 +02:00
|
|
|
#[diag(session::sanitizer_not_supported)]
|
|
|
|
pub struct SanitizerNotSupported {
|
|
|
|
pub us: String,
|
|
|
|
}
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-26 16:06:27 +02:00
|
|
|
#[diag(session::sanitizers_not_supported)]
|
|
|
|
pub struct SanitizersNotSupported {
|
|
|
|
pub us: String,
|
|
|
|
}
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-26 16:06:27 +02:00
|
|
|
#[diag(session::cannot_mix_and_match_sanitizers)]
|
|
|
|
pub struct CannotMixAndMatchSanitizers {
|
|
|
|
pub first: String,
|
|
|
|
pub second: String,
|
|
|
|
}
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-26 16:06:27 +02:00
|
|
|
#[diag(session::cannot_enable_crt_static_linux)]
|
|
|
|
pub struct CannotEnableCrtStaticLinux;
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-26 16:06:27 +02:00
|
|
|
#[diag(session::sanitizer_cfi_enabled)]
|
|
|
|
pub struct SanitizerCfiEnabled;
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-26 16:06:27 +02:00
|
|
|
#[diag(session::unstable_virtual_function_elimination)]
|
|
|
|
pub struct UnstableVirtualFunctionElimination;
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-26 16:06:27 +02:00
|
|
|
#[diag(session::unsupported_dwarf_version)]
|
|
|
|
pub struct UnsupportedDwarfVersion {
|
|
|
|
pub dwarf_version: u32,
|
|
|
|
}
|
2022-09-08 08:15:37 +02:00
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-09-08 08:15:37 +02:00
|
|
|
#[diag(session::target_stack_protector_not_supported)]
|
|
|
|
pub struct StackProtectorNotSupportedForTarget<'a> {
|
|
|
|
pub stack_protector: StackProtector,
|
|
|
|
pub target_triple: &'a TargetTriple,
|
|
|
|
}
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-09-08 08:15:37 +02:00
|
|
|
#[diag(session::split_debuginfo_unstable_platform)]
|
|
|
|
pub struct SplitDebugInfoUnstablePlatform {
|
|
|
|
pub debuginfo: SplitDebuginfo,
|
|
|
|
}
|
2022-09-01 08:03:47 +02:00
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-09-01 08:03:47 +02:00
|
|
|
#[diag(session::file_is_not_writeable)]
|
|
|
|
pub struct FileIsNotWriteable<'a> {
|
|
|
|
pub file: &'a std::path::Path,
|
|
|
|
}
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-09-01 08:03:47 +02:00
|
|
|
#[diag(session::crate_name_does_not_match)]
|
|
|
|
pub struct CrateNameDoesNotMatch<'a> {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub s: &'a str,
|
|
|
|
pub name: Symbol,
|
|
|
|
}
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-09-01 08:03:47 +02:00
|
|
|
#[diag(session::crate_name_invalid)]
|
|
|
|
pub struct CrateNameInvalid<'a> {
|
|
|
|
pub s: &'a str,
|
|
|
|
}
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-09-01 08:03:47 +02:00
|
|
|
#[diag(session::crate_name_empty)]
|
|
|
|
pub struct CrateNameEmpty {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Option<Span>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct InvalidCharacterInCrateName<'a> {
|
|
|
|
pub span: Option<Span>,
|
|
|
|
pub character: char,
|
|
|
|
pub crate_name: &'a str,
|
|
|
|
}
|
|
|
|
|
2022-09-15 00:01:44 -04:00
|
|
|
impl IntoDiagnostic<'_> for InvalidCharacterInCrateName<'_> {
|
|
|
|
fn into_diagnostic(self, sess: &Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
2022-09-01 08:03:47 +02:00
|
|
|
let mut diag = sess.struct_err(fluent::session::invalid_character_in_create_name);
|
|
|
|
if let Some(sp) = self.span {
|
|
|
|
diag.set_span(sp);
|
|
|
|
}
|
|
|
|
diag.set_arg("character", self.character);
|
|
|
|
diag.set_arg("crate_name", self.crate_name);
|
|
|
|
diag
|
|
|
|
}
|
|
|
|
}
|
2022-08-25 10:58:53 +02:00
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[multipart_suggestion(session::expr_parentheses_needed, applicability = "machine-applicable")]
|
|
|
|
pub struct ExprParenthesesNeeded {
|
|
|
|
#[suggestion_part(code = "(")]
|
|
|
|
pub left: Span,
|
|
|
|
#[suggestion_part(code = ")")]
|
|
|
|
pub right: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ExprParenthesesNeeded {
|
|
|
|
pub fn surrounding(s: Span) -> Self {
|
|
|
|
ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() }
|
|
|
|
}
|
|
|
|
}
|