-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Migrate rustc_codegen_llvm to SessionDiagnostics #101005
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merged
bors
merged 35 commits into
rust-lang:master
from
SLASHLogin:rustc_codegen_llvm_diagnostics
Nov 10, 2022
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
575f609
Port unknown feature diagnostic to the new framework
SLASHLogin a54c800
Formatting
SLASHLogin 1c4bd83
locales formatting
SLASHLogin 21b0426
Trailing whitespaces
SLASHLogin b164790
Change String in structs to &'a str
SLASHLogin 69d412a
Missing lifetime parameter and formatting
SLASHLogin 05ae7ec
Import `error creating import library`
SLASHLogin 4c625dc
Port Instrument coverage requires llvm 12 to the new struct
SLASHLogin 9f0c165
Port `symbol_already_defined` error
SLASHLogin ec1e101
Fix diag() and formatting
SLASHLogin 59b8aed
Port branch protection on aarch64
SLASHLogin f031823
Formatting
SLASHLogin 39d363f
Port layout size overflow
SLASHLogin 5d79d3c
Port InvalidMinimumAlignment
SLASHLogin 60ee496
Port LinkageConstOrMutType error
SLASHLogin 02403ee
Reuse SymbolAlreadyDefined
SLASHLogin 978b5f7
Port SanitizerMemtagRequiresMte
SLASHLogin d32caf9
Port ArchiveBuildFailure
SLASHLogin ddbb650
Import ErrorWritingDEFFile
SLASHLogin 81f7a8d
Port ErrorCallingDllTool
SLASHLogin c01546f
Port `DlltoolFailImportLibrary` and implement `IntoDiagnosticArg` for…
SLASHLogin 33ef16f
Port `UnknownArchiveKind`
SLASHLogin 185ef7b
Port `MissingFeatures` and `TargetFeatureDisableOrEnable`
SLASHLogin 1c7a801
Fix CI
SLASHLogin e9a5329
Correct tests to match errors
SLASHLogin 67394e7
Flatten diagnostic structs
SLASHLogin 3728e95
Port diagnostics created by `Handler`
SLASHLogin 9a15458
Simplify existing Diagnostic implementations
SLASHLogin b4820a3
Delay diagnostic translation in `rustc_codegen_ssa`
SLASHLogin 3b949eb
Add `replace_args` method for `rustc_errors::diagnostic::Diagnostic`
SLASHLogin 0381e51
Formatting
SLASHLogin a8a8055
Use `LayoutError`'s implementation of `IntoDiagnostic`
SLASHLogin 0baac88
Update compiler/rustc_codegen_llvm/src/back/archive.rs
SLASHLogin 39895b0
Add constructor for `Diagnostic` that takes `Vec<(DiagnosticMessage, …
SLASHLogin caada74
Add missing `emitted_at` to the `Diagnostic`
SLASHLogin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
use std::borrow::Cow; | ||
|
||
use rustc_errors::fluent; | ||
use rustc_errors::DiagnosticBuilder; | ||
use rustc_errors::ErrorGuaranteed; | ||
use rustc_errors::Handler; | ||
use rustc_errors::IntoDiagnostic; | ||
use rustc_macros::{Diagnostic, Subdiagnostic}; | ||
use rustc_span::Span; | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_unknown_ctarget_feature_prefix)] | ||
#[note] | ||
pub(crate) struct UnknownCTargetFeaturePrefix<'a> { | ||
pub feature: &'a str, | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_unknown_ctarget_feature)] | ||
#[note] | ||
pub(crate) struct UnknownCTargetFeature<'a> { | ||
pub feature: &'a str, | ||
#[subdiagnostic] | ||
pub rust_feature: PossibleFeature<'a>, | ||
} | ||
|
||
#[derive(Subdiagnostic)] | ||
pub(crate) enum PossibleFeature<'a> { | ||
#[help(possible_feature)] | ||
Some { rust_feature: &'a str }, | ||
#[help(consider_filing_feature_request)] | ||
None, | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_error_creating_import_library)] | ||
pub(crate) struct ErrorCreatingImportLibrary<'a> { | ||
pub lib_name: &'a str, | ||
pub error: String, | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_instrument_coverage_requires_llvm_12)] | ||
pub(crate) struct InstrumentCoverageRequiresLLVM12; | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_symbol_already_defined)] | ||
pub(crate) struct SymbolAlreadyDefined<'a> { | ||
#[primary_span] | ||
pub span: Span, | ||
pub symbol_name: &'a str, | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_branch_protection_requires_aarch64)] | ||
pub(crate) struct BranchProtectionRequiresAArch64; | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_invalid_minimum_alignment)] | ||
pub(crate) struct InvalidMinimumAlignment { | ||
pub err: String, | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_linkage_const_or_mut_type)] | ||
pub(crate) struct LinkageConstOrMutType { | ||
#[primary_span] | ||
pub span: Span, | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_sanitizer_memtag_requires_mte)] | ||
pub(crate) struct SanitizerMemtagRequiresMte; | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_archive_build_failure)] | ||
pub(crate) struct ArchiveBuildFailure { | ||
pub error: std::io::Error, | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_error_writing_def_file)] | ||
pub(crate) struct ErrorWritingDEFFile { | ||
pub error: std::io::Error, | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_error_calling_dlltool)] | ||
pub(crate) struct ErrorCallingDllTool { | ||
pub error: std::io::Error, | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_dlltool_fail_import_library)] | ||
pub(crate) struct DlltoolFailImportLibrary<'a> { | ||
pub stdout: Cow<'a, str>, | ||
pub stderr: Cow<'a, str>, | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_unknown_archive_kind)] | ||
pub(crate) struct UnknownArchiveKind<'a> { | ||
pub kind: &'a str, | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_dynamic_linking_with_lto)] | ||
#[note] | ||
pub(crate) struct DynamicLinkingWithLTO; | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(codegen_llvm_fail_parsing_target_machine_config_to_target_machine)] | ||
pub(crate) struct FailParsingTargetMachineConfigToTargetMachine { | ||
pub error: String, | ||
} | ||
|
||
pub(crate) struct TargetFeatureDisableOrEnable<'a> { | ||
pub features: &'a [&'a str], | ||
pub span: Option<Span>, | ||
pub missing_features: Option<MissingFeatures>, | ||
} | ||
|
||
#[derive(Subdiagnostic)] | ||
#[help(codegen_llvm_missing_features)] | ||
pub(crate) struct MissingFeatures; | ||
|
||
impl IntoDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> { | ||
fn into_diagnostic(self, sess: &'_ Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> { | ||
let mut diag = sess.struct_err(fluent::codegen_llvm_target_feature_disable_or_enable); | ||
if let Some(span) = self.span { | ||
diag.set_span(span); | ||
}; | ||
if let Some(missing_features) = self.missing_features { | ||
diag.subdiagnostic(missing_features); | ||
} | ||
diag.set_arg("features", self.features.join(", ")); | ||
davidtwco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
diag | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.