Skip to content

Commit 0aa4cde

Browse files
committed
avoid .into() conversion to identical types
1 parent 35a99ee commit 0aa4cde

File tree

11 files changed

+17
-27
lines changed

11 files changed

+17
-27
lines changed

compiler/rustc_builtin_macros/src/test.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ pub fn expand_test_or_bench(
239239
cx.attr_nested_word(sym::cfg, sym::test, attr_sp),
240240
// #[rustc_test_marker = "test_case_sort_key"]
241241
cx.attr_name_value_str(sym::rustc_test_marker, test_path_symbol, attr_sp),
242-
]
243-
.into(),
242+
],
244243
// const $ident: test::TestDescAndFn =
245244
ast::ItemKind::Const(
246245
ast::Defaultness::Final,

compiler/rustc_const_eval/src/interpret/operand.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub enum Immediate<Prov: Provenance = AllocId> {
3939
impl<Prov: Provenance> From<Scalar<Prov>> for Immediate<Prov> {
4040
#[inline(always)]
4141
fn from(val: Scalar<Prov>) -> Self {
42-
Immediate::Scalar(val.into())
42+
Immediate::Scalar(val)
4343
}
4444
}
4545

@@ -53,15 +53,15 @@ impl<Prov: Provenance> Immediate<Prov> {
5353
}
5454

5555
pub fn new_slice(val: Scalar<Prov>, len: u64, cx: &impl HasDataLayout) -> Self {
56-
Immediate::ScalarPair(val.into(), Scalar::from_machine_usize(len, cx).into())
56+
Immediate::ScalarPair(val, Scalar::from_machine_usize(len, cx))
5757
}
5858

5959
pub fn new_dyn_trait(
6060
val: Scalar<Prov>,
6161
vtable: Pointer<Option<Prov>>,
6262
cx: &impl HasDataLayout,
6363
) -> Self {
64-
Immediate::ScalarPair(val.into(), Scalar::from_maybe_pointer(vtable, cx))
64+
Immediate::ScalarPair(val, Scalar::from_maybe_pointer(vtable, cx))
6565
}
6666

6767
#[inline]
@@ -341,10 +341,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
341341
alloc_range(b_offset, b_size),
342342
/*read_provenance*/ b.is_ptr(),
343343
)?;
344-
Some(ImmTy {
345-
imm: Immediate::ScalarPair(a_val.into(), b_val.into()),
346-
layout: mplace.layout,
347-
})
344+
Some(ImmTy { imm: Immediate::ScalarPair(a_val, b_val), layout: mplace.layout })
348345
}
349346
_ => {
350347
// Neither a scalar nor scalar pair.

compiler/rustc_const_eval/src/interpret/operator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
3636
if let Abi::ScalarPair(..) = dest.layout.abi {
3737
// We can use the optimized path and avoid `place_field` (which might do
3838
// `force_allocation`).
39-
let pair = Immediate::ScalarPair(val.into(), Scalar::from_bool(overflowed).into());
39+
let pair = Immediate::ScalarPair(val, Scalar::from_bool(overflowed));
4040
self.write_immediate(pair, dest)?;
4141
} else {
4242
assert!(self.tcx.sess.opts.unstable_opts.randomize_layout);

compiler/rustc_const_eval/src/interpret/place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<Prov: Provenance> MemPlace<Prov> {
141141
match self.meta {
142142
MemPlaceMeta::None => Immediate::from(Scalar::from_maybe_pointer(self.ptr, cx)),
143143
MemPlaceMeta::Meta(meta) => {
144-
Immediate::ScalarPair(Scalar::from_maybe_pointer(self.ptr, cx).into(), meta.into())
144+
Immediate::ScalarPair(Scalar::from_maybe_pointer(self.ptr, cx), meta)
145145
}
146146
}
147147
}

compiler/rustc_infer/src/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,7 @@ impl<'tcx> TypeTrace<'tcx> {
19201920
) -> TypeTrace<'tcx> {
19211921
TypeTrace {
19221922
cause: cause.clone(),
1923-
values: PolyTraitRefs(ExpectedFound::new(a_is_expected, a.into(), b.into())),
1923+
values: PolyTraitRefs(ExpectedFound::new(a_is_expected, a, b)),
19241924
}
19251925
}
19261926

compiler/rustc_middle/src/ty/vtable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ pub(super) fn vtable_allocation_provider<'tcx>(
8888
let fn_ptr = Pointer::from(fn_alloc_id);
8989
Scalar::from_pointer(fn_ptr, &tcx)
9090
}
91-
VtblEntry::MetadataSize => Scalar::from_uint(size, ptr_size).into(),
92-
VtblEntry::MetadataAlign => Scalar::from_uint(align, ptr_size).into(),
91+
VtblEntry::MetadataSize => Scalar::from_uint(size, ptr_size),
92+
VtblEntry::MetadataAlign => Scalar::from_uint(align, ptr_size),
9393
VtblEntry::Vacant => continue,
9494
VtblEntry::Method(instance) => {
9595
// Prepare the fn ptr we write into the vtable.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ impl<'tcx> PlaceBuilder<'tcx> {
356356
match self {
357357
PlaceBuilder::Local { local, projection } => PlaceBuilder::Local {
358358
local: *local,
359-
projection: Vec::from_iter(projection.iter().copied().chain([elem.into()])),
359+
projection: Vec::from_iter(projection.iter().copied().chain([elem])),
360360
},
361361
PlaceBuilder::Upvar { upvar, projection } => PlaceBuilder::Upvar {
362362
upvar: *upvar,

compiler/rustc_mir_transform/src/const_prop.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -701,8 +701,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
701701
BinOp::Mul if const_arg.layout.ty.is_integral() && arg_value == 0 => {
702702
if let Rvalue::CheckedBinaryOp(_, _) = rvalue {
703703
let val = Immediate::ScalarPair(
704-
const_arg.to_scalar().into(),
705-
Scalar::from_bool(false).into(),
704+
const_arg.to_scalar(),
705+
Scalar::from_bool(false),
706706
);
707707
this.ecx.write_immediate(val, &dest)
708708
} else {

compiler/rustc_parse/src/parser/mod.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use rustc_ast::tokenstream::{TokenStream, TokenTree};
2525
use rustc_ast::util::case::Case;
2626
use rustc_ast::AttrId;
2727
use rustc_ast::DUMMY_NODE_ID;
28-
use rustc_ast::{self as ast, AnonConst, AttrStyle, AttrVec, Const, DelimArgs, Extern};
28+
use rustc_ast::{self as ast, AnonConst, AttrStyle, Const, DelimArgs, Extern};
2929
use rustc_ast::{Async, AttrArgs, AttrArgsEq, Expr, ExprKind, MacDelimiter, Mutability, StrLit};
3030
use rustc_ast::{HasAttrs, HasTokens, Unsafe, Visibility, VisibilityKind};
3131
use rustc_ast_pretty::pprust;
@@ -1217,11 +1217,7 @@ impl<'a> Parser<'a> {
12171217
value: self.mk_expr(blk.span, ExprKind::Block(blk, None)),
12181218
};
12191219
let blk_span = anon_const.value.span;
1220-
Ok(self.mk_expr_with_attrs(
1221-
span.to(blk_span),
1222-
ExprKind::ConstBlock(anon_const),
1223-
AttrVec::from(attrs),
1224-
))
1220+
Ok(self.mk_expr_with_attrs(span.to(blk_span), ExprKind::ConstBlock(anon_const), attrs))
12251221
}
12261222

12271223
/// Parses mutability (`mut` or nothing).

compiler/rustc_passes/src/lang_items.rs

-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ impl<'tcx> LanguageItemCollector<'tcx> {
8383
.map(|p| p.display().to_string())
8484
.collect::<Vec<_>>()
8585
.join(", ")
86-
.into()
8786
};
8887
let first_defined_span = self.tcx.hir().span_if_local(original_def_id);
8988
let mut orig_crate_name = Empty;
@@ -98,7 +97,6 @@ impl<'tcx> LanguageItemCollector<'tcx> {
9897
.map(|p| p.display().to_string())
9998
.collect::<Vec<_>>()
10099
.join(", ")
101-
.into()
102100
};
103101
if first_defined_span.is_none() {
104102
orig_crate_name = self.tcx.crate_name(original_def_id.krate);

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1735,8 +1735,8 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
17351735
values.map(|(_, is_normalized_ty_expected, normalized_ty, expected_ty)| {
17361736
infer::ValuePairs::Terms(ExpectedFound::new(
17371737
is_normalized_ty_expected,
1738-
normalized_ty.into(),
1739-
expected_ty.into(),
1738+
normalized_ty,
1739+
expected_ty,
17401740
))
17411741
}),
17421742
err,

0 commit comments

Comments
 (0)