diff options
| author | bors <bors@rust-lang.org> | 2024-11-26 21:57:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-11-26 21:57:32 +0000 |
| commit | dd2837ec5de4301a692e05a7c4475e980af57a57 (patch) | |
| tree | 385aaedfc698a1f470138f38ace6b5d0abc9d0f0 /compiler/rustc_target/src/spec/tests | |
| parent | dff3e7ccd4a18958c938136c4ccdc853fcc86194 (diff) | |
| parent | c4e2b0c60514736dbacc65908217197cf15d6b83 (diff) | |
Auto merge of #133505 - compiler-errors:rollup-xjp8hdi, r=compiler-errors
Rollup of 12 pull requests
Successful merges:
- #133042 (btree: add `{Entry,VacantEntry}::insert_entry`)
- #133070 (Lexer tweaks)
- #133136 (Support ranges in `<[T]>::get_many_mut()`)
- #133140 (Inline ExprPrecedence::order into Expr::precedence)
- #133155 (Yet more `rustc_mir_dataflow` cleanups)
- #133282 (Shorten the `MaybeUninit` `Debug` implementation)
- #133326 (Remove the `DefinitelyInitializedPlaces` analysis.)
- #133362 (No need to re-sort existential preds in relate impl)
- #133367 (Simplify array length mismatch error reporting (to not try to turn consts into target usizes))
- #133394 (Bail on more errors in dyn ty lowering)
- #133410 (target check_consistency: ensure target feature string makes some basic sense)
- #133435 (miri: disable test_downgrade_observe test on macOS)
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_target/src/spec/tests')
| -rw-r--r-- | compiler/rustc_target/src/spec/tests/tests_impl.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/spec/tests/tests_impl.rs b/compiler/rustc_target/src/spec/tests/tests_impl.rs index 522b9f837d7..3225cdc759d 100644 --- a/compiler/rustc_target/src/spec/tests/tests_impl.rs +++ b/compiler/rustc_target/src/spec/tests/tests_impl.rs @@ -1,5 +1,7 @@ use std::assert_matches::assert_matches; +use rustc_data_structures::fx::FxHashSet; + use super::super::*; // Test target self-consistency and JSON encoding/decoding roundtrip. @@ -173,6 +175,27 @@ impl Target { } _ => {} } + + // Check that the given target-features string makes some basic sense. + if !self.features.is_empty() { + let mut features_enabled = FxHashSet::default(); + let mut features_disabled = FxHashSet::default(); + for feat in self.features.split(',') { + if let Some(feat) = feat.strip_prefix("+") { + features_enabled.insert(feat); + if features_disabled.contains(feat) { + panic!("target feature `{feat}` is both enabled and disabled"); + } + } else if let Some(feat) = feat.strip_prefix("-") { + features_disabled.insert(feat); + if features_enabled.contains(feat) { + panic!("target feature `{feat}` is both enabled and disabled"); + } + } else { + panic!("target feature `{feat}` is invalid, must start with `+` or `-`"); + } + } + } } // Add your target to the whitelist if it has `std` library |
