diff options
| author | Antoni Boucher <bouanto@zoho.com> | 2025-01-12 19:47:47 -0500 |
|---|---|---|
| committer | Antoni Boucher <bouanto@zoho.com> | 2025-01-12 19:47:47 -0500 |
| commit | b4418b896c163f935bf0f48e7c1fa62cd2a3baaf (patch) | |
| tree | 692636158b01cccd866ec3ee794389ad6f5769e1 | |
| parent | 59689c43f3e8ac79bd221d1b0617017547bf3bd2 (diff) | |
| download | rust-b4418b896c163f935bf0f48e7c1fa62cd2a3baaf.tar.gz rust-b4418b896c163f935bf0f48e7c1fa62cd2a3baaf.zip | |
Fix clippy warnings
| -rw-r--r-- | src/gcc_util.rs | 44 | ||||
| -rw-r--r-- | src/intrinsic/llvm.rs | 2 | ||||
| -rw-r--r-- | src/lib.rs | 6 |
3 files changed, 23 insertions, 29 deletions
diff --git a/src/gcc_util.rs b/src/gcc_util.rs index 1994a2a3c53..560aff43d65 100644 --- a/src/gcc_util.rs +++ b/src/gcc_util.rs @@ -66,16 +66,14 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri // We do the equivalent above in `target_features_cfg`. // See <https://github.com/rust-lang/rust/issues/134792>. all_rust_features.push((false, feature)); - } else if !feature.is_empty() { - if diagnostics { - sess.dcx().emit_warn(UnknownCTargetFeaturePrefix { feature }); - } + } else if !feature.is_empty() && diagnostics { + sess.dcx().emit_warn(UnknownCTargetFeaturePrefix { feature }); } } // Remove features that are meant for rustc, not codegen. - all_rust_features.retain(|(_, feature)| { + all_rust_features.retain(|&(_, feature)| { // Retain if it is not a rustc feature - !RUSTC_SPECIFIC_FEATURES.contains(feature) + !RUSTC_SPECIFIC_FEATURES.contains(&feature) }); // Check feature validity. @@ -103,7 +101,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri }; sess.dcx().emit_warn(unknown_feature); } - Some((_, stability, _)) => { + Some(&(_, stability, _)) => { if let Err(reason) = stability.toggle_allowed() { sess.dcx().emit_warn(ForbiddenCTargetFeature { feature, @@ -165,29 +163,25 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri ); // Translate this into GCC features. - let feats = all_rust_features - .iter() - .filter_map(|&(enable, feature)| { + let feats = + all_rust_features.iter().flat_map(|&(enable, feature)| { let enable_disable = if enable { '+' } else { '-' }; // We run through `to_gcc_features` when // passing requests down to GCC. This means that all in-language // features also work on the command line instead of having two // different names when the GCC name and the Rust name differ. - Some( - to_gcc_features(sess, feature) - .iter() - .flat_map(|feat| to_gcc_features(sess, feat).into_iter()) - .map(|feature| { - if enable_disable == '-' { - format!("-{}", feature) - } else { - feature.to_string() - } - }) - .collect::<Vec<_>>(), - ) - }) - .flatten(); + to_gcc_features(sess, feature) + .iter() + .flat_map(|feat| to_gcc_features(sess, feat).into_iter()) + .map(|feature| { + if enable_disable == '-' { + format!("-{}", feature) + } else { + feature.to_string() + } + }) + .collect::<Vec<_>>() + }); features.extend(feats); if diagnostics { diff --git a/src/intrinsic/llvm.rs b/src/intrinsic/llvm.rs index 0a448ded6b1..231307def29 100644 --- a/src/intrinsic/llvm.rs +++ b/src/intrinsic/llvm.rs @@ -421,7 +421,7 @@ pub fn adjust_intrinsic_arguments<'a, 'b, 'gcc, 'tcx>( | "__builtin_ia32_xsaveopt64" => { let new_args = args.to_vec(); let thirty_two = builder.context.new_rvalue_from_int(new_args[1].get_type(), 32); - let arg2 = new_args[1] << thirty_two | new_args[2]; + let arg2 = (new_args[1] << thirty_two) | new_args[2]; let arg2_type = gcc_func.get_param_type(1); let arg2 = builder.context.new_cast(None, arg2, arg2_type); args = vec![new_args[0], arg2].into(); diff --git a/src/lib.rs b/src/lib.rs index 1dfa598ea67..f6ad0c79de5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -494,10 +494,10 @@ fn target_features_cfg( sess.target .rust_target_features() .iter() - .filter(|(_, gate, _)| gate.in_cfg()) - .filter_map(|(feature, gate, _)| { + .filter(|&&(_, gate, _)| gate.in_cfg()) + .filter_map(|&(feature, gate, _)| { if sess.is_nightly_build() || allow_unstable || gate.requires_nightly().is_none() { - Some(*feature) + Some(feature) } else { None } |
