rust/compiler/rustc_session/src/errors.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

194 lines
4.6 KiB
Rust
Raw Normal View History

use std::num::NonZeroU32;
use crate::cgu_reuse_tracker::CguReuse;
use rustc_errors::MultiSpan;
use rustc_macros::Diagnostic;
use rustc_span::{Span, Symbol};
use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple};
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_incorrect_cgu_reuse_type)]
pub struct IncorrectCguReuseType<'a> {
#[primary_span]
pub span: Span,
pub cgu_user_name: &'a str,
pub actual_reuse: CguReuse,
pub expected_reuse: CguReuse,
pub at_least: u8,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_cgu_not_recorded)]
pub struct CguNotRecorded<'a> {
pub cgu_user_name: &'a str,
pub cgu_name: &'a str,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_feature_gate_error, code = "E0658")]
pub struct FeatureGateError<'a> {
#[primary_span]
pub span: MultiSpan,
pub explain: &'a str,
}
#[derive(Subdiagnostic)]
2022-10-22 09:07:54 +00:00
#[note(session_feature_diagnostic_for_issue)]
pub struct FeatureDiagnosticForIssue {
pub n: NonZeroU32,
}
#[derive(Subdiagnostic)]
2022-10-22 09:07:54 +00:00
#[help(session_feature_diagnostic_help)]
pub struct FeatureDiagnosticHelp {
pub feature: Symbol,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_not_circumvent_feature)]
pub struct NotCircumventFeature;
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_linker_plugin_lto_windows_not_supported)]
pub struct LinkerPluginToWindowsNotSupported;
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_profile_use_file_does_not_exist)]
pub struct ProfileUseFileDoesNotExist<'a> {
pub path: &'a std::path::Path,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_profile_sample_use_file_does_not_exist)]
pub struct ProfileSampleUseFileDoesNotExist<'a> {
pub path: &'a std::path::Path,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_target_requires_unwind_tables)]
pub struct TargetRequiresUnwindTables;
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_sanitizer_not_supported)]
pub struct SanitizerNotSupported {
pub us: String,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_sanitizers_not_supported)]
pub struct SanitizersNotSupported {
pub us: String,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_cannot_mix_and_match_sanitizers)]
pub struct CannotMixAndMatchSanitizers {
pub first: String,
pub second: String,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_cannot_enable_crt_static_linux)]
pub struct CannotEnableCrtStaticLinux;
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_sanitizer_cfi_enabled)]
pub struct SanitizerCfiEnabled;
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_unstable_virtual_function_elimination)]
pub struct UnstableVirtualFunctionElimination;
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_unsupported_dwarf_version)]
pub struct UnsupportedDwarfVersion {
pub dwarf_version: u32,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_target_stack_protector_not_supported)]
pub struct StackProtectorNotSupportedForTarget<'a> {
pub stack_protector: StackProtector,
pub target_triple: &'a TargetTriple,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_split_debuginfo_unstable_platform)]
pub struct SplitDebugInfoUnstablePlatform {
pub debuginfo: SplitDebuginfo,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_file_is_not_writeable)]
pub struct FileIsNotWriteable<'a> {
pub file: &'a std::path::Path,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_crate_name_does_not_match)]
pub struct CrateNameDoesNotMatch<'a> {
#[primary_span]
pub span: Span,
pub s: &'a str,
pub name: Symbol,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_crate_name_invalid)]
pub struct CrateNameInvalid<'a> {
pub s: &'a str,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_crate_name_empty)]
pub struct CrateNameEmpty {
#[primary_span]
pub span: Option<Span>,
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_invalid_character_in_create_name)]
pub struct InvalidCharacterInCrateName<'a> {
#[primary_span]
pub span: Option<Span>,
pub character: char,
pub crate_name: &'a str,
}
#[derive(Subdiagnostic)]
2022-10-22 09:07:54 +00:00
#[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() }
}
}
#[derive(Diagnostic)]
2022-10-22 09:07:54 +00:00
#[diag(session_skipping_const_checks)]
pub struct SkippingConstChecks {
#[subdiagnostic(eager)]
pub unleashed_features: Vec<UnleashedFeatureHelp>,
}
#[derive(Subdiagnostic)]
pub enum UnleashedFeatureHelp {
2022-10-22 09:07:54 +00:00
#[help(session_unleashed_feature_help_named)]
Named {
#[primary_span]
span: Span,
gate: Symbol,
},
2022-10-22 09:07:54 +00:00
#[help(session_unleashed_feature_help_unnamed)]
Unnamed {
#[primary_span]
span: Span,
},
}