Skip to content

Commit aadd618

Browse files
committed
Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisa
more clippy::complexity fixes (also a couple of clippy::perf fixes)
2 parents f381e77 + 3fd8cbb commit aadd618

File tree

32 files changed

+44
-51
lines changed

32 files changed

+44
-51
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,8 +2189,7 @@ impl<'a> State<'a> {
21892189
Options(InlineAsmOptions),
21902190
}
21912191

2192-
let mut args = vec![];
2193-
args.push(AsmArg::Template(InlineAsmTemplatePiece::to_string(&asm.template)));
2192+
let mut args = vec![AsmArg::Template(InlineAsmTemplatePiece::to_string(&asm.template))];
21942193
args.extend(asm.operands.iter().map(|(o, _)| AsmArg::Operand(o)));
21952194
if !asm.options.is_empty() {
21962195
args.push(AsmArg::Options(asm.options));

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ pub fn llvm_global_features(sess: &Session) -> Vec<String> {
365365

366366
features_string
367367
};
368-
features.extend(features_string.split(",").map(String::from));
368+
features.extend(features_string.split(',').map(String::from));
369369
}
370370
Some(_) | None => {}
371371
};
@@ -374,7 +374,7 @@ pub fn llvm_global_features(sess: &Session) -> Vec<String> {
374374
if s.is_empty() {
375375
return None;
376376
}
377-
let feature = if s.starts_with("+") || s.starts_with("-") {
377+
let feature = if s.starts_with('+') || s.starts_with('-') {
378378
&s[1..]
379379
} else {
380380
return Some(s.to_string());

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ fn ident_name_compatibility_hack(
834834
.flat_map(|c| c.as_os_str().to_str())
835835
.find(|c| c.starts_with("js-sys"))
836836
{
837-
let mut version = c.trim_start_matches("js-sys-").split(".");
837+
let mut version = c.trim_start_matches("js-sys-").split('.');
838838
if version.next() == Some("0")
839839
&& version.next() == Some("3")
840840
&& version

compiler/rustc_hir/src/def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ impl<T> PerNS<Option<T>> {
476476

477477
/// Returns an iterator over the items which are `Some`.
478478
pub fn present_items(self) -> impl Iterator<Item = T> {
479-
IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).filter_map(|it| it)
479+
IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).flatten()
480480
}
481481
}
482482

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,8 +1357,8 @@ impl<'a> State<'a> {
13571357
Options(ast::InlineAsmOptions),
13581358
}
13591359

1360-
let mut args = vec![];
1361-
args.push(AsmArg::Template(ast::InlineAsmTemplatePiece::to_string(&asm.template)));
1360+
let mut args =
1361+
vec![AsmArg::Template(ast::InlineAsmTemplatePiece::to_string(&asm.template))];
13621362
args.extend(asm.operands.iter().map(|(o, _)| AsmArg::Operand(o)));
13631363
if !asm.options.is_empty() {
13641364
args.push(AsmArg::Options(asm.options));

compiler/rustc_lint/src/levels.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ pub fn is_known_lint_tool(m_item: Symbol, sess: &Session, attrs: &[ast::Attribut
576576
// NOTE: does no error handling; error handling is done by rustc_resolve.
577577
sess.filter_by_name(attrs, sym::register_tool)
578578
.filter_map(|attr| attr.meta_item_list())
579-
.flat_map(std::convert::identity)
579+
.flatten()
580580
.filter_map(|nested_meta| nested_meta.ident())
581581
.map(|ident| ident.name)
582582
.any(|name| name == m_item)

compiler/rustc_lint/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
906906
} else {
907907
return FfiUnsafe {
908908
ty,
909-
reason: format!("box cannot be represented as a single pointer"),
909+
reason: "box cannot be represented as a single pointer".to_string(),
910910
help: None,
911911
};
912912
}

compiler/rustc_macros/src/symbols.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
135135
let mut check_dup = |span: Span, str: &str, errors: &mut Errors| {
136136
if let Some(prev_span) = keys.get(str) {
137137
errors.error(span, format!("Symbol `{}` is duplicated", str));
138-
errors.error(*prev_span, format!("location of previous definition"));
138+
errors.error(*prev_span, "location of previous definition".to_string());
139139
} else {
140140
keys.insert(str.to_string(), span);
141141
}

compiler/rustc_middle/src/ty/codec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [mir::abstract_const::N
385385
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::List<ty::BoundVariableKind> {
386386
fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
387387
let len = decoder.read_usize()?;
388-
Ok(decoder.tcx().mk_bound_variable_kinds((0..len).map(|_| Decodable::decode(decoder)))?)
388+
decoder.tcx().mk_bound_variable_kinds((0..len).map(|_| Decodable::decode(decoder)))
389389
}
390390
}
391391

compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
320320
.map(|n| format!("`{}`", n))
321321
.unwrap_or_else(|| "the mutable reference".to_string()),
322322
),
323-
format!("&mut *"),
323+
"&mut *".to_string(),
324324
Applicability::MachineApplicable,
325325
);
326326
}

0 commit comments

Comments
 (0)