Skip to content

Commit 7c2d57e

Browse files
committed
couple of clippy::complexity fixes
1 parent 0d13f6a commit 7c2d57e

File tree

16 files changed

+25
-29
lines changed

16 files changed

+25
-29
lines changed

compiler/rustc_errors/src/diagnostic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ impl Diagnostic {
832832
name: impl Into<Cow<'static, str>>,
833833
arg: DiagnosticArgValue<'static>,
834834
) -> &mut Self {
835-
self.args.push((name.into(), arg.into()));
835+
self.args.push((name.into(), arg));
836836
self
837837
}
838838

compiler/rustc_expand/src/mbe/macro_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ fn check_binders(
270270
MISSING_FRAGMENT_SPECIFIER,
271271
span,
272272
node_id,
273-
&format!("missing fragment specifier"),
273+
"missing fragment specifier",
274274
);
275275
}
276276
if !macros.is_empty() {

compiler/rustc_infer/src/infer/at.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
6363
/// common state. Used in coherence.
6464
pub fn fork(&self) -> Self {
6565
Self {
66-
tcx: self.tcx.clone(),
67-
defining_use_anchor: self.defining_use_anchor.clone(),
68-
in_progress_typeck_results: self.in_progress_typeck_results.clone(),
66+
tcx: self.tcx,
67+
defining_use_anchor: self.defining_use_anchor,
68+
in_progress_typeck_results: self.in_progress_typeck_results,
6969
inner: self.inner.clone(),
7070
skip_leak_check: self.skip_leak_check.clone(),
7171
lexical_region_resolutions: self.lexical_region_resolutions.clone(),

compiler/rustc_macros/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn symbols(input: TokenStream) -> TokenStream {
4444
#[proc_macro]
4545
#[allow_internal_unstable(step_trait, rustc_attrs, trusted_step)]
4646
pub fn newtype_index(input: TokenStream) -> TokenStream {
47-
newtype::newtype(input).into()
47+
newtype::newtype(input)
4848
}
4949

5050
decl_derive!([HashStable, attributes(stable_hasher)] => hash_stable::hash_stable_derive);

compiler/rustc_middle/src/ty/inhabitedness/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl<'tcx> Ty<'tcx> {
191191
tcx: TyCtxt<'tcx>,
192192
param_env: ty::ParamEnv<'tcx>,
193193
) -> DefIdForest<'tcx> {
194-
tcx.type_uninhabited_from(param_env.and(self)).clone()
194+
tcx.type_uninhabited_from(param_env.and(self))
195195
}
196196
}
197197

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
3939
}
4040
};
4141

42-
Constant { span, user_ty: None, literal: literal.into() }
42+
Constant { span, user_ty: None, literal }
4343
}
4444
ExprKind::NonHirLiteral { lit, user_ty } => {
4545
let user_ty = user_ty.map(|user_ty| {

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
423423
}
424424
thir::InlineAsmOperand::Const { value, span } => {
425425
mir::InlineAsmOperand::Const {
426-
value: Box::new(Constant {
427-
span,
428-
user_ty: None,
429-
literal: value.into(),
430-
}),
426+
value: Box::new(Constant { span, user_ty: None, literal: value }),
431427
}
432428
}
433429
thir::InlineAsmOperand::SymFn { expr } => mir::InlineAsmOperand::SymFn {

compiler/rustc_mir_build/src/build/matches/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
441441
// Need to experiment.
442442
user_ty: None,
443443

444-
literal: method.into(),
444+
literal: method,
445445
})),
446446
args: vec![val, expect],
447447
destination: Some((eq_result, eq_block)),

