Skip to content

Commit a51ea93

Browse files
authored
Unrolled build for rust-lang#118889
Rollup merge of rust-lang#118889 - matthiaskrgr:compl_2023_2, r=WaffleLapkin more clippy::complexity fixes redundant_guards redundant_slicing filter_next needless_borrowed_reference useless_format
2 parents 77d1699 + 3795cc8 commit a51ea93

File tree

10 files changed

+18
-28
lines changed

10 files changed

+18
-28
lines changed

compiler/rustc_hir_typeck/src/coercion.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
17011701
&& !ty.is_never()
17021702
{
17031703
let indentation = if let None = block.expr
1704-
&& let [.., last] = &block.stmts[..]
1704+
&& let [.., last] = &block.stmts
17051705
{
17061706
tcx.sess.source_map().indentation_before(last.span).unwrap_or_else(String::new)
17071707
} else if let Some(expr) = block.expr {
@@ -1710,7 +1710,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
17101710
String::new()
17111711
};
17121712
if let None = block.expr
1713-
&& let [.., last] = &block.stmts[..]
1713+
&& let [.., last] = &block.stmts
17141714
{
17151715
err.span_suggestion_verbose(
17161716
last.span.shrink_to_hi(),
@@ -1750,7 +1750,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
17501750
}
17511751
}
17521752
if let None = block.expr
1753-
&& let [.., last] = &block.stmts[..]
1753+
&& let [.., last] = &block.stmts
17541754
{
17551755
sugg.push((last.span.shrink_to_hi(), format!("\n{indentation}None")));
17561756
} else if let Some(expr) = block.expr {

compiler/rustc_hir_typeck/src/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
862862
mutability,
863863
),
864864
),
865-
match &args[..] {
865+
match &args {
866866
[] => (base.span.shrink_to_hi().with_hi(deref.span.hi()), ")".to_string()),
867867
[first, ..] => (base.span.between(first.span), ", ".to_string()),
868868
},

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2452,7 +2452,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
24522452

24532453
if !suggs.is_empty() {
24542454
err.multipart_suggestion_verbose(
2455-
format!("{msg}"),
2455+
msg,
24562456
suggs,
24572457
Applicability::MaybeIncorrect, // Issue #41966
24582458
);

compiler/rustc_mir_build/src/thir/pattern/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
174174
span: Span,
175175
) -> Result<PatKind<'tcx>, ErrorGuaranteed> {
176176
if lo_expr.is_none() && hi_expr.is_none() {
177-
let msg = format!("found twice-open range pattern (`..`) outside of error recovery");
177+
let msg = "found twice-open range pattern (`..`) outside of error recovery";
178178
return Err(self.tcx.sess.span_delayed_bug(span, msg));
179179
}
180180

compiler/rustc_resolve/src/imports.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1063,12 +1063,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
10631063
initial_binding.res()
10641064
});
10651065
let res = binding.res();
1066-
let has_ambiguity_error = this
1067-
.ambiguity_errors
1068-
.iter()
1069-
.filter(|error| !error.warning)
1070-
.next()
1071-
.is_some();
1066+
let has_ambiguity_error =
1067+
this.ambiguity_errors.iter().any(|error| !error.warning);
10721068
if res == Res::Err || has_ambiguity_error {
10731069
this.tcx
10741070
.sess

compiler/rustc_resolve/src/late/diagnostics.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1829,13 +1829,12 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
18291829
)
18301830
.iter()
18311831
.filter_map(|candidate| candidate.did)
1832-
.filter(|did| {
1832+
.find(|did| {
18331833
self.r
18341834
.tcx
18351835
.get_attrs(*did, sym::rustc_diagnostic_item)
18361836
.any(|attr| attr.value_str() == Some(sym::Default))
1837-
})
1838-
.next();
1837+
});
18391838
let Some(default_trait) = default_trait else {
18401839
return;
18411840
};
@@ -1880,11 +1879,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
18801879
};
18811880

18821881
fields.is_some_and(|fields| {
1883-
fields
1884-
.iter()
1885-
.filter(|vis| !self.r.is_accessible_from(**vis, self.parent_scope.module))
1886-
.next()
1887-
.is_some()
1882+
fields.iter().any(|vis| !self.r.is_accessible_from(*vis, self.parent_scope.module))
18881883
})
18891884
}
18901885

compiler/rustc_smir/src/rustc_smir/convert/mir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ impl<'tcx> Stable<'tcx> for rustc_middle::mir::Const<'tcx> {
707707
let id = tables.intern_const(*self);
708708
Const::new(kind, ty, id)
709709
}
710-
mir::Const::Val(val, ty) if matches!(val, mir::ConstValue::ZeroSized) => {
710+
mir::Const::Val(mir::ConstValue::ZeroSized, ty) => {
711711
let ty = ty.stable(tables);
712712
let id = tables.intern_const(*self);
713713
Const::new(ConstantKind::ZeroSized, ty, id)

compiler/rustc_trait_selection/src/infer.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,10 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
101101
self.tcx.impl_trait_ref(impl_def_id).map(|r| (impl_def_id, r))
102102
})
103103
.map(|(impl_def_id, imp)| (impl_def_id, imp.skip_binder()))
104-
.filter(|(_, imp)| match imp.self_ty().peel_refs().kind() {
104+
.find(|(_, imp)| match imp.self_ty().peel_refs().kind() {
105105
ty::Adt(i_def, _) if i_def.did() == def.did() => true,
106106
_ => false,
107107
})
108-
.next()
109108
{
110109
let mut fulfill_cx = FulfillmentCtxt::new(self);
111110
// We get all obligations from the impl to talk about specific

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
21672167
})
21682168
.collect();
21692169
err.multipart_suggestion(
2170-
format!("consider wrapping the function in a closure"),
2170+
"consider wrapping the function in a closure",
21712171
vec![
21722172
(arg.span.shrink_to_lo(), format!("|{}| ", closure_names.join(", "))),
21732173
(arg.span.shrink_to_hi(), format!("({})", call_names.join(", "))),

src/librustdoc/clean/types.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2245,8 +2245,8 @@ impl GenericArgs {
22452245
}
22462246
pub(crate) fn bindings<'a>(&'a self) -> Box<dyn Iterator<Item = TypeBinding> + 'a> {
22472247
match self {
2248-
&GenericArgs::AngleBracketed { ref bindings, .. } => Box::new(bindings.iter().cloned()),
2249-
&GenericArgs::Parenthesized { ref output, .. } => Box::new(
2248+
GenericArgs::AngleBracketed { bindings, .. } => Box::new(bindings.iter().cloned()),
2249+
GenericArgs::Parenthesized { output, .. } => Box::new(
22502250
output
22512251
.as_ref()
22522252
.map(|ty| TypeBinding {
@@ -2270,8 +2270,8 @@ impl<'a> IntoIterator for &'a GenericArgs {
22702270
type Item = GenericArg;
22712271
fn into_iter(self) -> Self::IntoIter {
22722272
match self {
2273-
&GenericArgs::AngleBracketed { ref args, .. } => Box::new(args.iter().cloned()),
2274-
&GenericArgs::Parenthesized { ref inputs, .. } => {
2273+
GenericArgs::AngleBracketed { args, .. } => Box::new(args.iter().cloned()),
2274+
GenericArgs::Parenthesized { inputs, .. } => {
22752275
Box::new(inputs.iter().cloned().map(GenericArg::Type))
22762276
}
22772277
}

0 commit comments

Comments
 (0)