Skip to content

Commit 02b96b3

Browse files
authored
Rollup merge of #69529 - matthiaskrgr:clippy_identity_conversion, r=Mark-Simulacrum
don't use .into() to convert types into identical types. This removes redundant `.into()` calls. example: `let s: String = format!("hello").into();`
2 parents 4c9e44f + 7be94a8 commit 02b96b3

File tree

32 files changed

+42
-62
lines changed

32 files changed

+42
-62
lines changed

src/librustc/mir/interpret/allocation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
472472
val: ScalarMaybeUndef<Tag>,
473473
) -> InterpResult<'tcx> {
474474
let ptr_size = cx.data_layout().pointer_size;
475-
self.write_scalar(cx, ptr.into(), val, ptr_size)
475+
self.write_scalar(cx, ptr, val, ptr_size)
476476
}
477477
}
478478

src/librustc/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ impl<'tcx> TerminatorKind<'tcx> {
15191519
values
15201520
.iter()
15211521
.map(|&u| {
1522-
ty::Const::from_scalar(tcx, Scalar::from_uint(u, size).into(), switch_ty)
1522+
ty::Const::from_scalar(tcx, Scalar::from_uint(u, size), switch_ty)
15231523
.to_string()
15241524
.into()
15251525
})

src/librustc/mir/tcx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl<'tcx> Rvalue<'tcx> {
156156
}
157157
Rvalue::AddressOf(mutability, ref place) => {
158158
let place_ty = place.ty(local_decls, tcx).ty;
159-
tcx.mk_ptr(ty::TypeAndMut { ty: place_ty, mutbl: mutability.into() })
159+
tcx.mk_ptr(ty::TypeAndMut { ty: place_ty, mutbl: mutability })
160160
}
161161
Rvalue::Len(..) => tcx.types.usize,
162162
Rvalue::Cast(.., ty) => ty,

src/librustc/traits/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,7 @@ impl ObjectSafetyViolation {
820820
MethodViolationCode::UndispatchableReceiver,
821821
span,
822822
) => (
823-
format!("consider changing method `{}`'s `self` parameter to be `&self`", name)
824-
.into(),
823+
format!("consider changing method `{}`'s `self` parameter to be `&self`", name),
825824
Some(("&Self".to_string(), span)),
826825
),
827826
ObjectSafetyViolation::AssocConst(name, _)

src/librustc_ast_lowering/expr.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
831831
.last()
832832
.cloned()
833833
.map(|id| Ok(self.lower_node_id(id)))
834-
.unwrap_or(Err(hir::LoopIdError::OutsideLoopScope))
835-
.into(),
834+
.unwrap_or(Err(hir::LoopIdError::OutsideLoopScope)),
836835
};
837836
hir::Destination { label: destination.map(|(_, label)| label), target_id }
838837
}
@@ -841,7 +840,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
841840
if self.is_in_loop_condition && opt_label.is_none() {
842841
hir::Destination {
843842
label: None,
844-
target_id: Err(hir::LoopIdError::UnlabeledCfInWhileCondition).into(),
843+
target_id: Err(hir::LoopIdError::UnlabeledCfInWhileCondition),
845844
}
846845
} else {
847846
self.lower_loop_destination(opt_label.map(|label| (id, label)))
@@ -912,7 +911,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
912911
.collect(),
913912
asm: asm.asm,
914913
asm_str_style: asm.asm_str_style,
915-
clobbers: asm.clobbers.clone().into(),
914+
clobbers: asm.clobbers.clone(),
916915
volatile: asm.volatile,
917916
alignstack: asm.alignstack,
918917
dialect: asm.dialect,

src/librustc_codegen_ssa/mir/operand.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
9292
let a = Scalar::from(Pointer::new(
9393
bx.tcx().alloc_map.lock().create_memory_alloc(data),
9494
Size::from_bytes(start as u64),
95-
))
96-
.into();
95+
));
9796
let a_llval = bx.scalar_to_backend(
9897
a,
9998
a_scalar,

src/librustc_codegen_ssa/mir/rvalue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
387387

388388
mir::Rvalue::AddressOf(mutability, ref place) => {
389389
let mk_ptr = move |tcx: TyCtxt<'tcx>, ty: Ty<'tcx>| {
390-
tcx.mk_ptr(ty::TypeAndMut { ty, mutbl: mutability.into() })
390+
tcx.mk_ptr(ty::TypeAndMut { ty, mutbl: mutability })
391391
};
392392
self.codegen_place_to_pointer(bx, place, mk_ptr)
393393
}

src/librustc_expand/mbe/quoted.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn parse_tree(
112112
sess.span_diagnostic.span_err(span.entire(), &msg);
113113
}
114114
// Parse the contents of the sequence itself
115-
let sequence = parse(tts.into(), expect_matchers, sess);
115+
let sequence = parse(tts, expect_matchers, sess);
116116
// Get the Kleene operator and optional separator
117117
let (separator, kleene) = parse_sep_and_kleene_op(trees, span.entire(), sess);
118118
// Count the number of captured "names" (i.e., named metavars)
@@ -159,7 +159,7 @@ fn parse_tree(
159159
// descend into the delimited set and further parse it.
160160
tokenstream::TokenTree::Delimited(span, delim, tts) => TokenTree::Delimited(
161161
span,
162-
Lrc::new(Delimited { delim, tts: parse(tts.into(), expect_matchers, sess) }),
162+
Lrc::new(Delimited { delim, tts: parse(tts, expect_matchers, sess) }),
163163
),
164164
}
165165
}

src/librustc_expand/mbe/transcribe.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ pub(super) fn transcribe(
155155
}
156156

157157
// Step back into the parent Delimited.
158-
let tree =
159-
TokenTree::Delimited(span, forest.delim, TokenStream::new(result).into());
158+
let tree = TokenTree::Delimited(span, forest.delim, TokenStream::new(result));
160159
result = result_stack.pop().unwrap();
161160
result.push(tree.into());
162161
}

src/librustc_expand/proc_macro_server.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl FromInternal<(TreeAndJoint, &'_ ParseSess, &'_ mut Vec<Self>)>
6060
let Token { kind, span } = match tree {
6161
tokenstream::TokenTree::Delimited(span, delim, tts) => {
6262
let delimiter = Delimiter::from_internal(delim);
63-
return TokenTree::Group(Group { delimiter, stream: tts.into(), span });
63+
return TokenTree::Group(Group { delimiter, stream: tts, span });
6464
}
6565
tokenstream::TokenTree::Token(token) => token,
6666
};
@@ -196,12 +196,8 @@ impl ToInternal<TokenStream> for TokenTree<Group, Punct, Ident, Literal> {
196196
let (ch, joint, span) = match self {
197197
TokenTree::Punct(Punct { ch, joint, span }) => (ch, joint, span),
198198
TokenTree::Group(Group { delimiter, stream, span }) => {
199-
return tokenstream::TokenTree::Delimited(
200-
span,
201-
delimiter.to_internal(),
202-
stream.into(),
203-
)
204-
.into();
199+
return tokenstream::TokenTree::Delimited(span, delimiter.to_internal(), stream)
200+
.into();
205201
}
206202
TokenTree::Ident(self::Ident { sym, is_raw, span }) => {
207203
return tokenstream::TokenTree::token(Ident(sym, is_raw), span).into();

0 commit comments

Comments
 (0)