@@ -37,6 +37,14 @@ const DETECTOR_SNAPSHOT_PERIOD: isize = 256;
37
37
38
38
/// Warning: do not use this function if you expect to start interpreting the given `Mir`.
39
39
/// The `EvalContext` is only meant to be used to query values from constants and statics.
40
+ ///
41
+ /// This function is used during const propagation. We cannot use `mk_eval_cx`, because copy
42
+ /// propagation happens *during* the computation of the MIR of the current function. So if we
43
+ /// tried to call the `optimized_mir` query, we'd get a cycle error because we are (transitively)
44
+ /// inside the `optimized_mir` query of the `Instance` given.
45
+ ///
46
+ /// Since we are looking at the MIR of the function in an abstract manner, we don't have a
47
+ /// `ParamEnv` available to us. This function creates a `ParamEnv` for the given instance.
40
48
pub fn mk_borrowck_eval_cx < ' a , ' mir , ' tcx > (
41
49
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
42
50
instance : Instance < ' tcx > ,
@@ -78,6 +86,11 @@ fn mk_eval_cx_inner<'a, 'mir, 'tcx>(
78
86
/// Warning: do not use this function if you expect to start interpreting the given `Mir`.
79
87
/// The `EvalContext` is only meant to be used to do field and index projections into constants for
80
88
/// `simd_shuffle` and const patterns in match arms.
89
+ ///
90
+ /// The function containing the `match` that is currently being analyzed may have generic bounds
91
+ /// that inform us about the generic bounds of the constant. E.g. using an associated constant
92
+ /// of a function's generic parameter will require knowledge about the bounds on the generic
93
+ /// parameter.
81
94
fn mk_eval_cx < ' a , ' tcx > (
82
95
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
83
96
instance : Instance < ' tcx > ,
0 commit comments