Skip to content

Commit 3f2febd

Browse files
committed
Avoid double interning of feature names.
Also improve some comments.
1 parent f5729cf commit 3f2febd

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
@@ -313,11 +313,11 @@ pub(crate) fn target_features_cfg(sess: &Session, allow_unstable: bool) -> Vec<S
313313
// We do *not* add the -Ctarget-features there, and instead duplicate the logic for that below.
314314
// The reason is that if LLVM considers a feature implied but we do not, we don't want that to
315315
// show up in `cfg`. That way, `cfg` is entirely under our control -- except for the handling of
316-
// the target CPU, that is still expanded to target features (with all their implied features) by
317-
// LLVM.
316+
// the target CPU, that is still expanded to target features (with all their implied features)
317+
// by LLVM.
318318
let target_machine = create_informational_target_machine(sess, true);
319-
// Compute which of the known target features are enabled in the 'base' target machine.
320-
// We only consider "supported" features; "forbidden" features are not reflected in `cfg` as of now.
319+
// Compute which of the known target features are enabled in the 'base' target machine. We only
320+
// consider "supported" features; "forbidden" features are not reflected in `cfg` as of now.
321321
features.extend(
322322
sess.target
323323
.rust_target_features()
@@ -343,7 +343,7 @@ pub(crate) fn target_features_cfg(sess: &Session, allow_unstable: bool) -> Vec<S
343343
.map(|(feature, _, _)| Symbol::intern(feature)),
344344
);
345345

346-
// Add enabled features
346+
// Add enabled and remove disabled features.
347347
for (enabled, feature) in
348348
sess.opts.cg.target_feature.split(',').filter_map(|s| match s.chars().next() {
349349
Some('+') => Some((true, Symbol::intern(&s[1..]))),
@@ -397,13 +397,12 @@ pub(crate) fn target_features_cfg(sess: &Session, allow_unstable: bool) -> Vec<S
397397
if allow_unstable
398398
|| (gate.in_cfg() && (sess.is_nightly_build() || gate.requires_nightly().is_none()))
399399
{
400-
Some(*feature)
400+
Some(Symbol::intern(feature))
401401
} else {
402402
None
403403
}
404404
})
405-
.filter(|feature| features.contains(&Symbol::intern(feature)))
406-
.map(|feature| Symbol::intern(feature))
405+
.filter(|feature| features.contains(&feature))
407406
.collect()
408407
}
409408

0 commit comments

Comments
 (0)