Skip to content

Commit 1df9f44

Browse files
committed
typos + fmt
1 parent 069e84a commit 1df9f44

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

src/librustc_middle/mir/interpret/error.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,7 @@ impl fmt::Display for UnsupportedOpInfo {
522522
use UnsupportedOpInfo::*;
523523
match self {
524524
Unsupported(ref msg) => write!(f, "{}", msg),
525-
ReadExternStatic(did) => {
526-
write!(f, "cannot read from extern static ({:?})", did)
527-
}
525+
ReadExternStatic(did) => write!(f, "cannot read from extern static ({:?})", did),
528526
NoMirFor(did) => write!(f, "no MIR body is available for {:?}", did),
529527
ReadPointerAsBytes => write!(f, "unable to turn pointer into raw bytes",),
530528
ReadBytesAsPointer => write!(f, "unable to turn bytes into a pointer"),

src/librustc_mir/interpret/memory.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use std::fmt;
1313
use std::ptr;
1414

1515
use rustc_ast::ast::Mutability;
16-
use rustc_hir::def_id::DefId;
1716
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
17+
use rustc_hir::def_id::DefId;
1818
use rustc_middle::ty::{self, Instance, ParamEnv, TyCtxt};
1919
use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout};
2020

@@ -119,12 +119,8 @@ pub struct Memory<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
119119
pub tcx: TyCtxt<'tcx>,
120120
}
121121

122-
123122
/// Return the `tcx` allocation containing the initial value of the given static
124-
pub fn get_static(
125-
tcx: TyCtxt<'tcx>,
126-
def_id: DefId,
127-
) -> InterpResult<'tcx, &'tcx Allocation> {
123+
pub fn get_static(tcx: TyCtxt<'tcx>, def_id: DefId) -> InterpResult<'tcx, &'tcx Allocation> {
128124
trace!("get_static: Need to compute {:?}", def_id);
129125
let instance = Instance::mono(tcx, def_id);
130126
let gid = GlobalId { instance, promoted: None };
@@ -162,7 +158,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
162158
///
163159
/// This function can fail only if `ptr` points to an `extern static`.
164160
#[inline]
165-
pub fn global_base_pointer(&self, mut ptr: Pointer) -> InterpResult<'tcx, Pointer<M::PointerTag>> {
161+
pub fn global_base_pointer(
162+
&self,
163+
mut ptr: Pointer,
164+
) -> InterpResult<'tcx, Pointer<M::PointerTag>> {
166165
// We need to handle `extern static`.
167166
let ptr = match self.tcx.get_global_alloc(ptr.alloc_id) {
168167
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> {
197196
}
198197
};
199198
// Functions are global allocations, so make sure we get the right base pointer.
200-
// We know this is not an `extern static` so this cannmot fail.
199+
// We know this is not an `extern static` so this cannot fail.
201200
self.global_base_pointer(Pointer::from(id)).unwrap()
202201
}
203202

@@ -659,7 +658,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
659658
if ptr.offset.bytes() != 0 {
660659
throw_ub!(InvalidFunctionPointer(ptr.erase_tag()))
661660
}
662-
self.get_fn_alloc(ptr.alloc_id).ok_or_else(|| err_ub!(InvalidFunctionPointer(ptr.erase_tag())).into())
661+
self.get_fn_alloc(ptr.alloc_id)
662+
.ok_or_else(|| err_ub!(InvalidFunctionPointer(ptr.erase_tag())).into())
663663
}
664664

665665
pub fn mark_immutable(&mut self, id: AllocId) -> InterpResult<'tcx> {

src/librustc_mir/interpret/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub use rustc_middle::mir::interpret::*; // have all the `interpret` symbols in
2020
pub use self::eval_context::{Frame, InterpCx, LocalState, LocalValue, StackPopCleanup};
2121
pub use self::intern::{intern_const_alloc_recursive, InternKind};
2222
pub use self::machine::{compile_time_machine, AllocMap, Machine, MayLeak, StackPopJump};
23-
pub use self::memory::{AllocCheck, FnVal, Memory, MemoryKind, get_static};
23+
pub use self::memory::{get_static, AllocCheck, FnVal, Memory, MemoryKind};
2424
pub use self::operand::{ImmTy, Immediate, OpTy, Operand};
2525
pub use self::place::{MPlaceTy, MemPlace, MemPlaceMeta, Place, PlaceTy};
2626
pub use self::validity::RefTracking;

0 commit comments

Comments
 (0)