Skip to content

Commit a8623d1

Browse files
committed
fixup! Update docs related to const-eval
1 parent 4386a2c commit a8623d1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/const-eval.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,21 @@ Constant evaluation can be done by calling the `const_eval_*` queries of `TyCtxt
2424

2525
The `const_eval_*` queries use a [`ParamEnv`](./param_env.html) of environment
2626
in which the constant is evaluated (e.g. the function within which the constant is used)
27-
and a `GlobalId`. The `GlobalId` is made up of an `Instance` referring to a constant
27+
and a [`GlobalId`]. The `GlobalId` is made up of an `Instance` referring to a constant
2828
or static or of an `Instance` of a function and an index into the function's `Promoted` table.
2929

3030
Constant evaluation returns a [`ConstEvalResult`] with either the error, or the simplest
3131
representation of the constant. "simplest" meaning if it is representable as an
32-
integer or fat pointer, it will directly yield the value (via `ConstValue::Scalar` or
33-
`ConstValue::Slice`), instead of referring to the [`miri`](./miri.html) virtual
34-
memory allocation (via `ConstValue::ByRef`). This means that the `const_eval_*`
32+
integer or fat pointer, it will directly yield the value (via [`ConstValue::Scalar`]
33+
or [`ConstValue::Slice`]), instead of referring to the [`miri`](./miri.html) virtual
34+
memory allocation (via [`ConstValue::ByRef`]). This means that the `const_eval_*`
3535
functions cannot be used to create miri-pointers to the evaluated constant or
3636
static. If you need that, you need to directly work with the functions in
3737
[`src/librustc_mir/const_eval.rs`].
3838

39+
[`GlobalId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/interpret/struct.GlobalId.html
40+
[`ConstValue::Scalar`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/interpret/value/enum.ConstValue.html#variant.Scalar
41+
[`ConstValue::Slice`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/interpret/value/enum.ConstValue.html#variant.Slice
42+
[`ConstValue::ByRef`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/interpret/value/enum.ConstValue.html#variant.ByRef
3943
[`ConstEvalResult`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/interpret/error/type.ConstEvalResult.html
4044
[`src/librustc_mir/const_eval.rs`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/const_eval/index.html

0 commit comments

Comments
 (0)