diff options
| author | Ralf Jung <post@ralfj.de> | 2023-07-27 09:29:22 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-07-27 09:29:22 +0200 |
| commit | e5bede18f6b1df9d91e1516a7ac79cacbf1f8a9b (patch) | |
| tree | 413bbb08d04b88e810db6d1423d5a71d1e280fc7 /src/tools | |
| parent | 3a1a03a1cc56067b54ae198b1426245677954fd7 (diff) | |
| parent | d150dbb067e66f351a0b33a54e7d4b464ef51e47 (diff) | |
| download | rust-e5bede18f6b1df9d91e1516a7ac79cacbf1f8a9b.tar.gz rust-e5bede18f6b1df9d91e1516a7ac79cacbf1f8a9b.zip | |
Merge from rustc
Diffstat (limited to 'src/tools')
24 files changed, 143 insertions, 155 deletions
diff --git a/src/tools/clippy/clippy_lints/src/doc.rs b/src/tools/clippy/clippy_lints/src/doc.rs index 8879c529262..00f70e586f4 100644 --- a/src/tools/clippy/clippy_lints/src/doc.rs +++ b/src/tools/clippy/clippy_lints/src/doc.rs @@ -729,7 +729,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) { false, TerminalUrl::No, ); - let handler = Handler::with_emitter(false, None, Box::new(emitter), None); + let handler = Handler::with_emitter(Box::new(emitter)).disable_warnings(); let sess = ParseSess::with_span_handler(handler, sm); let mut parser = match maybe_new_parser_from_source_str(&sess, filename, code) { diff --git a/src/tools/clippy/clippy_lints/src/methods/bytecount.rs b/src/tools/clippy/clippy_lints/src/methods/bytecount.rs index fef90f6eba4..f490a717554 100644 --- a/src/tools/clippy/clippy_lints/src/methods/bytecount.rs +++ b/src/tools/clippy/clippy_lints/src/methods/bytecount.rs @@ -45,7 +45,7 @@ pub(super) fn check<'tcx>( let haystack = if let ExprKind::MethodCall(path, receiver, [], _) = filter_recv.kind { let p = path.ident.name; - if p == sym::iter || p == sym!(iter_mut) { + if p == sym::iter || p == sym::iter_mut { receiver } else { filter_recv diff --git a/src/tools/miri/src/concurrency/data_race.rs b/src/tools/miri/src/concurrency/data_race.rs index 84ef27f7365..37125337d6f 100644 --- a/src/tools/miri/src/concurrency/data_race.rs +++ b/src/tools/miri/src/concurrency/data_race.rs @@ -472,7 +472,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { // This is fine with StackedBorrow and race checks because they don't concern metadata on // the *value* (including the associated provenance if this is an AtomicPtr) at this location. // Only metadata on the location itself is used. - let scalar = this.allow_data_races_ref(move |this| this.read_scalar(&place.into()))?; + let scalar = this.allow_data_races_ref(move |this| this.read_scalar(place))?; this.validate_overlapping_atomic(place)?; this.buffered_atomic_read(place, atomic, scalar, || { this.validate_atomic_load(place, atomic) @@ -490,7 +490,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { this.atomic_access_check(dest)?; this.validate_overlapping_atomic(dest)?; - this.allow_data_races_mut(move |this| this.write_scalar(val, &dest.into()))?; + this.allow_data_races_mut(move |this| this.write_scalar(val, dest))?; this.validate_atomic_store(dest, atomic)?; // FIXME: it's not possible to get the value before write_scalar. A read_scalar will cause // side effects from a read the program did not perform. So we have to initialise @@ -513,12 +513,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { this.atomic_access_check(place)?; this.validate_overlapping_atomic(place)?; - let old = this.allow_data_races_mut(|this| this.read_immediate(&place.into()))?; + let old = this.allow_data_races_mut(|this| this.read_immediate(place))?; // Atomics wrap around on overflow. let val = this.binary_op(op, &old, rhs)?; let val = if neg { this.unary_op(mir::UnOp::Not, &val)? } else { val }; - this.allow_data_races_mut(|this| this.write_immediate(*val, &place.into()))?; + this.allow_data_races_mut(|this| this.write_immediate(*val, place))?; this.validate_atomic_rmw(place, atomic)?; @@ -538,8 +538,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { this.atomic_access_check(place)?; this.validate_overlapping_atomic(place)?; - let old = this.allow_data_races_mut(|this| this.read_scalar(&place.into()))?; - this.allow_data_races_mut(|this| this.write_scalar(new, &place.into()))?; + let old = this.allow_data_races_mut(|this| this.read_scalar(place))?; + this.allow_data_races_mut(|this| this.write_scalar(new, place))?; this.validate_atomic_rmw(place, atomic)?; @@ -560,7 +560,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { this.atomic_access_check(place)?; this.validate_overlapping_atomic(place)?; - let old = this.allow_data_races_mut(|this| this.read_immediate(&place.into()))?; + let old = this.allow_data_races_mut(|this| this.read_immediate(place))?; let lt = this.binary_op(mir::BinOp::Lt, &old, &rhs)?.to_scalar().to_bool()?; let new_val = if min { @@ -569,7 +569,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { if lt { &rhs } else { &old } }; - this.allow_data_races_mut(|this| this.write_immediate(**new_val, &place.into()))?; + this.allow_data_races_mut(|this| this.write_immediate(**new_val, place))?; this.validate_atomic_rmw(place, atomic)?; @@ -603,7 +603,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { // to read with the failure ordering and if successful then try again with the success // read ordering and write in the success case. // Read as immediate for the sake of `binary_op()` - let old = this.allow_data_races_mut(|this| this.read_immediate(&(place.into())))?; + let old = this.allow_data_races_mut(|this| this.read_immediate(place))?; // `binary_op` will bail if either of them is not a scalar. let eq = this.binary_op(mir::BinOp::Eq, &old, expect_old)?; // If the operation would succeed, but is "weak", fail some portion @@ -621,7 +621,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { // if successful, perform a full rw-atomic validation // otherwise treat this as an atomic load with the fail ordering. if cmpxchg_success { - this.allow_data_races_mut(|this| this.write_scalar(new, &place.into()))?; + this.allow_data_races_mut(|this| this.write_scalar(new, place))?; this.validate_atomic_rmw(place, success)?; this.buffered_atomic_rmw(new, place, success, old.to_scalar())?; } else { diff --git a/src/tools/miri/src/concurrency/thread.rs b/src/tools/miri/src/concurrency/thread.rs index 25c8df43ee2..9c11ad85aef 100644 --- a/src/tools/miri/src/concurrency/thread.rs +++ b/src/tools/miri/src/concurrency/thread.rs @@ -834,7 +834,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { if let Some(thread_info_place) = thread { this.write_scalar( Scalar::from_uint(new_thread_id.to_u32(), thread_info_place.layout.size), - &thread_info_place.into(), + &thread_info_place, )?; } diff --git a/src/tools/miri/src/eval.rs b/src/tools/miri/src/eval.rs index 4f7b70649a9..b761a6cf475 100644 --- a/src/tools/miri/src/eval.rs +++ b/src/tools/miri/src/eval.rs @@ -246,7 +246,7 @@ impl MainThreadState { this.machine.main_fn_ret_place.unwrap().ptr, this.machine.layouts.isize, ); - let exit_code = this.read_target_isize(&ret_place.into())?; + let exit_code = this.read_target_isize(&ret_place)?; // Need to call this ourselves since we are not going to return to the scheduler // loop, and we want the main thread TLS to not show up as memory leaks. this.terminate_active_thread()?; @@ -321,7 +321,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( let argvs_place = ecx.allocate(argvs_layout, MiriMemoryKind::Machine.into())?; for (idx, arg) in argvs.into_iter().enumerate() { let place = ecx.project_field(&argvs_place, idx)?; - ecx.write_immediate(arg, &place.into())?; + ecx.write_immediate(arg, &place)?; } ecx.mark_immutable(&argvs_place); // A pointer to that place is the 3rd argument for main. @@ -330,7 +330,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( { let argc_place = ecx.allocate(ecx.machine.layouts.isize, MiriMemoryKind::Machine.into())?; - ecx.write_scalar(argc, &argc_place.into())?; + ecx.write_scalar(argc, &argc_place)?; ecx.mark_immutable(&argc_place); ecx.machine.argc = Some(*argc_place); @@ -338,7 +338,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( ecx.layout_of(Ty::new_imm_ptr(tcx, tcx.types.unit))?, MiriMemoryKind::Machine.into(), )?; - ecx.write_immediate(argv, &argv_place.into())?; + ecx.write_immediate(argv, &argv_place)?; ecx.mark_immutable(&argv_place); ecx.machine.argv = Some(*argv_place); } @@ -355,7 +355,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( // Store the UTF-16 string. We just allocated so we know the bounds are fine. for (idx, &c) in cmd_utf16.iter().enumerate() { let place = ecx.project_field(&cmd_place, idx)?; - ecx.write_scalar(Scalar::from_u16(c), &place.into())?; + ecx.write_scalar(Scalar::from_u16(c), &place)?; } ecx.mark_immutable(&cmd_place); } diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index f6a438f5d62..d41bcc978b0 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -166,7 +166,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let const_val = this.eval_global(cid, None).unwrap_or_else(|err| { panic!("failed to evaluate required Rust item: {path:?}\n{err:?}") }); - this.read_scalar(&const_val.into()) + this.read_scalar(&const_val) .unwrap_or_else(|err| panic!("failed to read required Rust item: {path:?}\n{err:?}")) } @@ -231,7 +231,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } /// Project to the given *named* field (which must be a struct or union type). - fn project_field_named<P: Projectable<'mir, 'tcx, Provenance>>( + fn project_field_named<P: Projectable<'tcx, Provenance>>( &self, base: &P, name: &str, @@ -252,13 +252,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { fn write_int( &mut self, i: impl Into<i128>, - dest: &PlaceTy<'tcx, Provenance>, + dest: &impl Writeable<'tcx, Provenance>, ) -> InterpResult<'tcx> { - assert!(dest.layout.abi.is_scalar(), "write_int on non-scalar type {}", dest.layout.ty); - let val = if dest.layout.abi.is_signed() { - Scalar::from_int(i, dest.layout.size) + assert!(dest.layout().abi.is_scalar(), "write_int on non-scalar type {}", dest.layout().ty); + let val = if dest.layout().abi.is_signed() { + Scalar::from_int(i, dest.layout().size) } else { - Scalar::from_uint(u64::try_from(i.into()).unwrap(), dest.layout.size) + Scalar::from_uint(u64::try_from(i.into()).unwrap(), dest.layout().size) }; self.eval_context_mut().write_scalar(val, dest) } @@ -267,12 +267,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { fn write_int_fields( &mut self, values: &[i128], - dest: &MPlaceTy<'tcx, Provenance>, + dest: &impl Writeable<'tcx, Provenance>, ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); for (idx, &val) in values.iter().enumerate() { let field = this.project_field(dest, idx)?; - this.write_int(val, &field.into())?; + this.write_int(val, &field)?; } Ok(()) } @@ -281,18 +281,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { fn write_int_fields_named( &mut self, values: &[(&str, i128)], - dest: &MPlaceTy<'tcx, Provenance>, + dest: &impl Writeable<'tcx, Provenance>, ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); for &(name, val) in values.iter() { let field = this.project_field_named(dest, name)?; - this.write_int(val, &field.into())?; + this.write_int(val, &field)?; } Ok(()) } /// Write a 0 of the appropriate size to `dest`. - fn write_null(&mut self, dest: &PlaceTy<'tcx, Provenance>) -> InterpResult<'tcx> { + fn write_null(&mut self, dest: &impl Writeable<'tcx, Provenance>) -> InterpResult<'tcx> { self.write_int(0, dest) } @@ -600,14 +600,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { /// necessary. fn last_error_place(&mut self) -> InterpResult<'tcx, MPlaceTy<'tcx, Provenance>> { let this = self.eval_context_mut(); - if let Some(errno_place) = this.active_thread_ref().last_error { - Ok(errno_place) + if let Some(errno_place) = this.active_thread_ref().last_error.as_ref() { + Ok(errno_place.clone()) } else { // Allocate new place, set initial value to 0. let errno_layout = this.machine.layouts.u32; let errno_place = this.allocate(errno_layout, MiriMemoryKind::Machine.into())?; - this.write_scalar(Scalar::from_u32(0), &errno_place.into())?; - this.active_thread_mut().last_error = Some(errno_place); + this.write_scalar(Scalar::from_u32(0), &errno_place)?; + this.active_thread_mut().last_error = Some(errno_place.clone()); Ok(errno_place) } } @@ -616,14 +616,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { fn set_last_error(&mut self, scalar: Scalar<Provenance>) -> InterpResult<'tcx> { let this = self.eval_context_mut(); let errno_place = this.last_error_place()?; - this.write_scalar(scalar, &errno_place.into()) + this.write_scalar(scalar, &errno_place) } /// Gets the last error variable. fn get_last_error(&mut self) -> InterpResult<'tcx, Scalar<Provenance>> { let this = self.eval_context_mut(); let errno_place = this.last_error_place()?; - this.read_scalar(&errno_place.into()) + this.read_scalar(&errno_place) } /// This function tries to produce the most similar OS error from the `std::io::ErrorKind` @@ -725,7 +725,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let mplace = MPlaceTy::from_aligned_ptr(ptr, layout); - this.check_mplace(mplace)?; + this.check_mplace(&mplace)?; Ok(mplace) } @@ -772,7 +772,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { ) -> InterpResult<'tcx, Scalar<Provenance>> { let this = self.eval_context_ref(); let value_place = this.deref_operand_and_offset(op, offset, base_layout, value_layout)?; - this.read_scalar(&value_place.into()) + this.read_scalar(&value_place) } fn write_scalar_at_offset( @@ -785,7 +785,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { ) -> InterpResult<'tcx, ()> { let this = self.eval_context_mut(); let value_place = this.deref_operand_and_offset(op, offset, base_layout, value_layout)?; - this.write_scalar(value, &value_place.into()) + this.write_scalar(value, &value_place) } /// Parse a `timespec` struct and return it as a `std::time::Duration`. It returns `None` @@ -797,10 +797,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { ) -> InterpResult<'tcx, Option<Duration>> { let this = self.eval_context_mut(); let seconds_place = this.project_field(tp, 0)?; - let seconds_scalar = this.read_scalar(&seconds_place.into())?; + let seconds_scalar = this.read_scalar(&seconds_place)?; let seconds = seconds_scalar.to_target_isize(this)?; let nanoseconds_place = this.project_field(tp, 1)?; - let nanoseconds_scalar = this.read_scalar(&nanoseconds_place.into())?; + let nanoseconds_scalar = this.read_scalar(&nanoseconds_place)?; let nanoseconds = nanoseconds_scalar.to_target_isize(this)?; Ok(try { diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index a8f89d56f6d..0c9c072b051 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -651,7 +651,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { val: ImmTy<'tcx, Provenance>, ) -> InterpResult<'tcx> { let place = this.allocate(val.layout, MiriMemoryKind::ExternStatic.into())?; - this.write_immediate(*val, &place.into())?; + this.write_immediate(*val, &place)?; Self::add_extern_static(this, name, place.ptr); Ok(()) } @@ -668,7 +668,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { Self::add_extern_static( this, "environ", - this.machine.env_vars.environ.unwrap().ptr, + this.machine.env_vars.environ.as_ref().unwrap().ptr, ); // A couple zero-initialized pointer-sized extern statics. // Most of them are for weak symbols, which we all set to null (indicating that the @@ -685,7 +685,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { Self::add_extern_static( this, "environ", - this.machine.env_vars.environ.unwrap().ptr, + this.machine.env_vars.environ.as_ref().unwrap().ptr, ); } "android" => { diff --git a/src/tools/miri/src/shims/backtrace.rs b/src/tools/miri/src/shims/backtrace.rs index e4aa7467cbe..e89b2e01a39 100644 --- a/src/tools/miri/src/shims/backtrace.rs +++ b/src/tools/miri/src/shims/backtrace.rs @@ -85,7 +85,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { for (i, ptr) in ptrs.into_iter().enumerate() { let place = this.project_index(&alloc, i as u64)?; - this.write_pointer(ptr, &place.into())?; + this.write_pointer(ptr, &place)?; } this.write_immediate( @@ -106,7 +106,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let op_place = buf_place.offset(offset, ptr_layout, this)?; - this.write_pointer(ptr, &op_place.into())?; + this.write_pointer(ptr, &op_place)?; } } _ => throw_unsup_format!("unknown `miri_get_backtrace` flags {}", flags), @@ -196,33 +196,33 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { this.write_immediate( name_alloc.to_ref(this), - &this.project_field(&dest, 0)?.into(), + &this.project_field(&dest, 0)?, )?; this.write_immediate( filename_alloc.to_ref(this), - &this.project_field(&dest, 1)?.into(), + &this.project_field(&dest, 1)?, )?; } 1 => { this.write_scalar( Scalar::from_target_usize(name.len().try_into().unwrap(), this), - &this.project_field(&dest, 0)?.into(), + &this.project_field(&dest, 0)?, )?; this.write_scalar( Scalar::from_target_usize(filename.len().try_into().unwrap(), this), - &this.project_field(&dest, 1)?.into(), + &this.project_field(&dest, 1)?, )?; } _ => throw_unsup_format!("unknown `miri_resolve_frame` flags {}", flags), } - this.write_scalar(Scalar::from_u32(lineno), &this.project_field(&dest, 2)?.into())?; - this.write_scalar(Scalar::from_u32(colno), &this.project_field(&dest, 3)?.into())?; + this.write_scalar(Scalar::from_u32(lineno), &this.project_field(&dest, 2)?)?; + this.write_scalar(Scalar::from_u32(colno), &this.project_field(&dest, 3)?)?; // Support a 4-field struct for now - this is deprecated // and slated for removal. if num_fields == 5 { - this.write_pointer(fn_ptr, &this.project_field(&dest, 4)?.into())?; + this.write_pointer(fn_ptr, &this.project_field(&dest, 4)?)?; } Ok(()) diff --git a/src/tools/miri/src/shims/env.rs b/src/tools/miri/src/shims/env.rs index f98fd0431ae..3694ea51da6 100644 --- a/src/tools/miri/src/shims/env.rs +++ b/src/tools/miri/src/shims/env.rs @@ -87,8 +87,8 @@ impl<'tcx> EnvVars<'tcx> { ecx.deallocate_ptr(ptr, None, MiriMemoryKind::Runtime.into())?; } // Deallocate environ var list. - let environ = ecx.machine.env_vars.environ.unwrap(); - let old_vars_ptr = ecx.read_pointer(&environ.into())?; + let environ = ecx.machine.env_vars.environ.as_ref().unwrap(); + let old_vars_ptr = ecx.read_pointer(environ)?; ecx.deallocate_ptr(old_vars_ptr, None, MiriMemoryKind::Runtime.into())?; Ok(()) } @@ -431,8 +431,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { fn update_environ(&mut self) -> InterpResult<'tcx> { let this = self.eval_context_mut(); // Deallocate the old environ list, if any. - if let Some(environ) = this.machine.env_vars.environ { - let old_vars_ptr = this.read_pointer(&environ.into())?; + if let Some(environ) = this.machine.env_vars.environ.as_ref() { + let old_vars_ptr = this.read_pointer(environ)?; this.deallocate_ptr(old_vars_ptr, None, MiriMemoryKind::Runtime.into())?; } else { // No `environ` allocated yet, let's do that. @@ -457,9 +457,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let vars_place = this.allocate(vars_layout, MiriMemoryKind::Runtime.into())?; for (idx, var) in vars.into_iter().enumerate() { let place = this.project_field(&vars_place, idx)?; - this.write_pointer(var, &place.into())?; + this.write_pointer(var, &place)?; } - this.write_pointer(vars_place.ptr, &this.machine.env_vars.environ.unwrap().into())?; + this.write_pointer(vars_place.ptr, &this.machine.env_vars.environ.clone().unwrap())?; Ok(()) } diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index c753eadbbad..763fa9235d0 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -914,16 +914,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let x = this.read_scalar(x)?.to_f64()?; let exp = this.read_scalar(exp)?.to_i32()?; - // Saturating cast to i16. Even those are outside the valid exponent range so - // `scalbn` below will do its over/underflow handling. - let exp = if exp > i32::from(i16::MAX) { - i16::MAX - } else if exp < i32::from(i16::MIN) { - i16::MIN - } else { - exp.try_into().unwrap() - }; - let res = x.scalbn(exp); this.write_scalar(Scalar::from_f64(res), dest)?; } diff --git a/src/tools/miri/src/shims/intrinsics/mod.rs b/src/tools/miri/src/shims/intrinsics/mod.rs index ca2c1652dc1..26f0a660657 100644 --- a/src/tools/miri/src/shims/intrinsics/mod.rs +++ b/src/tools/miri/src/shims/intrinsics/mod.rs @@ -97,12 +97,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { "volatile_load" => { let [place] = check_arg_count(args)?; let place = this.deref_operand(place)?; - this.copy_op(&place.into(), dest, /*allow_transmute*/ false)?; + this.copy_op(&place, dest, /*allow_transmute*/ false)?; } "volatile_store" => { let [place, dest] = check_arg_count(args)?; let place = this.deref_operand(place)?; - this.copy_op(dest, &place.into(), /*allow_transmute*/ false)?; + this.copy_op(dest, &place, /*allow_transmute*/ false)?; } "write_bytes" | "volatile_set_memory" => { diff --git a/src/tools/miri/src/shims/intrinsics/simd.rs b/src/tools/miri/src/shims/intrinsics/simd.rs index bddfe58ee3c..103feae4ae7 100644 --- a/src/tools/miri/src/shims/intrinsics/simd.rs +++ b/src/tools/miri/src/shims/intrinsics/simd.rs @@ -57,7 +57,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { }; for i in 0..dest_len { - let op = this.read_immediate(&this.project_index(&op, i)?.into())?; + let op = this.read_immediate(&this.project_index(&op, i)?)?; let dest = this.project_index(&dest, i)?; let val = match which { Op::MirOp(mir_op) => this.unary_op(mir_op, &op)?.to_scalar(), @@ -104,7 +104,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } }; - this.write_scalar(val, &dest.into())?; + this.write_scalar(val, &dest)?; } } #[rustfmt::skip] @@ -172,8 +172,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { }; for i in 0..dest_len { - let left = this.read_immediate(&this.project_index(&left, i)?.into())?; - let right = this.read_immediate(&this.project_index(&right, i)?.into())?; + let left = this.read_immediate(&this.project_index(&left, i)?)?; + let right = this.read_immediate(&this.project_index(&right, i)?)?; let dest = this.project_index(&dest, i)?; let val = match which { Op::MirOp(mir_op) => { @@ -217,7 +217,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { fmin_op(&left, &right)? } }; - this.write_scalar(val, &dest.into())?; + this.write_scalar(val, &dest)?; } } "fma" => { @@ -232,9 +232,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { assert_eq!(dest_len, c_len); for i in 0..dest_len { - let a = this.read_scalar(&this.project_index(&a, i)?.into())?; - let b = this.read_scalar(&this.project_index(&b, i)?.into())?; - let c = this.read_scalar(&this.project_index(&c, i)?.into())?; + let a = this.read_scalar(&this.project_index(&a, i)?)?; + let b = this.read_scalar(&this.project_index(&b, i)?)?; + let c = this.read_scalar(&this.project_index(&c, i)?)?; let dest = this.project_index(&dest, i)?; // Works for f32 and f64. @@ -258,7 +258,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { Scalar::from_u64(res.to_bits()) } }; - this.write_scalar(val, &dest.into())?; + this.write_scalar(val, &dest)?; } } #[rustfmt::skip] @@ -295,13 +295,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { }; // Initialize with first lane, then proceed with the rest. - let mut res = this.read_immediate(&this.project_index(&op, 0)?.into())?; + let mut res = this.read_immediate(&this.project_index(&op, 0)?)?; if matches!(which, Op::MirOpBool(_)) { // Convert to `bool` scalar. res = imm_from_bool(simd_element_to_bool(res)?); } for i in 1..op_len { - let op = this.read_immediate(&this.project_index(&op, i)?.into())?; + let op = this.read_immediate(&this.project_index(&op, i)?)?; res = match which { Op::MirOp(mir_op) => { this.binary_op(mir_op, &res, &op)? @@ -355,7 +355,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let mut res = init; for i in 0..op_len { - let op = this.read_immediate(&this.project_index(&op, i)?.into())?; + let op = this.read_immediate(&this.project_index(&op, i)?)?; res = this.binary_op(mir_op, &res, &op)?; } this.write_immediate(*res, dest)?; @@ -372,13 +372,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { assert_eq!(dest_len, no_len); for i in 0..dest_len { - let mask = this.read_immediate(&this.project_index(&mask, i)?.into())?; - let yes = this.read_immediate(&this.project_index(&yes, i)?.into())?; - let no = this.read_immediate(&this.project_index(&no, i)?.into())?; + let mask = this.read_immediate(&this.project_index(&mask, i)?)?; + let yes = this.read_immediate(&this.project_index(&yes, i)?)?; + let no = this.read_immediate(&this.project_index(&no, i)?)?; let dest = this.project_index(&dest, i)?; let val = if simd_element_to_bool(mask)? { yes } else { no }; - this.write_immediate(*val, &dest.into())?; + this.write_immediate(*val, &dest)?; } } "select_bitmask" => { @@ -403,12 +403,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { & 1u64 .checked_shl(simd_bitmask_index(i, dest_len, this.data_layout().endian)) .unwrap(); - let yes = this.read_immediate(&this.project_index(&yes, i.into())?.into())?; - let no = this.read_immediate(&this.project_index(&no, i.into())?.into())?; + let yes = this.read_immediate(&this.project_index(&yes, i.into())?)?; + let no = this.read_immediate(&this.project_index(&no, i.into())?)?; let dest = this.project_index(&dest, i.into())?; let val = if mask != 0 { yes } else { no }; - this.write_immediate(*val, &dest.into())?; + this.write_immediate(*val, &dest)?; } for i in dest_len..bitmask_len { // If the mask is "padded", ensure that padding is all-zero. @@ -435,7 +435,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let from_exposed_cast = intrinsic_name == "from_exposed_addr"; for i in 0..dest_len { - let op = this.read_immediate(&this.project_index(&op, i)?.into())?; + let op = this.read_immediate(&this.project_index(&op, i)?)?; let dest = this.project_index(&dest, i)?; let val = match (op.layout.ty.kind(), dest.layout.ty.kind()) { @@ -472,7 +472,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { to_ty = dest.layout.ty, ), }; - this.write_immediate(val, &dest.into())?; + this.write_immediate(val, &dest)?; } } "shuffle" => { @@ -503,17 +503,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let dest = this.project_index(&dest, i)?; let val = if src_index < left_len { - this.read_immediate(&this.project_index(&left, src_index)?.into())? + this.read_immediate(&this.project_index(&left, src_index)?)? } else if src_index < left_len.checked_add(right_len).unwrap() { let right_idx = src_index.checked_sub(left_len).unwrap(); - this.read_immediate(&this.project_index(&right, right_idx)?.into())? + this.read_immediate(&this.project_index(&right, right_idx)?)? } else { span_bug!( this.cur_span(), "simd_shuffle index {src_index} is out of bounds for 2 vectors of size {left_len}", ); }; - this.write_immediate(*val, &dest.into())?; + this.write_immediate(*val, &dest)?; } } "gather" => { @@ -528,19 +528,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { assert_eq!(dest_len, mask_len); for i in 0..dest_len { - let passthru = - this.read_immediate(&this.project_index(&passthru, i)?.into())?; - let ptr = this.read_immediate(&this.project_index(&ptrs, i)?.into())?; - let mask = this.read_immediate(&this.project_index(&mask, i)?.into())?; + let passthru = this.read_immediate(&this.project_index(&passthru, i)?)?; + let ptr = this.read_immediate(&this.project_index(&ptrs, i)?)?; + let mask = this.read_immediate(&this.project_index(&mask, i)?)?; let dest = this.project_index(&dest, i)?; let val = if simd_element_to_bool(mask)? { - let place = this.deref_operand(&ptr.into())?; - this.read_immediate(&place.into())? + let place = this.deref_operand(&ptr)?; + this.read_immediate(&place)? } else { passthru }; - this.write_immediate(*val, &dest.into())?; + this.write_immediate(*val, &dest)?; } } "scatter" => { @@ -553,13 +552,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { assert_eq!(ptrs_len, mask_len); for i in 0..ptrs_len { - let value = this.read_immediate(&this.project_index(&value, i)?.into())?; - let ptr = this.read_immediate(&this.project_index(&ptrs, i)?.into())?; - let mask = this.read_immediate(&this.project_index(&mask, i)?.into())?; + let value = this.read_immediate(&this.project_index(&value, i)?)?; + let ptr = this.read_immediate(&this.project_index(&ptrs, i)?)?; + let mask = this.read_immediate(&this.project_index(&mask, i)?)?; if simd_element_to_bool(mask)? { - let place = this.deref_operand(&ptr.into())?; - this.write_immediate(*value, &place.into())?; + let place = this.deref_operand(&ptr)?; + this.write_immediate(*value, &place)?; } } } @@ -579,7 +578,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let mut res = 0u64; for i in 0..op_len { - let op = this.read_immediate(&this.project_index(&op, i.into())?.into())?; + let op = this.read_immediate(&this.project_index(&op, i.into())?)?; if simd_element_to_bool(op)? { res |= 1u64 .checked_shl(simd_bitmask_index(i, op_len, this.data_layout().endian)) @@ -589,7 +588,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // We have to force the place type to be an int so that we can write `res` into it. let mut dest = this.force_allocation(dest)?; dest.layout = this.machine.layouts.uint(dest.layout.size).unwrap(); - this.write_int(res, &dest.into())?; + this.write_int(res, &dest)?; } name => throw_unsup_format!("unimplemented intrinsic: `simd_{name}`"), diff --git a/src/tools/miri/src/shims/time.rs b/src/tools/miri/src/shims/time.rs index c761c45a5a1..6667c4d751f 100644 --- a/src/tools/miri/src/shims/time.rs +++ b/src/tools/miri/src/shims/time.rs @@ -158,7 +158,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { })?; this.write_scalar( Scalar::from_i64(qpc), - &this.deref_operand(lpPerformanceCount_op)?.into(), + &this.deref_operand(lpPerformanceCount_op)?, )?; Ok(Scalar::from_i32(-1)) // return non-zero on success } @@ -179,7 +179,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // and thus 10^9 counts per second. this.write_scalar( Scalar::from_i64(1_000_000_000), - &this.deref_operand_as(lpFrequency_op, this.machine.layouts.u64)?.into(), + &this.deref_operand_as(lpFrequency_op, this.machine.layouts.u64)?, )?; Ok(Scalar::from_i32(-1)) // Return non-zero on success } diff --git a/src/tools/miri/src/shims/unix/foreign_items.rs b/src/tools/miri/src/shims/unix/foreign_items.rs index 14297845d3d..5f3c15c5874 100644 --- a/src/tools/miri/src/shims/unix/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/foreign_items.rs @@ -201,14 +201,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { this.write_int(einval, dest)?; } else { if size == 0 { - this.write_null(&ret.into())?; + this.write_null(&ret)?; } else { let ptr = this.allocate_ptr( Size::from_bytes(size), Align::from_bytes(align).unwrap(), MiriMemoryKind::C.into(), )?; - this.write_pointer(ptr, &ret.into())?; + this.write_pointer(ptr, &ret)?; } this.write_null(dest)?; } @@ -293,7 +293,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // Create key and write it into the memory where `key_ptr` wants it. let key = this.machine.tls.create_tls_key(dtor, key_layout.size)?; - this.write_scalar(Scalar::from_uint(key, key_layout.size), &key_place.into())?; + this.write_scalar(Scalar::from_uint(key, key_layout.size), &key_place)?; // Return success (`0`). this.write_null(dest)?; @@ -508,7 +508,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let [_attr, guard_size] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; let guard_size = this.deref_operand(guard_size)?; let guard_size_layout = this.libc_ty_layout("size_t"); - this.write_scalar(Scalar::from_uint(this.machine.page_size, guard_size_layout.size), &guard_size.into())?; + this.write_scalar(Scalar::from_uint(this.machine.page_size, guard_size_layout.size), &guard_size)?; // Return success (`0`). this.write_null(dest)?; @@ -538,11 +538,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { this.write_scalar( Scalar::from_uint(this.machine.stack_addr, this.pointer_size()), - &addr_place.into(), + &addr_place, )?; this.write_scalar( Scalar::from_uint(this.machine.stack_size, this.pointer_size()), - &size_place.into(), + &size_place, )?; // Return success (`0`). @@ -587,20 +587,20 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // Reset all fields to `uninit` to make sure nobody reads them. // (This is a std-only shim so we are okay with such hacks.) - this.write_uninit(&pwd.into())?; + this.write_uninit(&pwd)?; // We only set the home_dir field. #[allow(deprecated)] let home_dir = std::env::home_dir().unwrap(); let (written, _) = this.write_path_to_c_str(&home_dir, buf, buflen)?; let pw_dir = this.project_field_named(&pwd, "pw_dir")?; - this.write_pointer(buf, &pw_dir.into())?; + this.write_pointer(buf, &pw_dir)?; if written { - this.write_pointer(pwd.ptr, &result.into())?; + this.write_pointer(pwd.ptr, &result)?; this.write_null(dest)?; } else { - this.write_null(&result.into())?; + this.write_null(&result)?; this.write_scalar(this.eval_libc("ERANGE"), dest)?; } } diff --git a/src/tools/miri/src/shims/unix/fs.rs b/src/tools/miri/src/shims/unix/fs.rs index 3da6c17f3b0..fe5b01e7610 100644 --- a/src/tools/miri/src/shims/unix/fs.rs +++ b/src/tools/miri/src/shims/unix/fs.rs @@ -1457,13 +1457,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { )?; let result_place = this.deref_operand(result_op)?; - this.write_scalar(this.read_scalar(entry_op)?, &result_place.into())?; + this.write_scalar(this.read_scalar(entry_op)?, &result_place)?; 0 } None => { // end of stream: return 0, assign *result=NULL - this.write_null(&this.deref_operand(result_op)?.into())?; + this.write_null(&this.deref_operand(result_op)?)?; 0 } Some(Err(e)) => diff --git a/src/tools/miri/src/shims/unix/linux/fd.rs b/src/tools/miri/src/shims/unix/linux/fd.rs index 9c43651132b..92966319f19 100644 --- a/src/tools/miri/src/shims/unix/linux/fd.rs +++ b/src/tools/miri/src/shims/unix/linux/fd.rs @@ -74,9 +74,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let event = this.deref_operand_as(event, this.libc_ty_layout("epoll_event"))?; let events = this.project_field(&event, 0)?; - let events = this.read_scalar(&events.into())?.to_u32()?; + let events = this.read_scalar(&events)?.to_u32()?; let data = this.project_field(&event, 1)?; - let data = this.read_scalar(&data.into())?; + let data = this.read_scalar(&data)?; let event = EpollEvent { events, data }; if let Some(epfd) = this.machine.file_handler.handles.get_mut(&epfd) { @@ -248,8 +248,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let sv1 = fh.insert_fd(Box::new(SocketPair)); let sv1 = ScalarInt::try_from_int(sv1, sv.layout.size).unwrap(); - this.write_scalar(sv0, &sv.into())?; - this.write_scalar(sv1, &sv.offset(sv.layout.size, sv.layout, this)?.into())?; + this.write_scalar(sv0, &sv)?; + this.write_scalar(sv1, &sv.offset(sv.layout.size, sv.layout, this)?)?; Ok(Scalar::from_i32(0)) } diff --git a/src/tools/miri/src/shims/unix/macos/foreign_items.rs b/src/tools/miri/src/shims/unix/macos/foreign_items.rs index 85b950da4fe..3673ca5aee3 100644 --- a/src/tools/miri/src/shims/unix/macos/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/macos/foreign_items.rs @@ -86,7 +86,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { "_NSGetEnviron" => { let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; this.write_pointer( - this.machine.env_vars.environ.expect("machine must be initialized").ptr, + this.machine.env_vars.environ.as_ref().expect("machine must be initialized").ptr, dest, )?; } @@ -133,7 +133,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let (written, size_needed) = this.write_path_to_c_str( &path, buf_ptr, - this.read_scalar(&bufsize.into())?.to_u32()?.into(), + this.read_scalar(&bufsize)?.to_u32()?.into(), )?; if written { @@ -141,7 +141,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } else { this.write_scalar( Scalar::from_u32(size_needed.try_into().unwrap()), - &bufsize.into(), + &bufsize, )?; this.write_int(-1, dest)?; } diff --git a/src/tools/miri/src/shims/unix/sync.rs b/src/tools/miri/src/shims/unix/sync.rs index 1fa0ffd8ee7..428581801d9 100644 --- a/src/tools/miri/src/shims/unix/sync.rs +++ b/src/tools/miri/src/shims/unix/sync.rs @@ -346,7 +346,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // This can always be revisited to have some external state to catch double-destroys // but not complain about the above code. See https://github.com/rust-lang/miri/pull/1933 this.write_uninit( - &this.deref_operand_as(attr_op, this.libc_ty_layout("pthread_mutexattr_t"))?.into(), + &this.deref_operand_as(attr_op, this.libc_ty_layout("pthread_mutexattr_t"))?, )?; Ok(0) @@ -500,7 +500,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // This might lead to false positives, see comment in pthread_mutexattr_destroy this.write_uninit( - &this.deref_operand_as(mutex_op, this.libc_ty_layout("pthread_mutex_t"))?.into(), + &this.deref_operand_as(mutex_op, this.libc_ty_layout("pthread_mutex_t"))?, )?; // FIXME: delete interpreter state associated with this mutex. @@ -625,7 +625,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // This might lead to false positives, see comment in pthread_mutexattr_destroy this.write_uninit( - &this.deref_operand_as(rwlock_op, this.libc_ty_layout("pthread_rwlock_t"))?.into(), + &this.deref_operand_as(rwlock_op, this.libc_ty_layout("pthread_rwlock_t"))?, )?; // FIXME: delete interpreter state associated with this rwlock. @@ -675,7 +675,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let this = self.eval_context_mut(); let clock_id = condattr_get_clock_id(this, attr_op)?; - this.write_scalar(Scalar::from_i32(clock_id), &this.deref_operand(clk_id_op)?.into())?; + this.write_scalar(Scalar::from_i32(clock_id), &this.deref_operand(clk_id_op)?)?; Ok(Scalar::from_i32(0)) } @@ -691,7 +691,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // This might lead to false positives, see comment in pthread_mutexattr_destroy this.write_uninit( - &this.deref_operand_as(attr_op, this.libc_ty_layout("pthread_condattr_t"))?.into(), + &this.deref_operand_as(attr_op, this.libc_ty_layout("pthread_condattr_t"))?, )?; Ok(0) @@ -868,7 +868,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // This might lead to false positives, see comment in pthread_mutexattr_destroy this.write_uninit( - &this.deref_operand_as(cond_op, this.libc_ty_layout("pthread_cond_t"))?.into(), + &this.deref_operand_as(cond_op, this.libc_ty_layout("pthread_cond_t"))?, )?; // FIXME: delete interpreter state associated with this condvar. diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index d64aa53ed95..2f95cfb8bab 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -125,7 +125,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { this.project_field_named(&io_status_block, "Information")?; this.write_scalar( Scalar::from_target_usize(n.into(), this), - &io_status_information.into(), + &io_status_information, )?; } // Return whether this was a success. >= 0 is success. diff --git a/src/tools/miri/src/shims/windows/sync.rs b/src/tools/miri/src/shims/windows/sync.rs index 172312e331a..5d5cf73797f 100644 --- a/src/tools/miri/src/shims/windows/sync.rs +++ b/src/tools/miri/src/shims/windows/sync.rs @@ -323,7 +323,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let layout = this.machine.layouts.uint(size).unwrap(); let futex_val = this .read_scalar_atomic(&MPlaceTy::from_aligned_ptr(ptr, layout), AtomicReadOrd::Relaxed)?; - let compare_val = this.read_scalar(&MPlaceTy::from_aligned_ptr(compare, layout).into())?; + let compare_val = this.read_scalar(&MPlaceTy::from_aligned_ptr(compare, layout))?; if futex_val == compare_val { // If the values are the same, we have to block. diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs index 92d2425cd3b..aa75b477473 100644 --- a/src/tools/rustfmt/src/parse/session.rs +++ b/src/tools/rustfmt/src/parse/session.rs @@ -152,18 +152,13 @@ fn default_handler( TerminalUrl::No, )) }; - Handler::with_emitter( - true, - None, - Box::new(SilentOnIgnoredFilesEmitter { - has_non_ignorable_parser_errors: false, - source_map, - emitter, - ignore_path_set, - can_reset, - }), - None, - ) + Handler::with_emitter(Box::new(SilentOnIgnoredFilesEmitter { + has_non_ignorable_parser_errors: false, + source_map, + emitter, + ignore_path_set, + can_reset, + })) } impl ParseSess { @@ -234,7 +229,7 @@ impl ParseSess { } pub(crate) fn set_silent_emitter(&mut self) { - self.parse_sess.span_diagnostic = Handler::with_emitter(true, None, silent_emitter(), None); + self.parse_sess.span_diagnostic = Handler::with_emitter(silent_emitter()); } pub(crate) fn span_to_filename(&self, span: Span) -> FileName { diff --git a/src/tools/rustfmt/src/test/mod.rs b/src/tools/rustfmt/src/test/mod.rs index cfad4a8ed0e..364aa225f68 100644 --- a/src/tools/rustfmt/src/test/mod.rs +++ b/src/tools/rustfmt/src/test/mod.rs @@ -838,6 +838,12 @@ fn handle_result( // Ignore LF and CRLF difference for Windows. if !string_eq_ignore_newline_repr(&fmt_text, &text) { + if let Some(bless) = std::env::var_os("BLESS") { + if bless != "0" { + std::fs::write(file_name, fmt_text).unwrap(); + continue; + } + } let diff = make_diff(&text, &fmt_text, DIFF_CONTEXT_SIZE); assert!( !diff.is_empty(), diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index bfb967213e1..57cbfe68be4 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -46,6 +46,7 @@ const EXCEPTIONS: &[(&str, &str)] = &[ ("instant", "BSD-3-Clause"), // rustc_driver/tracing-subscriber/parking_lot ("mdbook", "MPL-2.0"), // mdbook ("openssl", "Apache-2.0"), // opt-dist + ("rustc_apfloat", "Apache-2.0 WITH LLVM-exception"), // rustc (license is the same as LLVM uses) ("ryu", "Apache-2.0 OR BSL-1.0"), // cargo/... (because of serde) ("self_cell", "Apache-2.0"), // rustc (fluent translations) ("snap", "BSD-3-Clause"), // rustc @@ -224,6 +225,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "rustc-hash", "rustc-rayon", "rustc-rayon-core", + "rustc_apfloat", "rustc_version", "rustix", "ruzstd", // via object in thorin-dwp diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index d0257d71697..11480e2be60 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -302,10 +302,6 @@ pub fn check(path: &Path, bad: &mut bool) { return; } } - // apfloat shouldn't be changed because of license problems - if is_in(file, "compiler", "rustc_apfloat") { - return; - } let mut skip_cr = contains_ignore_directive(can_contain, &contents, "cr"); let mut skip_undocumented_unsafe = contains_ignore_directive(can_contain, &contents, "undocumented-unsafe"); |
