Skip to content

Commit 6d06429

Browse files
clippy::useless_conversion
1 parent 5a2dd7d commit 6d06429

File tree

13 files changed

+20
-28
lines changed

13 files changed

+20
-28
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3475,7 +3475,7 @@ impl From<ForeignItemKind> for ItemKind {
34753475
fn from(foreign_item_kind: ForeignItemKind) -> ItemKind {
34763476
match foreign_item_kind {
34773477
ForeignItemKind::Static(box static_foreign_item) => {
3478-
ItemKind::Static(Box::new(static_foreign_item.into()))
3478+
ItemKind::Static(Box::new(static_foreign_item))
34793479
}
34803480
ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind),
34813481
ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
@@ -3489,9 +3489,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
34893489

34903490
fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
34913491
Ok(match item_kind {
3492-
ItemKind::Static(box static_item) => {
3493-
ForeignItemKind::Static(Box::new(static_item.into()))
3494-
}
3492+
ItemKind::Static(box static_item) => ForeignItemKind::Static(Box::new(static_item)),
34953493
ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind),
34963494
ItemKind::TyAlias(ty_alias_kind) => ForeignItemKind::TyAlias(ty_alias_kind),
34973495
ItemKind::MacCall(a) => ForeignItemKind::MacCall(a),

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,7 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
7575

7676
// This can't use `init_stack_frame` since `body` is not a function,
7777
// so computing its ABI would fail. It's also not worth it since there are no arguments to pass.
78-
ecx.push_stack_frame_raw(
79-
cid.instance,
80-
body,
81-
&ret.clone().into(),
82-
StackPopCleanup::Root { cleanup: false },
83-
)?;
78+
ecx.push_stack_frame_raw(cid.instance, body, &ret, StackPopCleanup::Root { cleanup: false })?;
8479
ecx.storage_live_for_always_live_locals()?;
8580

8681
// The main interpreter loop.

compiler/rustc_const_eval/src/interpret/call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
823823
(Abi::Rust, fn_abi),
824824
&[FnArg::Copy(arg.into())],
825825
false,
826-
&ret.into(),
826+
&ret,
827827
Some(target),
828828
unwind,
829829
)

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,10 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
681681
" ".repeat(expected_padding),
682682
expected_label
683683
))];
684-
msg.extend(expected.0.into_iter());
684+
msg.extend(expected.0);
685685
msg.push(StringPart::normal(format!("`{expected_extra}\n")));
686686
msg.push(StringPart::normal(format!("{}{} `", " ".repeat(found_padding), found_label)));
687-
msg.extend(found.0.into_iter());
687+
msg.extend(found.0);
688688
msg.push(StringPart::normal(format!("`{found_extra}")));
689689

690690
// For now, just attach these as notes.

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ fn check_fn_or_method<'tcx>(
16021602
function: def_id,
16031603
// Note that the `param_idx` of the output type is
16041604
// one greater than the index of the last input type.
1605-
param_idx: idx.try_into().unwrap(),
1605+
param_idx: idx,
16061606
}),
16071607
ty,
16081608
)
@@ -1611,7 +1611,7 @@ fn check_fn_or_method<'tcx>(
16111611
for (idx, ty) in sig.inputs_and_output.iter().enumerate() {
16121612
wfcx.register_wf_obligation(
16131613
arg_span(idx),
1614-
Some(WellFormedLoc::Param { function: def_id, param_idx: idx.try_into().unwrap() }),
1614+
Some(WellFormedLoc::Param { function: def_id, param_idx: idx }),
16151615
ty.into(),
16161616
);
16171617
}

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2565,7 +2565,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25652565
other_generic_param.name.ident() == generic_param.name.ident()
25662566
},
25672567
) {
2568-
idxs_matched.push(other_idx.into());
2568+
idxs_matched.push(other_idx);
25692569
}
25702570

25712571
if idxs_matched.is_empty() {

compiler/rustc_middle/src/ty/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ impl<'tcx> Const<'tcx> {
396396
Ok((tcx.type_of(unevaluated.def).instantiate(tcx, unevaluated.args), c))
397397
}
398398
Ok(Err(bad_ty)) => Err(Either::Left(bad_ty)),
399-
Err(err) => Err(Either::Right(err.into())),
399+
Err(err) => Err(Either::Right(err)),
400400
}
401401
}
402402
ConstKind::Value(ty, val) => Ok((ty, val)),

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
15261526

15271527
let precedence = |binop: rustc_middle::mir::BinOp| {
15281528
use rustc_ast::util::parser::AssocOp;
1529-
AssocOp::from_ast_binop(binop.to_hir_binop().into()).precedence()
1529+
AssocOp::from_ast_binop(binop.to_hir_binop()).precedence()
15301530
};
15311531
let op_precedence = precedence(op);
15321532
let formatted_op = op.to_hir_binop().as_str();

compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,6 @@ where
883883
.into_iter()
884884
.chain(a_data.principal_def_id().into_iter().flat_map(|principal_def_id| {
885885
elaborate::supertrait_def_ids(self.cx(), principal_def_id)
886-
.into_iter()
887886
.filter(|def_id| self.cx().trait_is_auto(*def_id))
888887
}))
889888
.collect();

compiler/rustc_parse/src/parser/attr_wrapper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl<'a> Parser<'a> {
383383
self.capture_state
384384
.parser_replacements
385385
.drain(parser_replacements_start..parser_replacements_end)
386-
.chain(inner_attr_parser_replacements.into_iter())
386+
.chain(inner_attr_parser_replacements)
387387
.map(|(parser_range, data)| {
388388
(NodeRange::new(parser_range, collect_pos.start_pos), data)
389389
})

0 commit comments

Comments
 (0)