File tree 4 files changed +10
-1
lines changed
rustc_const_eval/src/const_eval
rustc_mir_build/src/thir/pattern
4 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -272,7 +272,8 @@ pub(crate) fn eval_to_valtree<'tcx>(
272
272
273
273
/// Converts a `ValTree` to a `ConstValue`, which is needed after mir
274
274
/// 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.
276
277
#[ instrument( skip( tcx) , level = "debug" , ret) ]
277
278
pub fn valtree_to_const_value < ' tcx > (
278
279
tcx : TyCtxt < ' tcx > ,
Original file line number Diff line number Diff line change @@ -222,13 +222,19 @@ impl<'tcx> Const<'tcx> {
222
222
}
223
223
224
224
/// Attempts to convert to a value.
225
+ ///
226
+ /// Note that this does not evaluate the constant.
225
227
pub fn try_to_value ( self ) -> Option < ty:: Value < ' tcx > > {
226
228
match self . kind ( ) {
227
229
ty:: ConstKind :: Value ( cv) => Some ( cv) ,
228
230
_ => None ,
229
231
}
230
232
}
231
233
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.
232
238
#[ inline]
233
239
pub fn try_to_target_usize ( self , tcx : TyCtxt < ' tcx > ) -> Option < u64 > {
234
240
self . try_to_value ( ) ?. try_to_target_usize ( tcx)
Original file line number Diff line number Diff line change @@ -1781,6 +1781,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
1781
1781
Ok ( ( ) )
1782
1782
}
1783
1783
1784
+ // FIXME(valtrees): Accept `ty::Value` instead of `Ty` and `ty::ValTree` separately.
1784
1785
fn pretty_print_const_valtree (
1785
1786
& mut self ,
1786
1787
valtree : ty:: ValTree < ' tcx > ,
Original file line number Diff line number Diff line change @@ -214,6 +214,7 @@ impl<'tcx> ConstToPat<'tcx> {
214
214
}
215
215
216
216
// 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.
217
218
#[ instrument( skip( self ) , level = "debug" ) ]
218
219
fn valtree_to_pat ( & self , cv : ValTree < ' tcx > , ty : Ty < ' tcx > ) -> Box < Pat < ' tcx > > {
219
220
let span = self . span ;
You can’t perform that action at this time.
0 commit comments