Skip to content

Commit 11cd4ff

Browse files
committed
Auto merge of #109852 - Nilstrieb:rollup-g3mgxxw, r=Nilstrieb
Rollup of 4 pull requests Successful merges: - #109839 (Improve grammar of Iterator.partition_in_place) - #109840 (Fix typo in std/src/os/fd/owned.rs) - #109844 (a couple clippy::complexity fixes) - #109846 (more clippy::complexity fixes (iter_kv_map, map_flatten, nonminimal_bool)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 637d7fd + 59f394b commit 11cd4ff

File tree

27 files changed

+44
-66
lines changed

27 files changed

+44
-66
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,8 +1190,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
11901190
// Set KCFI operand bundle
11911191
let is_indirect_call = unsafe { llvm::LLVMIsAFunction(llfn).is_none() };
11921192
let kcfi_bundle =
1193-
if self.tcx.sess.is_sanitizer_kcfi_enabled() && fn_abi.is_some() && is_indirect_call {
1194-
let kcfi_typeid = kcfi_typeid_for_fnabi(self.tcx, fn_abi.unwrap());
1193+
if let Some(fn_abi) = fn_abi && self.tcx.sess.is_sanitizer_kcfi_enabled() && is_indirect_call {
1194+
let kcfi_typeid = kcfi_typeid_for_fnabi(self.tcx, fn_abi);
11951195
Some(llvm::OperandBundleDef::new("kcfi", &[self.const_u32(kcfi_typeid)]))
11961196
} else {
11971197
None

compiler/rustc_codegen_llvm/src/common.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,7 @@ pub(crate) fn get_dllimport<'tcx>(
378378
name: &str,
379379
) -> Option<&'tcx DllImport> {
380380
tcx.native_library(id)
381-
.map(|lib| lib.dll_imports.iter().find(|di| di.name.as_str() == name))
382-
.flatten()
381+
.and_then(|lib| lib.dll_imports.iter().find(|di| di.name.as_str() == name))
383382
}
384383

