Skip to content

Commit 4a5c717

Browse files
committed
Avoid double interning of feature names.
Also improve some comments.
1 parent b522e7c commit 4a5c717

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,11 @@ pub(crate) fn target_features_cfg(sess: &Session, allow_unstable: bool) -> Vec<S
311311
// We do *not* add the -Ctarget-features there, and instead duplicate the logic for that below.
312312
// The reason is that if LLVM considers a feature implied but we do not, we don't want that to
313313
// show up in `cfg`. That way, `cfg` is entirely under our control -- except for the handling of
314-
// the target CPU, that is still expanded to target features (with all their implied features) by
315-
// LLVM.
314+
// the target CPU, that is still expanded to target features (with all their implied features)
315+
// by LLVM.
316316
let target_machine = create_informational_target_machine(sess, true);
317-
// Compute which of the known target features are enabled in the 'base' target machine.
318-
// We only consider "supported" features; "forbidden" features are not reflected in `cfg` as of now.
317+
// Compute which of the known target features are enabled in the 'base' target machine. We only
318+
// consider "supported" features; "forbidden" features are not reflected in `cfg` as of now.
319319
features.extend(
320320
sess.target
321321
.rust_target_features()
@@ -341,7 +341,7 @@ pub(crate) fn target_features_cfg(sess: &Session, allow_unstable: bool) -> Vec<S
341341
.map(|(feature, _, _)| Symbol::intern(feature)),
342342
);
343343

344-
// Add enabled features
344+
// Add enabled and remove disabled features.
345345
for (enabled, feature) in
346346
sess.opts.cg.target_feature.split(',').filter_map(|s| match s.chars().next() {
347347
Some('+') => Some((true, Symbol::intern(&s[1..]))),
@@ -395,13 +395,12 @@ pub(crate) fn target_features_cfg(sess: &Session, allow_unstable: bool) -> Vec<S
395395
if allow_unstable
396396
|| (gate.in_cfg() && (sess.is_nightly_build() || gate.requires_nightly().is_none()))
397397
{
398-
Some(*feature)
398+
Some(Symbol::intern(feature))
399399
} else {
400400
None
401401
}
402402
})
403-
.filter(|feature| features.contains(&Symbol::intern(feature)))
404-
.map(|feature| Symbol::intern(feature))
403+
.filter(|feature| features.contains(&feature))
405404
.collect()
406405
}
407406

0 commit comments

Comments
 (0)