File tree 1 file changed +23
-0
lines changed
compiler/rustc_target/src/spec/tests
1 file changed +23
-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,27 @@ impl Target {
170
172
}
171
173
_ => { }
172
174
}
175
+
176
+ // Check that the given target-features string makes some basic sense.
177
+ if !self . features . is_empty ( ) {
178
+ let mut features_enabled = FxHashSet :: default ( ) ;
179
+ let mut features_disabled = FxHashSet :: default ( ) ;
180
+ for feat in self . features . split ( ',' ) {
181
+ if let Some ( feat) = feat. strip_prefix ( "+" ) {
182
+ features_enabled. insert ( feat) ;
183
+ if features_disabled. contains ( feat) {
184
+ panic ! ( "target feature `{feat}` is both enabled and disabled" ) ;
185
+ }
186
+ } else if let Some ( feat) = feat. strip_prefix ( "-" ) {
187
+ features_disabled. insert ( feat) ;
188
+ if features_enabled. contains ( feat) {
189
+ panic ! ( "target feature `{feat}` is both enabled and disabled" ) ;
190
+ }
191
+ } else {
192
+ panic ! ( "target feature `{feat}` is invalid, must start with `+` or `-`" ) ;
193
+ }
194
+ }
195
+ }
173
196
}
174
197
175
198
// Add your target to the whitelist if it has `std` library
You can’t perform that action at this time.
0 commit comments