Skip to content

Commit b4418b8

Browse files
committed
Fix clippy warnings
1 parent 59689c4 commit b4418b8

File tree

3 files changed

+23
-29
lines changed

3 files changed

+23
-29
lines changed

Diff for: src/gcc_util.rs

+19-25
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,14 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
6666
// We do the equivalent above in `target_features_cfg`.
6767
// See <https://github.com/rust-lang/rust/issues/134792>.
6868
all_rust_features.push((false, feature));
69-
} else if !feature.is_empty() {
70-
if diagnostics {
71-
sess.dcx().emit_warn(UnknownCTargetFeaturePrefix { feature });
72-
}
69+
} else if !feature.is_empty() && diagnostics {
70+
sess.dcx().emit_warn(UnknownCTargetFeaturePrefix { feature });
7371
}
7472
}
7573
// Remove features that are meant for rustc, not codegen.
76-
all_rust_features.retain(|(_, feature)| {
74+
all_rust_features.retain(|&(_, feature)| {
7775
// Retain if it is not a rustc feature
78-
!RUSTC_SPECIFIC_FEATURES.contains(feature)
76+
!RUSTC_SPECIFIC_FEATURES.contains(&feature)
7977
});
8078

8179
// Check feature validity.
@@ -103,7 +101,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
103101
};
104102
sess.dcx().emit_warn(unknown_feature);
105103
}
106-
Some((_, stability, _)) => {
104+
Some(&(_, stability, _)) => {
107105
if let Err(reason) = stability.toggle_allowed() {
108106
sess.dcx().emit_warn(ForbiddenCTargetFeature {
109107
feature,
@@ -165,29 +163,25 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
165163
);
166164

167165
// Translate this into GCC features.
168-
let feats = all_rust_features
169-
.iter()
170-
.filter_map(|&(enable, feature)| {
166+
let feats =
167+
all_rust_features.iter().flat_map(|&(enable, feature)| {
171168
let enable_disable = if enable { '+' } else { '-' };
172169
// We run through `to_gcc_features` when
173170
// passing requests down to GCC. This means that all in-language
174171
// features also work on the command line instead of having two
175172
// different names when the GCC name and the Rust name differ.
176-
Some(
177-
to_gcc_features(sess, feature)
178-
.iter()
179-
.flat_map(|feat| to_gcc_features(sess, feat).into_iter())
180-
.map(|feature| {
181-
if enable_disable == '-' {
182-
format!("-{}", feature)
183-
} else {
184-
feature.to_string()
185-
}
186-
})
187-
.collect::<Vec<_>>(),
188-
)
189-
})
190-
.flatten();
173+
to_gcc_features(sess, feature)
174+
.iter()
175+
.flat_map(|feat| to_gcc_features(sess, feat).into_iter())
176+
.map(|feature| {
177+
if enable_disable == '-' {
178+
format!("-{}", feature)
179+
} else {
180+
feature.to_string()
181+
}
182+
})
183+
.collect::<Vec<_>>()
184+
});
191185
features.extend(feats);
192186

193187
if diagnostics {

Diff for: src/intrinsic/llvm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ pub fn adjust_intrinsic_arguments<'a, 'b, 'gcc, 'tcx>(
421421
| "__builtin_ia32_xsaveopt64" => {
422422
let new_args = args.to_vec();
423423
let thirty_two = builder.context.new_rvalue_from_int(new_args[1].get_type(), 32);
424-
let arg2 = new_args[1] << thirty_two | new_args[2];
424+
let arg2 = (new_args[1] << thirty_two) | new_args[2];
425425
let arg2_type = gcc_func.get_param_type(1);
426426
let arg2 = builder.context.new_cast(None, arg2, arg2_type);
427427
args = vec![new_args[0], arg2].into();

Diff for: src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,10 @@ fn target_features_cfg(
494494
sess.target
495495
.rust_target_features()
496496
.iter()
497-
.filter(|(_, gate, _)| gate.in_cfg())
498-
.filter_map(|(feature, gate, _)| {
497+
.filter(|&&(_, gate, _)| gate.in_cfg())
498+
.filter_map(|&(feature, gate, _)| {
499499
if sess.is_nightly_build() || allow_unstable || gate.requires_nightly().is_none() {
500-
Some(*feature)
500+
Some(feature)
501501
} else {
502502
None
503503
}

0 commit comments

Comments
 (0)