Skip to content

Commit ab2eb92

Browse files
author
Lukas Markeffsky
committed
add comments
1 parent 0e75539 commit ab2eb92

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

Diff for: compiler/rustc_const_eval/src/const_eval/valtrees.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ pub(crate) fn eval_to_valtree<'tcx>(
272272

273273
/// Converts a `ValTree` to a `ConstValue`, which is needed after mir
274274
/// construction has finished.
275-
// FIXME Merge `valtree_to_const_value` and `valtree_into_mplace` into one function
275+
// FIXME(valtrees): Merge `valtree_to_const_value` and `valtree_into_mplace` into one function
276+
// FIXME(valtrees): Accept `ty::Value` instead of `Ty` and `ty::ValTree` separately.
276277
#[instrument(skip(tcx), level = "debug", ret)]
277278
pub fn valtree_to_const_value<'tcx>(
278279
tcx: TyCtxt<'tcx>,

Diff for: compiler/rustc_middle/src/ty/consts.rs

+6
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,19 @@ impl<'tcx> Const<'tcx> {
222222
}
223223

224224
/// Attempts to convert to a value.
225+
///
226+
/// Note that this does not evaluate the constant.
225227
pub fn try_to_value(self) -> Option<ty::Value<'tcx>> {
226228
match self.kind() {
227229
ty::ConstKind::Value(cv) => Some(cv),
228230
_ => None,
229231
}
230232
}
231233

234+
/// Convenience method to extract the value of a usize constant,
235+
/// useful to get the length of an array type.
236+
///
237+
/// Note that this does not evaluate the constant.
232238
#[inline]
233239
pub fn try_to_target_usize(self, tcx: TyCtxt<'tcx>) -> Option<u64> {
234240
self.try_to_value()?.try_to_target_usize(tcx)

Diff for: compiler/rustc_middle/src/ty/print/pretty.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1781,6 +1781,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
17811781
Ok(())
17821782
}
17831783

1784+
// FIXME(valtrees): Accept `ty::Value` instead of `Ty` and `ty::ValTree` separately.
17841785
fn pretty_print_const_valtree(
17851786
&mut self,
17861787
valtree: ty::ValTree<'tcx>,

Diff for: compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs

+1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ impl<'tcx> ConstToPat<'tcx> {
214214
}
215215

216216
// Recursive helper for `to_pat`; invoke that (instead of calling this directly).
217+
// FIXME(valtrees): Accept `ty::Value` instead of `Ty` and `ty::ValTree` separately.
217218
#[instrument(skip(self), level = "debug")]
218219
fn valtree_to_pat(&self, cv: ValTree<'tcx>, ty: Ty<'tcx>) -> Box<Pat<'tcx>> {
219220
let span = self.span;

0 commit comments

Comments
 (0)