From 1df9f44db7e0be3122335d961c3aa3542c923c7d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 26 Jul 2020 15:45:09 +0200 Subject: [PATCH] typos + fmt --- src/librustc_middle/mir/interpret/error.rs | 4 +--- src/librustc_mir/interpret/memory.rs | 18 +++++++++--------- src/librustc_mir/interpret/mod.rs | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/librustc_middle/mir/interpret/error.rs b/src/librustc_middle/mir/interpret/error.rs index ff6284e75db81..1d76bb525ebf4 100644 --- a/src/librustc_middle/mir/interpret/error.rs +++ b/src/librustc_middle/mir/interpret/error.rs @@ -522,9 +522,7 @@ impl fmt::Display for UnsupportedOpInfo { use UnsupportedOpInfo::*; match self { Unsupported(ref msg) => write!(f, "{}", msg), - ReadExternStatic(did) => { - write!(f, "cannot read from extern static ({:?})", did) - } + ReadExternStatic(did) => write!(f, "cannot read from extern static ({:?})", did), NoMirFor(did) => write!(f, "no MIR body is available for {:?}", did), ReadPointerAsBytes => write!(f, "unable to turn pointer into raw bytes",), ReadBytesAsPointer => write!(f, "unable to turn bytes into a pointer"), diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 4dbaafe4a21d5..6867a299d81bf 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -13,8 +13,8 @@ use std::fmt; use std::ptr; use rustc_ast::ast::Mutability; -use rustc_hir::def_id::DefId; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_hir::def_id::DefId; use rustc_middle::ty::{self, Instance, ParamEnv, TyCtxt}; use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout}; @@ -119,12 +119,8 @@ pub struct Memory<'mir, 'tcx, M: Machine<'mir, 'tcx>> { pub tcx: TyCtxt<'tcx>, } - /// Return the `tcx` allocation containing the initial value of the given static -pub fn get_static( - tcx: TyCtxt<'tcx>, - def_id: DefId, -) -> InterpResult<'tcx, &'tcx Allocation> { +pub fn get_static(tcx: TyCtxt<'tcx>, def_id: DefId) -> InterpResult<'tcx, &'tcx Allocation> { trace!("get_static: Need to compute {:?}", def_id); let instance = Instance::mono(tcx, def_id); let gid = GlobalId { instance, promoted: None }; @@ -162,7 +158,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { /// /// This function can fail only if `ptr` points to an `extern static`. #[inline] - pub fn global_base_pointer(&self, mut ptr: Pointer) -> InterpResult<'tcx, Pointer> { + pub fn global_base_pointer( + &self, + mut ptr: Pointer, + ) -> InterpResult<'tcx, Pointer> { // We need to handle `extern static`. let ptr = match self.tcx.get_global_alloc(ptr.alloc_id) { Some(GlobalAlloc::Static(def_id)) if self.tcx.is_thread_local_static(def_id) => { @@ -197,7 +196,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { } }; // Functions are global allocations, so make sure we get the right base pointer. - // We know this is not an `extern static` so this cannmot fail. + // We know this is not an `extern static` so this cannot fail. self.global_base_pointer(Pointer::from(id)).unwrap() } @@ -659,7 +658,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { if ptr.offset.bytes() != 0 { throw_ub!(InvalidFunctionPointer(ptr.erase_tag())) } - self.get_fn_alloc(ptr.alloc_id).ok_or_else(|| err_ub!(InvalidFunctionPointer(ptr.erase_tag())).into()) + self.get_fn_alloc(ptr.alloc_id) + .ok_or_else(|| err_ub!(InvalidFunctionPointer(ptr.erase_tag())).into()) } pub fn mark_immutable(&mut self, id: AllocId) -> InterpResult<'tcx> { diff --git a/src/librustc_mir/interpret/mod.rs b/src/librustc_mir/interpret/mod.rs index 04a2c3baef4bf..5de9b502a37c4 100644 --- a/src/librustc_mir/interpret/mod.rs +++ b/src/librustc_mir/interpret/mod.rs @@ -20,7 +20,7 @@ pub use rustc_middle::mir::interpret::*; // have all the `interpret` symbols in pub use self::eval_context::{Frame, InterpCx, LocalState, LocalValue, StackPopCleanup}; pub use self::intern::{intern_const_alloc_recursive, InternKind}; pub use self::machine::{compile_time_machine, AllocMap, Machine, MayLeak, StackPopJump}; -pub use self::memory::{AllocCheck, FnVal, Memory, MemoryKind, get_static}; +pub use self::memory::{get_static, AllocCheck, FnVal, Memory, MemoryKind}; pub use self::operand::{ImmTy, Immediate, OpTy, Operand}; pub use self::place::{MPlaceTy, MemPlace, MemPlaceMeta, Place, PlaceTy}; pub use self::validity::RefTracking;