Skip to content

Commit 3a79ba5

Browse files
committed
fix related miri variables
rename variables like below - Value => ConstValue - PrimVal => Scalar - Value::ByVal => ConstValue::Scalar - Value::ByValPair => ConstValue::ScalarPair
1 parent 2c5ff55 commit 3a79ba5

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/const-eval.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ used) and a `GlobalId`. The `GlobalId` is made up of an
3030

3131
Constant evaluation returns a `Result` with either the error, or the simplest
3232
representation of the constant. "simplest" meaning if it is representable as an
33-
integer or fat pointer, it will directly yield the value (via `Value::ByVal` or
34-
`Value::ByValPair`), instead of referring to the [`miri`](./miri.html) virtual
35-
memory allocation (via `Value::ByRef`). This means that the `const_eval`
33+
integer or fat pointer, it will directly yield the value (via `ConstValue::Scalar` or
34+
`ConstValue::ScalarPair`), instead of referring to the [`miri`](./miri.html) virtual
35+
memory allocation (via `ConstValue::ByRef`). This means that the `const_eval`
3636
function cannot be used to create miri-pointers to the evaluated constant or
3737
static. If you need that, you need to directly work with the functions in
3838
[src/librustc_mir/const_eval.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/const_eval/index.html).

src/miri.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@ Before the evaluation, a virtual memory location (in this case essentially a
5555
`vec![u8; 4]` or `vec![u8; 8]`) is created for storing the evaluation result.
5656

5757
At the start of the evaluation, `_0` and `_1` are
58-
`Value::ByVal(PrimVal::Undef)`. When the initialization of `_1` is invoked, the
58+
`ConstValue::Scalar(Scalar::Undef)`. When the initialization of `_1` is invoked, the
5959
value of the `FOO` constant is required, and triggers another call to
6060
`tcx.const_eval`, which will not be shown here. If the evaluation of FOO is
6161
successful, 42 will be subtracted by its value `4096` and the result stored in
62-
`_1` as `Value::ByValPair(PrimVal::Bytes(4054), PrimVal::Bytes(0))`. The first
62+
`_1` as `ConstValue::ScalarPair(Scalar::Bytes(4054), Scalar::Bytes(0))`. The first
6363
part of the pair is the computed value, the second part is a bool that's true if
6464
an overflow happened.
6565

6666
The next statement asserts that said boolean is `0`. In case the assertion
6767
fails, its error message is used for reporting a compile-time error.
6868

69-
Since it does not fail, `Value::ByVal(PrimVal::Bytes(4054))` is stored in the
69+
Since it does not fail, `ConstValue::Scalar(Scalar::Bytes(4054))` is stored in the
7070
virtual memory was allocated before the evaluation. `_0` always refers to that
7171
location directly.
7272

@@ -75,23 +75,23 @@ After the evaluation is done, the virtual memory allocation is interned into the
7575
miri, but just extract the value from the interned allocation.
7676

7777
The `tcx.const_eval` function has one additional feature: it will not return a
78-
`ByRef(interned_allocation_id)`, but a `ByVal(computed_value)` if possible. This
78+
`ByRef(interned_allocation_id)`, but a `Scalar(computed_value)` if possible. This
7979
makes using the result much more convenient, as no further queries need to be
8080
executed in order to get at something as simple as a `usize`.
8181

8282
## Datastructures
8383

8484
Miri's core datastructures can be found in
8585
[librustc/mir/interpret](https://github.com/rust-lang/rust/blob/master/src/librustc/mir/interpret).
86-
This is mainly the error enum and the `Value` and `PrimVal` types. A `Value` can
87-
be either `ByVal` (a single `PrimVal`), `ByValPair` (two `PrimVal`s, usually fat
86+
This is mainly the error enum and the `ConstValue` and `Scalar` types. A `ConstValue` can
87+
be either `Scalar` (a single `Scalar`), `ScalarPair` (two `Scalar`s, usually fat
8888
pointers or two element tuples) or `ByRef`, which is used for anything else and
8989
refers to a virtual allocation. These allocations can be accessed via the
9090
methods on `tcx.interpret_interner`.
9191

9292
If you are expecting a numeric result, you can use `unwrap_u64` (panics on
9393
anything that can't be representad as a `u64`) or `to_raw_bits` which results
94-
in an `Option<u128>` yielding the `ByVal` if possible.
94+
in an `Option<u128>` yielding the `Scalar` if possible.
9595

9696
## Allocations
9797

@@ -113,7 +113,7 @@ to a pointer to `b`.
113113
Although the main entry point to constant evaluation is the `tcx.const_eval`
114114
query, there are additional functions in
115115
[librustc_mir/const_eval.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/const_eval/index.html)
116-
that allow accessing the fields of a `Value` (`ByRef` or otherwise). You should
116+
that allow accessing the fields of a `ConstValue` (`ByRef` or otherwise). You should
117117
never have to access an `Allocation` directly except for translating it to the
118118
compilation target (at the moment just LLVM).
119119

0 commit comments

Comments
 (0)