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
This commit is contained in:
parent
4b523fce18
commit
d35c82f79f
@ -664,8 +664,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
loop {
|
||||
// FIXME: We are re-getting the allocation each time around the loop.
|
||||
// Would be nice if we could somehow "extend" an existing AllocRange.
|
||||
let alloc =
|
||||
this.get_ptr_alloc(ptr.offset(len, this)?.into(), size1, Align::ONE)?.unwrap(); // not a ZST, so we will get a result
|
||||
let alloc = this.get_ptr_alloc(ptr.offset(len, this)?, size1, Align::ONE)?.unwrap(); // not a ZST, so we will get a result
|
||||
let byte = alloc.read_scalar(alloc_range(Size::ZERO, size1))?.to_u8()?;
|
||||
if byte == 0 {
|
||||
break;
|
||||
@ -675,7 +674,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
}
|
||||
|
||||
// Step 2: get the bytes.
|
||||
this.read_bytes_ptr(ptr.into(), len)
|
||||
this.read_bytes_ptr(ptr, len)
|
||||
}
|
||||
|
||||
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
|
||||
loop {
|
||||
// FIXME: We are re-getting the allocation each time around the loop.
|
||||
// Would be nice if we could somehow "extend" an existing AllocRange.
|
||||
let alloc = this.get_ptr_alloc(ptr.into(), size2, align2)?.unwrap(); // not a ZST, so we will get a result
|
||||
let alloc = this.get_ptr_alloc(ptr, size2, align2)?.unwrap(); // not a ZST, so we will get a result
|
||||
let wchar = alloc.read_scalar(alloc_range(Size::ZERO, size2))?.to_u16()?;
|
||||
if wchar == 0 {
|
||||
break;
|
||||
|
@ -21,7 +21,6 @@
|
||||
clippy::needless_lifetimes,
|
||||
clippy::new_without_default,
|
||||
clippy::single_match,
|
||||
clippy::useless_conversion,
|
||||
clippy::useless_format
|
||||
)]
|
||||
|
||||
|
@ -64,7 +64,7 @@ impl<'tcx> EnvVars<'tcx> {
|
||||
unsupported
|
||||
),
|
||||
};
|
||||
ecx.machine.env_vars.map.insert(OsString::from(name), var_ptr);
|
||||
ecx.machine.env_vars.map.insert(name, var_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -775,7 +775,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
|
||||
for i in 0..dest_len {
|
||||
let src_index: u64 = this
|
||||
.read_immediate(&this.operand_index(index, i)?.into())?
|
||||
.read_immediate(&this.operand_index(index, i)?)?
|
||||
.to_scalar()?
|
||||
.to_u32()?
|
||||
.into();
|
||||
|
@ -1168,7 +1168,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::os::unix::fs::DirBuilderExt;
|
||||
builder.mode(mode.into());
|
||||
builder.mode(mode);
|
||||
}
|
||||
|
||||
let result = builder.create(path).map(|_| 0i32);
|
||||
|
@ -99,7 +99,7 @@ impl<'tcx> TlsData<'tcx> {
|
||||
Some(TlsEntry { data, .. }) => {
|
||||
let value = data.get(&thread_id).copied();
|
||||
trace!("TLS key {} for thread {:?} loaded: {:?}", key, thread_id, value);
|
||||
Ok(value.unwrap_or_else(|| Scalar::null_ptr(cx).into()))
|
||||
Ok(value.unwrap_or_else(|| Scalar::null_ptr(cx)))
|
||||
}
|
||||
None => throw_ub_format!("loading from a non-existing TLS key: {}", key),
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ impl From<u32> for ThreadId {
|
||||
|
||||
impl ThreadId {
|
||||
pub fn to_u32_scalar(&self) -> Scalar<Tag> {
|
||||
Scalar::from_u32(u32::try_from(self.0).unwrap())
|
||||
Scalar::from_u32(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user