target check_consistency: ensure target feature string makes some basic sense
This commit is contained in:
parent
4e4c20d2ab
commit
5d42f64ad2
1 changed files with 23 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
||||||
use std::assert_matches::assert_matches;
|
use std::assert_matches::assert_matches;
|
||||||
|
|
||||||
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
|
|
||||||
use super::super::*;
|
use super::super::*;
|
||||||
|
|
||||||
// Test target self-consistency and JSON encoding/decoding roundtrip.
|
// Test target self-consistency and JSON encoding/decoding roundtrip.
|
||||||
|
@ -170,6 +172,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
|
// Add your target to the whitelist if it has `std` library
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue