File tree 1 file changed +21
-0
lines changed
compiler/rustc_target/src/spec/tests
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1
1
use std:: assert_matches:: assert_matches;
2
2
3
+ use rustc_data_structures:: fx:: FxHashSet ;
4
+
3
5
use super :: super :: * ;
4
6
5
7
// Test target self-consistency and JSON encoding/decoding roundtrip.
@@ -170,6 +172,25 @@ impl Target {
170
172
}
171
173
_ => { }
172
174
}
175
+
176
+ // Check that the given target-features string makes some basic sense.
177
+ let mut features_enabled = FxHashSet :: default ( ) ;
178
+ let mut features_disabled = FxHashSet :: default ( ) ;
179
+ for feat in self . features . split ( ',' ) {
180
+ if let Some ( feat) = feat. strip_prefix ( "+" ) {
181
+ features_enabled. insert ( feat) ;
182
+ if features_disabled. contains ( feat) {
183
+ panic ! ( "target feature `{feat}` is both enabled and disabled" ) ;
184
+ }
185
+ } else if let Some ( feat) = feat. strip_prefix ( "-" ) {
186
+ features_disabled. insert ( feat) ;
187
+ if features_enabled. contains ( feat) {
188
+ panic ! ( "target feature `{feat}` is both enabled and disabled" ) ;
189
+ }
190
+ } else {
191
+ panic ! ( "target feature `{feat}` is invalid, must start with `+` or `-`" ) ;
192
+ }
193
+ }
173
194
}
174
195
175
196
// Add your target to the whitelist if it has `std` library
You can’t perform that action at this time.
0 commit comments