@@ -252,7 +252,9 @@ impl<'tcx, Tag: Provenance> ImmTy<'tcx, Tag> {
252
252
impl < ' mir , ' tcx : ' mir , M : Machine < ' mir , ' tcx > > InterpCx < ' mir , ' tcx , M > {
253
253
/// Try reading an immediate in memory; this is interesting particularly for `ScalarPair`.
254
254
/// Returns `None` if the layout does not permit loading this as a value.
255
- fn try_read_immediate_from_mplace (
255
+ ///
256
+ /// This is an internal function; call `read_immediate` instead.
257
+ fn read_immediate_from_mplace_raw (
256
258
& self ,
257
259
mplace : & MPlaceTy < ' tcx , M :: PointerTag > ,
258
260
force : bool ,
@@ -312,24 +314,25 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
312
314
return Ok ( None ) ;
313
315
}
314
316
315
- /// Try returning an immediate for the operand.
316
- /// If the layout does not permit loading this as an immediate, return where in memory
317
- /// we can find the data.
317
+ /// Try returning an immediate for the operand. If the layout does not permit loading this as an
318
+ /// immediate, return where in memory we can find the data.
318
319
/// Note that for a given layout, this operation will either always fail or always
319
320
/// succeed! Whether it succeeds depends on whether the layout can be represented
320
321
/// in an `Immediate`, not on which data is stored there currently.
321
322
///
322
323
/// If `force` is `true`, then even scalars with fields that can be ununit will be
323
324
/// read. This means the load is lossy and should not be written back!
324
325
/// This flag exists only for validity checking.
325
- pub fn try_read_immediate (
326
+ ///
327
+ /// This is an internal function that should not usually be used; call `read_immediate` instead.
328
+ pub fn read_immediate_raw (
326
329
& self ,
327
330
src : & OpTy < ' tcx , M :: PointerTag > ,
328
331
force : bool ,
329
332
) -> InterpResult < ' tcx , Result < ImmTy < ' tcx , M :: PointerTag > , MPlaceTy < ' tcx , M :: PointerTag > > > {
330
333
Ok ( match src. try_as_mplace ( ) {
331
334
Ok ( ref mplace) => {
332
- if let Some ( val) = self . try_read_immediate_from_mplace ( mplace, force) ? {
335
+ if let Some ( val) = self . read_immediate_from_mplace_raw ( mplace, force) ? {
333
336
Ok ( val)
334
337
} else {
335
338
Err ( * mplace)
@@ -345,7 +348,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
345
348
& self ,
346
349
op : & OpTy < ' tcx , M :: PointerTag > ,
347
350
) -> InterpResult < ' tcx , ImmTy < ' tcx , M :: PointerTag > > {
348
- if let Ok ( imm) = self . try_read_immediate ( op, /*force*/ false ) ? {
351
+ if let Ok ( imm) = self . read_immediate_raw ( op, /*force*/ false ) ? {
349
352
Ok ( imm)
350
353
} else {
351
354
span_bug ! ( self . cur_span( ) , "primitive read failed for type: {:?}" , op. layout. ty) ;
0 commit comments