diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-10-10 22:00:45 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-10 22:00:45 +0200 | 
| commit | 13976f1f25ac64d53a2e1317153f4cfb1324b351 (patch) | |
| tree | dd0c0800e3defaf3a5bd073141e635690d6494c0 /compiler/rustc_codegen_ssa/src/errors.rs | |
| parent | 8d94e06ec9758b5c03ea77bb5dab22a1a76bc261 (diff) | |
| parent | 207bc77e15acc9444bf6c3e74fa46607490a8e8a (diff) | |
| download | rust-13976f1f25ac64d53a2e1317153f4cfb1324b351.tar.gz rust-13976f1f25ac64d53a2e1317153f4cfb1324b351.zip  | |
Rollup merge of #130308 - davidtwco:tied-target-consolidation, r=wesleywiser
codegen_ssa: consolidate tied target checks Fixes #105110. Fixes #105111. `rustc_codegen_llvm` and `rustc_codegen_gcc` duplicated logic for checking if tied target features were partially enabled. This PR consolidates these checks into `rustc_codegen_ssa` in the `codegen_fn_attrs` query, which also is run pre-monomorphisation for each function, which ensures that this check is run for unused functions, as would be expected. Also adds a test confirming that enabling one tied feature doesn't imply another - the appropriate error for this was already being emitted. I did a bisect and narrowed it down to two patches it was likely to be - something in #128796, probably #128221 or #128679.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/errors.rs')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/errors.rs | 26 | 
1 files changed, 25 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs index ab909abcead..d67cf0e3a6d 100644 --- a/compiler/rustc_codegen_ssa/src/errors.rs +++ b/compiler/rustc_codegen_ssa/src/errors.rs @@ -9,7 +9,7 @@ use rustc_errors::codes::*; use rustc_errors::{ Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level, }; -use rustc_macros::Diagnostic; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::LayoutError; use rustc_span::{Span, Symbol}; @@ -1068,3 +1068,27 @@ pub(crate) struct ErrorCreatingImportLibrary<'a> { pub lib_name: &'a str, pub error: String, } + +pub struct TargetFeatureDisableOrEnable<'a> { + pub features: &'a [&'a str], + pub span: Option<Span>, + pub missing_features: Option<MissingFeatures>, +} + +#[derive(Subdiagnostic)] +#[help(codegen_ssa_missing_features)] +pub struct MissingFeatures; + +impl<G: EmissionGuarantee> Diagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { + let mut diag = Diag::new(dcx, level, fluent::codegen_ssa_target_feature_disable_or_enable); + if let Some(span) = self.span { + diag.span(span); + }; + if let Some(missing_features) = self.missing_features { + diag.subdiagnostic(missing_features); + } + diag.arg("features", self.features.join(", ")); + diag + } +}  | 
