add comments
This commit is contained in:
parent
0055fb92db
commit
ca3ff832e3
4 changed files with 10 additions and 1 deletions
|
@ -272,7 +272,8 @@ pub(crate) fn eval_to_valtree<'tcx>(
|
||||||
|
|
||||||
/// Converts a `ValTree` to a `ConstValue`, which is needed after mir
|
/// Converts a `ValTree` to a `ConstValue`, which is needed after mir
|
||||||
/// construction has finished.
|
/// construction has finished.
|
||||||
// FIXME Merge `valtree_to_const_value` and `valtree_into_mplace` into one function
|
// FIXME(valtrees): Merge `valtree_to_const_value` and `valtree_into_mplace` into one function
|
||||||
|
// FIXME(valtrees): Accept `ty::Value` instead of `Ty` and `ty::ValTree` separately.
|
||||||
#[instrument(skip(tcx), level = "debug", ret)]
|
#[instrument(skip(tcx), level = "debug", ret)]
|
||||||
pub fn valtree_to_const_value<'tcx>(
|
pub fn valtree_to_const_value<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
|
|
@ -222,6 +222,8 @@ impl<'tcx> Const<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to convert to a value.
|
/// Attempts to convert to a value.
|
||||||
|
///
|
||||||
|
/// Note that this does not evaluate the constant.
|
||||||
pub fn try_to_value(self) -> Option<ty::Value<'tcx>> {
|
pub fn try_to_value(self) -> Option<ty::Value<'tcx>> {
|
||||||
match self.kind() {
|
match self.kind() {
|
||||||
ty::ConstKind::Value(cv) => Some(cv),
|
ty::ConstKind::Value(cv) => Some(cv),
|
||||||
|
@ -229,6 +231,10 @@ impl<'tcx> Const<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convenience method to extract the value of a usize constant,
|
||||||
|
/// useful to get the length of an array type.
|
||||||
|
///
|
||||||
|
/// Note that this does not evaluate the constant.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn try_to_target_usize(self, tcx: TyCtxt<'tcx>) -> Option<u64> {
|
pub fn try_to_target_usize(self, tcx: TyCtxt<'tcx>) -> Option<u64> {
|
||||||
self.try_to_value()?.try_to_target_usize(tcx)
|
self.try_to_value()?.try_to_target_usize(tcx)
|
||||||
|
|
|
@ -1785,6 +1785,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME(valtrees): Accept `ty::Value` instead of `Ty` and `ty::ValTree` separately.
|
||||||
fn pretty_print_const_valtree(
|
fn pretty_print_const_valtree(
|
||||||
&mut self,
|
&mut self,
|
||||||
valtree: ty::ValTree<'tcx>,
|
valtree: ty::ValTree<'tcx>,
|
||||||
|
|
|
@ -214,6 +214,7 @@ impl<'tcx> ConstToPat<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recursive helper for `to_pat`; invoke that (instead of calling this directly).
|
// Recursive helper for `to_pat`; invoke that (instead of calling this directly).
|
||||||
|
// FIXME(valtrees): Accept `ty::Value` instead of `Ty` and `ty::ValTree` separately.
|
||||||
#[instrument(skip(self), level = "debug")]
|
#[instrument(skip(self), level = "debug")]
|
||||||
fn valtree_to_pat(&self, cv: ValTree<'tcx>, ty: Ty<'tcx>) -> Box<Pat<'tcx>> {
|
fn valtree_to_pat(&self, cv: ValTree<'tcx>, ty: Ty<'tcx>) -> Box<Pat<'tcx>> {
|
||||||
let span = self.span;
|
let span = self.span;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue