Skip to content

Commit

Permalink
couple of clippy::complexity fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Apr 13, 2022
1 parent 0d13f6a commit 7c2d57e
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ impl Diagnostic {
name: impl Into<Cow<'static, str>>,
arg: DiagnosticArgValue<'static>,
) -> &mut Self {
self.args.push((name.into(), arg.into()));
self.args.push((name.into(), arg));
self
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/mbe/macro_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ fn check_binders(
MISSING_FRAGMENT_SPECIFIER,
span,
node_id,
&format!("missing fragment specifier"),
"missing fragment specifier",
);
}
if !macros.is_empty() {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_infer/src/infer/at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
/// common state. Used in coherence.
pub fn fork(&self) -> Self {
Self {
tcx: self.tcx.clone(),
defining_use_anchor: self.defining_use_anchor.clone(),
in_progress_typeck_results: self.in_progress_typeck_results.clone(),
tcx: self.tcx,
defining_use_anchor: self.defining_use_anchor,
in_progress_typeck_results: self.in_progress_typeck_results,
inner: self.inner.clone(),
skip_leak_check: self.skip_leak_check.clone(),
lexical_region_resolutions: self.lexical_region_resolutions.clone(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn symbols(input: TokenStream) -> TokenStream {
#[proc_macro]
#[allow_internal_unstable(step_trait, rustc_attrs, trusted_step)]
pub fn newtype_index(input: TokenStream) -> TokenStream {
newtype::newtype(input).into()
newtype::newtype(input)
}

decl_derive!([HashStable, attributes(stable_hasher)] => hash_stable::hash_stable_derive);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/inhabitedness/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<'tcx> Ty<'tcx> {
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
) -> DefIdForest<'tcx> {
tcx.type_uninhabited_from(param_env.and(self)).clone()
tcx.type_uninhabited_from(param_env.and(self))
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/build/expr/as_constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
};

Constant { span, user_ty: None, literal: literal.into() }
Constant { span, user_ty: None, literal }
}
ExprKind::NonHirLiteral { lit, user_ty } => {
let user_ty = user_ty.map(|user_ty| {
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_mir_build/src/build/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
thir::InlineAsmOperand::Const { value, span } => {
mir::InlineAsmOperand::Const {
value: Box::new(Constant {
span,
user_ty: None,
literal: value.into(),
}),
value: Box::new(Constant { span, user_ty: None, literal: value }),
}
}
thir::InlineAsmOperand::SymFn { expr } => mir::InlineAsmOperand::SymFn {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/build/matches/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Need to experiment.
user_ty: None,

literal: method.into(),
literal: method,
})),
args: vec![val, expect],
destination: Some((eq_result, eq_block)),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_transform/src/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,13 @@ fn report_unused_unsafe(tcx: TyCtxt<'_>, kind: UnusedUnsafe, id: HirId) {
UnusedUnsafe::InUnsafeBlock(id) => {
db.span_label(
tcx.sess.source_map().guess_head_span(tcx.hir().span(id)),
format!("because it's nested under this `unsafe` block"),
"because it's nested under this `unsafe` block",
);
}
UnusedUnsafe::InUnsafeFn(id, usage_lint_root) => {
db.span_label(
tcx.sess.source_map().guess_head_span(tcx.hir().span(id)),
format!("because it's nested under this `unsafe` fn"),
"because it's nested under this `unsafe` fn",
)
.note(
"this `unsafe` block does contain unsafe operations, \
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_parse/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ impl<'a> StringReader<'a> {
rustc_lexer::TokenKind::InvalidIdent
// Do not recover an identifier with emoji if the codepoint is a confusable
// with a recoverable substitution token, like `➖`.
if UNICODE_ARRAY
if !UNICODE_ARRAY
.iter()
.find(|&&(c, _, _)| {
.any(|&(c, _, _)| {
let sym = self.str_from(start);
sym.chars().count() == 1 && c == sym.chars().next().unwrap()
})
.is_none() =>
=>
{
let sym = nfc_normalize(self.str_from(start));
let span = self.mk_sp(start, self.pos);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
}

// `Deprecation` is just two pointers, no need to intern it
let depr_entry = DeprecationEntry::local(depr.clone(), def_id);
let depr_entry = DeprecationEntry::local(*depr, def_id);
self.index.depr_map.insert(def_id, depr_entry);
} else if let Some(parent_depr) = self.parent_depr.clone() {
} else if let Some(parent_depr) = self.parent_depr {
if inherit_deprecation.yes() {
is_deprecated = true;
info!("tagging child {:?} as deprecated from parent", def_id);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl Session {
}
diag.emit();
// If we should err, make sure we did.
if must_err && !self.has_errors().is_some() {
if must_err && self.has_errors().is_none() {
// We have skipped a feature gate, and not run into other errors... reject.
self.err(
"`-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature \
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_target/src/abi/call/sparc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ where
data = arg_scalar(cx, &scalar, offset, data);
}
abi::Abi::Aggregate { .. } => {
for i in 0..layout.fields.count().clone() {
for i in 0..layout.fields.count() {
if offset < layout.fields.offset(i) {
offset = layout.fields.offset(i);
}
data = parse_structure(cx, layout.field(cx, i).clone(), data.clone(), offset);
data = parse_structure(cx, layout.field(cx, i), data.clone(), offset);
}
}
_ => {
Expand Down Expand Up @@ -161,7 +161,7 @@ where

let mut data = parse_structure(
cx,
arg.layout.clone(),
arg.layout,
Sdata {
prefix: [None; 8],
prefix_index: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl<'tcx> OnUnimplementedDirective {
enclosing_scope = Some(enclosing_scope_.clone());
}

append_const_msg = command.append_const_msg.clone();
append_const_msg = command.append_const_msg;
}

OnUnimplementedNote {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.get_if_local(def_id)
.and_then(|node| node.body_id())
.into_iter()
.map(|id| tcx.hir().body(id).params)
.flatten();
.flat_map(|id| tcx.hir().body(id).params)
;

for param in params {
spans.push_span_label(param.span, String::new());
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

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

// extract all bounds from the source code using their spans
let all_matching_bounds_strs = expected_generic_param
Expand Down

0 comments on commit 7c2d57e

Please sign in to comment.