385384
pub(crate) fn is_mingw_gnu_toolchain(target: &Target) -> bool {

compiler/rustc_const_eval/src/transform/validate.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
677677
);
678678
}
679679
if let Rvalue::CopyForDeref(place) = rvalue {
680-
if !place.ty(&self.body.local_decls, self.tcx).ty.builtin_deref(true).is_some()
681-
{
680+
if place.ty(&self.body.local_decls, self.tcx).ty.builtin_deref(true).is_none() {
682681
self.fail(
683682
location,
684683
"`CopyForDeref` should only be used for dereferenceable types",

compiler/rustc_errors/src/emitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2235,7 +2235,7 @@ impl EmitterWriter {
22352235
}
22362236
} else if is_multiline {
22372237
buffer.puts(*row_num, 0, &self.maybe_anonymized(line_num), Style::LineNumber);
2238-
match &highlight_parts[..] {
2238+
match &highlight_parts {
22392239
[SubstitutionHighlight { start: 0, end }] if *end == line_to_add.len() => {
22402240
buffer.puts(*row_num, max_line_num_len + 1, "+ ", Style::Addition);
22412241
}

compiler/rustc_hir_analysis/src/astconv/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
483483
[segment] if segment.args.is_none() => {
484484
trait_bound_spans = vec![segment.ident.span];
485485
associated_types = associated_types
486-
.into_iter()
487-
.map(|(_, items)| (segment.ident.span, items))
486+
.into_values()
487+
.map(|items| (segment.ident.span, items))
488488
.collect();
489489
}
490490
_ => {}

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
559559
// struct; however, when EUV is run during typeck, it
560560
// may not. This will generate an error earlier in typeck,
561561
// so we can just ignore it.
562-
if !self.tcx().sess.has_errors().is_some() {
562+
if self.tcx().sess.has_errors().is_none() {
563563
span_bug!(with_expr.span, "with expression doesn't evaluate to a struct");
564564
}
565565
}

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
978978
let (_, sig, reg) = ty::print::FmtPrinter::new(self.tcx, Namespace::TypeNS)
979979
.name_all_regions(sig)
980980
.unwrap();
981-
let lts: Vec<String> = reg.into_iter().map(|(_, kind)| kind.to_string()).collect();
981+
let lts: Vec<String> = reg.into_values().map(|kind| kind.to_string()).collect();
982982
(if lts.is_empty() { String::new() } else { format!("for<{}> ", lts.join(", ")) }, sig)
983983
};
984984

@@ -2399,10 +2399,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
23992399
let suggestion =
24002400
if has_lifetimes { format!(" + {}", sub) } else { format!(": {}", sub) };
24012401
let mut suggestions = vec![(sp, suggestion)];
2402-
for add_lt_sugg in add_lt_suggs {
2403-
if let Some(add_lt_sugg) = add_lt_sugg {
2404-
suggestions.push(add_lt_sugg);
2405-
}
2402+
for add_lt_sugg in add_lt_suggs.into_iter().flatten() {
2403+
suggestions.push(add_lt_sugg);
24062404
}
24072405
err.multipart_suggestion_verbose(
24082406
format!("{msg}..."),
@@ -2426,11 +2424,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
24262424
};
24272425
let mut sugg =
24282426
vec![(sp, suggestion), (span.shrink_to_hi(), format!(" + {}", new_lt))];
2429-
for add_lt_sugg in add_lt_suggs.clone() {
2430-
if let Some(lt) = add_lt_sugg {
2431-
sugg.push(lt);
2432-
sugg.rotate_right(1);
2433-
}
2427+
for lt in add_lt_suggs.clone().into_iter().flatten() {
2428+
sugg.push(lt);
2429+
sugg.rotate_right(1);
24342430
}
24352431
// `MaybeIncorrect` due to issue #41966.
24362432
err.multipart_suggestion(msg, sugg, Applicability::MaybeIncorrect);

compiler/rustc_middle/src/middle/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub mod lib_features {
1919
.stable
2020
.iter()
2121
.map(|(f, (s, _))| (*f, Some(*s)))
22-
.chain(self.unstable.iter().map(|(f, _)| (*f, None)))
22+
.chain(self.unstable.keys().map(|f| (*f, None)))
2323
.collect();
2424
all_features.sort_unstable_by(|a, b| a.0.as_str().partial_cmp(b.0.as_str()).unwrap());
2525
all_features

compiler/rustc_middle/src/ty/consts/valtree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'tcx> ValTree<'tcx> {
7979
}
8080

8181
pub fn try_to_target_usize(self, tcx: TyCtxt<'tcx>) -> Option<u64> {
82-
self.try_to_scalar_int().map(|s| s.try_to_target_usize(tcx).ok()).flatten()
82+
self.try_to_scalar_int().and_then(|s| s.try_to_target_usize(tcx).ok())
8383
}
8484

8585
/// Get the values inside the ValTree as a slice of bytes. This only works for

compiler/rustc_mir_build/src/build/expr/as_constant.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@ pub fn as_constant_inner<'tcx>(
6262
Constant { span, user_ty: None, literal }
6363
}
6464
ExprKind::NonHirLiteral { lit, ref user_ty } => {
65-
let user_ty = user_ty.as_ref().map(push_cuta).flatten();
65+
let user_ty = user_ty.as_ref().and_then(push_cuta);
6666

6767
let literal = ConstantKind::Val(ConstValue::Scalar(Scalar::Int(lit)), ty);
6868

6969
Constant { span, user_ty, literal }
7070
}
7171
ExprKind::ZstLiteral { ref user_ty } => {
72-
let user_ty = user_ty.as_ref().map(push_cuta).flatten();
72+
let user_ty = user_ty.as_ref().and_then(push_cuta);
7373

7474
let literal = ConstantKind::Val(ConstValue::ZeroSized, ty);
7575

7676
Constant { span, user_ty, literal }
7777
}
7878
ExprKind::NamedConst { def_id, substs, ref user_ty } => {
79-
let user_ty = user_ty.as_ref().map(push_cuta).flatten();
79+
let user_ty = user_ty.as_ref().and_then(push_cuta);
8080

8181
let uneval = mir::UnevaluatedConst::new(ty::WithOptConstParam::unknown(def_id), substs);
8282
let literal = ConstantKind::Unevaluated(uneval, ty);

0 commit comments

Comments
 (0)