@@ -24,17 +24,21 @@ Constant evaluation can be done by calling the `const_eval_*` queries of `TyCtxt
24
24
25
25
The ` const_eval_* ` queries use a [ ` ParamEnv ` ] ( ./param_env.html ) of environment
26
26
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
28
28
or static or of an ` Instance ` of a function and an index into the function's ` Promoted ` table.
29
29
30
30
Constant evaluation returns a [ ` ConstEvalResult ` ] with either the error, or the simplest
31
31
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_* `
35
35
functions cannot be used to create miri-pointers to the evaluated constant or
36
36
static. If you need that, you need to directly work with the functions in
37
37
[ ` src/librustc_mir/const_eval.rs ` ] .
38
38
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
39
43
[ `ConstEvalResult` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/interpret/error/type.ConstEvalResult.html
40
44
[ `src/librustc_mir/const_eval.rs` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/const_eval/index.html
0 commit comments