Skip to content

Commit fc5df1d

Browse files
committed
renaming err to err_unsup
1 parent b60a336 commit fc5df1d

File tree

18 files changed

+73
-63
lines changed

18 files changed

+73
-63
lines changed

src/librustc/mir/interpret/allocation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
244244
Ok(&self.get_bytes(cx, ptr, size_with_null)?[..size])
245245
}
246246
// This includes the case where `offset` is out-of-bounds to begin with.
247-
None => throw_err!(UnterminatedCString(ptr.erase_tag())),
247+
None => throw_err_unsup!(UnterminatedCString(ptr.erase_tag())),
248248
}
249249
}
250250

@@ -446,7 +446,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
446446
if self.relocations(cx, ptr, size).is_empty() {
447447
Ok(())
448448
} else {
449-
throw_err!(ReadPointerAsBytes)
449+
throw_err_unsup!(ReadPointerAsBytes)
450450
}
451451
}
452452

@@ -516,7 +516,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
516516
self.undef_mask.is_range_defined(
517517
ptr.offset,
518518
ptr.offset + size,
519-
).or_else(|idx| throw_err!(ReadUndefBytes(idx)))
519+
).or_else(|idx| throw_err_unsup!(ReadUndefBytes(idx)))
520520
}
521521

522522
pub fn mark_definedness(

src/librustc/mir/interpret/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ pub fn struct_error<'tcx>(tcx: TyCtxtAt<'tcx>, msg: &str) -> DiagnosticBuilder<'
184184
/// Packages the kind of error we got from the const code interpreter
185185
/// up with a Rust-level backtrace of where the error occured.
186186
/// Thsese should always be constructed by calling `.into()` on
187-
/// a `InterpError`. In `librustc_mir::interpret`, we have the `throw_err!`
188-
/// macro for this.
187+
/// a `InterpError`. In `librustc_mir::interpret`, we have `throw_err_*`
188+
/// macros for this.
189189
#[derive(Debug, Clone)]
190190
pub struct InterpErrorInfo<'tcx> {
191191
pub kind: InterpError<'tcx>,

src/librustc/mir/interpret/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! An interpreter for MIR used in CTFE and by miri
22
33
#[macro_export]
4-
macro_rules! throw_err {
4+
macro_rules! throw_err_unsup {
55
($($tt:tt)*) => {
66
Err($crate::mir::interpret::InterpError::Unsupported(
77
$crate::mir::interpret::UnsupportedOpInfo::$($tt)*
@@ -55,7 +55,7 @@ macro_rules! err_inval {
5555
}
5656

5757
#[macro_export]
58-
macro_rules! err {
58+
macro_rules! err_unsup {
5959
($($tt:tt)*) => {
6060
$crate::mir::interpret::InterpError::Unsupported(
6161
$crate::mir::interpret::UnsupportedOpInfo::$($tt)*

src/librustc/mir/interpret/pointer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<'tcx, Tag> Pointer<Tag> {
196196
msg: CheckInAllocMsg,
197197
) -> InterpResult<'tcx, ()> {
198198
if self.offset > allocation_size {
199-
throw_err!(PointerOutOfBounds { ptr: self.erase_tag(), msg, allocation_size })
199+
throw_err_unsup!(PointerOutOfBounds { ptr: self.erase_tag(), msg, allocation_size })
200200
} else {
201201
Ok(())
202202
}

src/librustc/mir/interpret/value.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ impl<'tcx, Tag> Scalar<Tag> {
360360
Scalar::check_data(data, size);
361361
Ok(data)
362362
}
363-
Scalar::Ptr(_) => throw_err!(ReadPointerAsBytes),
363+
Scalar::Ptr(_) => throw_err_unsup!(ReadPointerAsBytes),
364364
}
365365
}
366366

@@ -373,8 +373,8 @@ impl<'tcx, Tag> Scalar<Tag> {
373373
#[inline]
374374
pub fn to_ptr(self) -> InterpResult<'tcx, Pointer<Tag>> {
375375
match self {
376-
Scalar::Raw { data: 0, .. } => throw_err!(InvalidNullPointerUsage),
377-
Scalar::Raw { .. } => throw_err!(ReadBytesAsPointer),
376+
Scalar::Raw { data: 0, .. } => throw_err_unsup!(InvalidNullPointerUsage),
377+
Scalar::Raw { .. } => throw_err_unsup!(ReadBytesAsPointer),
378378
Scalar::Ptr(p) => Ok(p),
379379
}
380380
}
@@ -406,15 +406,15 @@ impl<'tcx, Tag> Scalar<Tag> {
406406
match self {
407407
Scalar::Raw { data: 0, size: 1 } => Ok(false),
408408
Scalar::Raw { data: 1, size: 1 } => Ok(true),
409-
_ => throw_err!(InvalidBool),
409+
_ => throw_err_unsup!(InvalidBool),
410410
}
411411
}
412412

413413
pub fn to_char(self) -> InterpResult<'tcx, char> {
414414
let val = self.to_u32()?;
415415
match ::std::char::from_u32(val) {
416416
Some(c) => Ok(c),
417-
None => throw_err!(InvalidChar(val as u128)),
417+
None => throw_err_unsup!(InvalidChar(val as u128)),
418418
}
419419
}
420420

@@ -537,7 +537,7 @@ impl<'tcx, Tag> ScalarMaybeUndef<Tag> {
537537
pub fn not_undef(self) -> InterpResult<'static, Scalar<Tag>> {
538538
match self {
539539
ScalarMaybeUndef::Scalar(scalar) => Ok(scalar),
540-
ScalarMaybeUndef::Undef => throw_err!(ReadUndefBytes(Size::from_bytes(0))),
540+
ScalarMaybeUndef::Undef => throw_err_unsup!(ReadUndefBytes(Size::from_bytes(0))),
541541
}
542542
}
543543

src/librustc_mir/const_eval.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
352352
ecx.goto_block(ret)?; // fully evaluated and done
353353
Ok(None)
354354
} else {
355-
throw_err!(MachineError(format!("calling non-const function `{}`", instance)))
355+
throw_err_unsup!(
356+
MachineError(format!("calling non-const function `{}`", instance))
357+
)
356358
};
357359
}
358360
}
@@ -412,7 +414,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
412414
_tcx: TyCtxt<'tcx>,
413415
_def_id: DefId,
414416
) -> InterpResult<'tcx, Cow<'tcx, Allocation<Self::PointerTag>>> {
415-
throw_err!(ReadForeignStatic)
417+
throw_err_unsup!(ReadForeignStatic)
416418
}
417419

