diff options
| author | bors <bors@rust-lang.org> | 2024-02-06 19:38:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-06 19:38:39 +0000 |
| commit | 0d531351e848ad69a03c704d40985c9003847427 (patch) | |
| tree | db91eddf4a9d263a2ed51dd7d388fb52af917875 /compiler/rustc_codegen_llvm/src | |
| parent | 4a2fe4491ea616983a0cf0cbbd145a39768f4e7a (diff) | |
| parent | d98a8a1185e1eec2fbd58f21f161c0292ca40f3a (diff) | |
| download | rust-0d531351e848ad69a03c704d40985c9003847427.tar.gz rust-0d531351e848ad69a03c704d40985c9003847427.zip | |
Auto merge of #120715 - matthiaskrgr:rollup-sp1pp74, r=matthiaskrgr
Rollup of 12 pull requests Successful merges: - #120520 (Some cleanups around diagnostic levels.) - #120575 (Simplify codegen diagnostic handling) - #120597 (Suggest `[tail @ ..]` on `[..tail]` and `[...tail]` where `tail` is unresolved) - #120602 (rustc_monomorphize: fix outdated comment in partition) - #120609 (hir: Stop keeping prefixes for most of `use` list stems) - #120631 (Emit a diagnostic for invalid target options) - #120632 (For E0223, suggest associated functions that are similar to the path) - #120670 (cleanup effect var handling) - #120673 (rustc_metadata: fix typo) - #120683 (miri: fix ICE with symbolic alignment check on extern static) - #120690 (Remove b-naber from the compiler review rotation) - #120713 (Make async closures test use async bound modifier) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/errors.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm_util.rs | 16 |
2 files changed, 14 insertions, 8 deletions
diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs index e839d278bea..587c5e9e8d2 100644 --- a/compiler/rustc_codegen_llvm/src/errors.rs +++ b/compiler/rustc_codegen_llvm/src/errors.rs @@ -253,3 +253,9 @@ pub struct MismatchedDataLayout<'a> { pub llvm_target: &'a str, pub llvm_layout: &'a str, } + +#[derive(Diagnostic)] +#[diag(codegen_llvm_invalid_target_feature_prefix)] +pub(crate) struct InvalidTargetFeaturePrefix<'a> { + pub feature: &'a str, +} diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 99f4488ac0f..4bb400b1879 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -1,7 +1,7 @@ use crate::back::write::create_informational_target_machine; use crate::errors::{ - PossibleFeature, TargetFeatureDisableOrEnable, UnknownCTargetFeature, - UnknownCTargetFeaturePrefix, UnstableCTargetFeature, + InvalidTargetFeaturePrefix, PossibleFeature, TargetFeatureDisableOrEnable, + UnknownCTargetFeature, UnknownCTargetFeaturePrefix, UnstableCTargetFeature, }; use crate::llvm; use libc::c_int; @@ -511,7 +511,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str sess.target .features .split(',') - .filter(|v| !v.is_empty() && backend_feature_name(v).is_some()) + .filter(|v| !v.is_empty() && backend_feature_name(sess, v).is_some()) .map(String::from), ); @@ -535,7 +535,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str } }; - let feature = backend_feature_name(s)?; + let feature = backend_feature_name(sess, s)?; // Warn against use of LLVM specific feature names and unstable features on the CLI. if diagnostics { let feature_state = supported_features.iter().find(|&&(v, _)| v == feature); @@ -611,11 +611,11 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str /// Returns a feature name for the given `+feature` or `-feature` string. /// /// Only allows features that are backend specific (i.e. not [`RUSTC_SPECIFIC_FEATURES`].) -fn backend_feature_name(s: &str) -> Option<&str> { +fn backend_feature_name<'a>(sess: &Session, s: &'a str) -> Option<&'a str> { // features must start with a `+` or `-`. - let feature = s.strip_prefix(&['+', '-'][..]).unwrap_or_else(|| { - bug!("target feature `{}` must begin with a `+` or `-`", s); - }); + let feature = s + .strip_prefix(&['+', '-'][..]) + .unwrap_or_else(|| sess.dcx().emit_fatal(InvalidTargetFeaturePrefix { feature: s })); // Rustc-specific feature requests like `+crt-static` or `-crt-static` // are not passed down to LLVM. if RUSTC_SPECIFIC_FEATURES.contains(&feature) { |