compiler/rustc_mir_transform/src/check_unsafety.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -539,13 +539,13 @@ fn report_unused_unsafe(tcx: TyCtxt<'_>, kind: UnusedUnsafe, id: HirId) {
539539
UnusedUnsafe::InUnsafeBlock(id) => {
540540
db.span_label(
541541
tcx.sess.source_map().guess_head_span(tcx.hir().span(id)),
542-
format!("because it's nested under this `unsafe` block"),
542+
"because it's nested under this `unsafe` block",
543543
);
544544
}
545545
UnusedUnsafe::InUnsafeFn(id, usage_lint_root) => {
546546
db.span_label(
547547
tcx.sess.source_map().guess_head_span(tcx.hir().span(id)),
548-
format!("because it's nested under this `unsafe` fn"),
548+
"because it's nested under this `unsafe` fn",
549549
)
550550
.note(
551551
"this `unsafe` block does contain unsafe operations, \

compiler/rustc_parse/src/lexer/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,13 @@ impl<'a> StringReader<'a> {
234234
rustc_lexer::TokenKind::InvalidIdent
235235
// Do not recover an identifier with emoji if the codepoint is a confusable
236236
// with a recoverable substitution token, like `➖`.
237-
if UNICODE_ARRAY
237+
if !UNICODE_ARRAY
238238
.iter()
239-
.find(|&&(c, _, _)| {
239+
.any(|&(c, _, _)| {
240240
let sym = self.str_from(start);
241241
sym.chars().count() == 1 && c == sym.chars().next().unwrap()
242242
})
243-
.is_none() =>
243+
=>
244244
{
245245
let sym = nfc_normalize(self.str_from(start));
246246
let span = self.mk_sp(start, self.pos);

compiler/rustc_passes/src/stability.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
133133
}
134134

135135
// `Deprecation` is just two pointers, no need to intern it
136-
let depr_entry = DeprecationEntry::local(depr.clone(), def_id);
136+
let depr_entry = DeprecationEntry::local(*depr, def_id);
137137
self.index.depr_map.insert(def_id, depr_entry);
138-
} else if let Some(parent_depr) = self.parent_depr.clone() {
138+
} else if let Some(parent_depr) = self.parent_depr {
139139
if inherit_deprecation.yes() {
140140
is_deprecated = true;
141141
info!("tagging child {:?} as deprecated from parent", def_id);

compiler/rustc_session/src/session.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl Session {
238238
}
239239
diag.emit();
240240
// If we should err, make sure we did.
241-
if must_err && !self.has_errors().is_some() {
241+
if must_err && self.has_errors().is_none() {
242242
// We have skipped a feature gate, and not run into other errors... reject.
243243
self.err(
244244
"`-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature \

compiler/rustc_target/src/abi/call/sparc64.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ where
113113
data = arg_scalar(cx, &scalar, offset, data);
114114
}
115115
abi::Abi::Aggregate { .. } => {
116-
for i in 0..layout.fields.count().clone() {
116+
for i in 0..layout.fields.count() {
117117
if offset < layout.fields.offset(i) {
118118
offset = layout.fields.offset(i);
119119
}
120-
data = parse_structure(cx, layout.field(cx, i).clone(), data.clone(), offset);
120+
data = parse_structure(cx, layout.field(cx, i), data.clone(), offset);
121121
}
122122
}
123123
_ => {
@@ -161,7 +161,7 @@ where
161161

162162
let mut data = parse_structure(
163163
cx,
164-
arg.layout.clone(),
164+
arg.layout,
165165
Sdata {
166166
prefix: [None; 8],
167167
prefix_index: 0,

compiler/rustc_trait_selection/src/traits/on_unimplemented.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl<'tcx> OnUnimplementedDirective {
258258
enclosing_scope = Some(enclosing_scope_.clone());
259259
}
260260

261-
append_const_msg = command.append_const_msg.clone();
261+
append_const_msg = command.append_const_msg;
262262
}
263263

264264
OnUnimplementedNote {

compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
415415
.get_if_local(def_id)
416416
.and_then(|node| node.body_id())
417417
.into_iter()
418-
.map(|id| tcx.hir().body(id).params)
419-
.flatten();
418+
.flat_map(|id| tcx.hir().body(id).params)
419+
;
420420

421421
for param in params {
422422
spans.push_span_label(param.span, String::new());

compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
646646

647647
// now get all predicates in the same types as the where bounds, so we can chain them
648648
let predicates_from_where =
649-
where_predicates.iter().flatten().map(|bounds| bounds.iter()).flatten();
649+
where_predicates.iter().flatten().flat_map(|bounds| bounds.iter());
650650

651651
// extract all bounds from the source code using their spans
652652
let all_matching_bounds_strs = expected_generic_param

0 commit comments

Comments
 (0)