418420
#[inline(always)]

src/librustc_mir/interpret/cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
199199
},
200200

201201
// Casts to bool are not permitted by rustc, no need to handle them here.
202-
_ => throw_err!(Unimplemented(format!("int to {:?} cast", dest_layout.ty))),
202+
_ => throw_err_unsup!(Unimplemented(format!("int to {:?} cast", dest_layout.ty))),
203203
}
204204
}
205205

src/librustc_mir/interpret/eval_context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub enum LocalValue<Tag=(), Id=AllocId> {
135135
impl<'tcx, Tag: Copy + 'static> LocalState<'tcx, Tag> {
136136
pub fn access(&self) -> InterpResult<'tcx, Operand<Tag>> {
137137
match self.value {
138-
LocalValue::Dead => throw_err!(DeadLocal),
138+
LocalValue::Dead => throw_err_unsup!(DeadLocal),
139139
LocalValue::Uninitialized =>
140140
bug!("The type checker should prevent reading from a never-written local"),
141141
LocalValue::Live(val) => Ok(val),
@@ -148,7 +148,7 @@ impl<'tcx, Tag: Copy + 'static> LocalState<'tcx, Tag> {
148148
&mut self,
149149
) -> InterpResult<'tcx, Result<&mut LocalValue<Tag>, MemPlace<Tag>>> {
150150
match self.value {
151-
LocalValue::Dead => throw_err!(DeadLocal),
151+
LocalValue::Dead => throw_err_unsup!(DeadLocal),
152152
LocalValue::Live(Operand::Indirect(mplace)) => Ok(Err(mplace)),
153153
ref mut local @ LocalValue::Live(Operand::Immediate(_)) |
154154
ref mut local @ LocalValue::Uninitialized => {
@@ -346,7 +346,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
346346
ty::InstanceDef::Item(def_id) => if self.tcx.is_mir_available(did) {
347347
Ok(self.tcx.optimized_mir(did))
348348
} else {
349-
throw_err!(NoMirFor(self.tcx.def_path_str(def_id)))
349+
throw_err_unsup!(NoMirFor(self.tcx.def_path_str(def_id)))
350350
},
351351
_ => Ok(self.tcx.instance_mir(instance)),
352352
}

src/librustc_mir/interpret/intern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ pub fn intern_const_alloc_recursive(
328328
}
329329
} else if ecx.memory().dead_alloc_map.contains_key(&alloc_id) {
330330
// dangling pointer
331-
return throw_err!(
331+
return throw_err_unsup!(
332332
ValidationFailure("encountered dangling pointer in final constant".into())
333333
)
334334
}

src/librustc_mir/interpret/intrinsics.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
104104
};
105105
let out_val = if intrinsic_name.ends_with("_nonzero") {
106106
if bits == 0 {
107-
return throw_err!(Intrinsic(format!("{} called on 0", intrinsic_name)));
107+
return throw_err_unsup!(
108+
Intrinsic(format!("{} called on 0", intrinsic_name))
109+
);
108110
}
109111
numeric_intrinsic(intrinsic_name.trim_end_matches("_nonzero"), bits, kind)?
110112
} else {
@@ -190,7 +192,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
190192
if overflowed {
191193
let layout = self.layout_of(substs.type_at(0))?;
192194
let r_val = r.to_scalar()?.to_bits(layout.size)?;
193-
return throw_err!(Intrinsic(
195+
return throw_err_unsup!(Intrinsic(
194196
format!("Overflowing shift by {} in {}", r_val, intrinsic_name),
195197
));
196198
}

0 commit comments

Comments
 (0)