Skip to content

Commit 1df93fd

Browse files
committed
Avoid double interning of feature names.
Also improve some comments.
1 parent f9e0239 commit 1df93fd

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+7-8
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()
@@ -344,7 +344,7 @@ pub(crate) fn target_features_cfg(sess: &Session, allow_unstable: bool) -> Vec<S
344344
.map(|(feature, _, _)| Symbol::intern(feature)),
345345
);
346346

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

0 commit comments

Comments
 (0)