Skip to content

Commit d35c82f

Browse files
committed
Resolve clippy::useless_conversion
error: useless conversion to the same type: `rustc_const_eval::interpret::Pointer<std::option::Option<machine::Tag>>` --> src/helpers.rs:668:36 | 668 | this.get_ptr_alloc(ptr.offset(len, this)?.into(), size1, Align::ONE)?.unwrap(); // not a ZST, so we will get a result | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `ptr.offset(len, this)?` | = note: `-D clippy::useless-conversion` implied by `-D clippy::all` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion error: useless conversion to the same type: `rustc_const_eval::interpret::Pointer<std::option::Option<machine::Tag>>` --> src/helpers.rs:678:29 | 678 | this.read_bytes_ptr(ptr.into(), len) | ^^^^^^^^^^ help: consider removing `.into()`: `ptr` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion error: useless conversion to the same type: `rustc_const_eval::interpret::Pointer<std::option::Option<machine::Tag>>` --> src/helpers.rs:690:44 | 690 | let alloc = this.get_ptr_alloc(ptr.into(), size2, align2)?.unwrap(); // not a ZST, so we will get a result | ^^^^^^^^^^ help: consider removing `.into()`: `ptr` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion error: useless conversion to the same type: `rustc_const_eval::interpret::OpTy<machine::Tag>` --> src/shims/intrinsics.rs:778:42 | 778 | .read_immediate(&this.operand_index(index, i)?.into())? | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `this.operand_index(index, i)?` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion error: useless conversion to the same type: `u32` --> src/shims/posix/fs.rs:1171:26 | 1171 | builder.mode(mode.into()); | ^^^^^^^^^^^ help: consider removing `.into()`: `mode` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion error: useless conversion to the same type: `std::ffi::OsString` --> src/shims/env.rs:67:53 | 67 | ecx.machine.env_vars.map.insert(OsString::from(name), var_ptr); | ^^^^^^^^^^^^^^^^^^^^ help: consider removing `OsString::from()`: `name` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion error: useless conversion to the same type: `rustc_const_eval::interpret::Scalar<machine::Tag>` --> src/shims/tls.rs:102:44 | 102 | Ok(value.unwrap_or_else(|| Scalar::null_ptr(cx).into())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `Scalar::null_ptr(cx)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion error: useless conversion to the same type: `u32` --> src/thread.rs:73:26 | 73 | Scalar::from_u32(u32::try_from(self.0).unwrap()) | ^^^^^^^^^^^^^^^^^^^^^ | = help: consider removing `u32::try_from()` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
1 parent 4b523fc commit d35c82f

File tree

7 files changed

+8
-10
lines changed

7 files changed

+8
-10
lines changed

src/helpers.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
664664
loop {
665665
// FIXME: We are re-getting the allocation each time around the loop.
666666
// Would be nice if we could somehow "extend" an existing AllocRange.
667-
let alloc =
668-
this.get_ptr_alloc(ptr.offset(len, this)?.into(), size1, Align::ONE)?.unwrap(); // not a ZST, so we will get a result
667+
let alloc = this.get_ptr_alloc(ptr.offset(len, this)?, size1, Align::ONE)?.unwrap(); // not a ZST, so we will get a result
669668
let byte = alloc.read_scalar(alloc_range(Size::ZERO, size1))?.to_u8()?;
670669
if byte == 0 {
671670
break;
@@ -675,7 +674,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
675674
}
676675

677676
// Step 2: get the bytes.
678-
this.read_bytes_ptr(ptr.into(), len)
677+
this.read_bytes_ptr(ptr, len)
679678
}
680679

681680
fn read_wide_str(&self, mut ptr: Pointer<Option<Tag>>) -> InterpResult<'tcx, Vec<u16>> {
@@ -687,7 +686,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
687686
loop {
688687
// FIXME: We are re-getting the allocation each time around the loop.
689688
// Would be nice if we could somehow "extend" an existing AllocRange.
690-
let alloc = this.get_ptr_alloc(ptr.into(), size2, align2)?.unwrap(); // not a ZST, so we will get a result
689+
let alloc = this.get_ptr_alloc(ptr, size2, align2)?.unwrap(); // not a ZST, so we will get a result
691690
let wchar = alloc.read_scalar(alloc_range(Size::ZERO, size2))?.to_u16()?;
692691
if wchar == 0 {
693692
break;

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
clippy::needless_lifetimes,
2222
clippy::new_without_default,
2323
clippy::single_match,
24-
clippy::useless_conversion,
2524
clippy::useless_format
2625
)]
2726

src/shims/env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl<'tcx> EnvVars<'tcx> {
6464
unsupported
6565
),
6666
};
67-
ecx.machine.env_vars.map.insert(OsString::from(name), var_ptr);
67+
ecx.machine.env_vars.map.insert(name, var_ptr);
6868
}
6969
}
7070
}

src/shims/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
775775

776776
for i in 0..dest_len {
777777
let src_index: u64 = this
778-
.read_immediate(&this.operand_index(index, i)?.into())?
778+
.read_immediate(&this.operand_index(index, i)?)?
779779
.to_scalar()?
780780
.to_u32()?
781781
.into();

src/shims/posix/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
11681168
#[cfg(unix)]
11691169
{
11701170
use std::os::unix::fs::DirBuilderExt;
1171-
builder.mode(mode.into());
1171+
builder.mode(mode);
11721172
}
11731173

11741174
let result = builder.create(path).map(|_| 0i32);

src/shims/tls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl<'tcx> TlsData<'tcx> {
9999
Some(TlsEntry { data, .. }) => {
100100
let value = data.get(&thread_id).copied();
101101
trace!("TLS key {} for thread {:?} loaded: {:?}", key, thread_id, value);
102-
Ok(value.unwrap_or_else(|| Scalar::null_ptr(cx).into()))
102+
Ok(value.unwrap_or_else(|| Scalar::null_ptr(cx)))
103103
}
104104
None => throw_ub_format!("loading from a non-existing TLS key: {}", key),
105105
}

src/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl From<u32> for ThreadId {
7070

7171
impl ThreadId {
7272
pub fn to_u32_scalar(&self) -> Scalar<Tag> {
73-
Scalar::from_u32(u32::try_from(self.0).unwrap())
73+
Scalar::from_u32(self.0)
7474
}
7575
}
7676

0 commit comments

Comments
 (0)