Skip to content

Commit

Permalink
Update remap_mir_for_const_eval_select
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Jun 25, 2024
1 parent 6bc4527 commit 8138504
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ fn remap_mir_for_const_eval_select<'tcx>(
} if let ty::FnDef(def_id, _) = *const_.ty().kind()
&& tcx.is_intrinsic(def_id, sym::const_eval_select) =>
{
let [tupled_args, called_in_const, called_at_rt]: [_; 3] =
std::mem::take(args).try_into().unwrap();
let Ok([tupled_args, called_in_const, called_at_rt]) = take_array(args) else {
unreachable!()
};
let ty = tupled_args.node.ty(&body.local_decls, tcx);
let fields = ty.tuple_fields();
let num_args = fields.len();
Expand Down Expand Up @@ -137,6 +138,11 @@ fn remap_mir_for_const_eval_select<'tcx>(
body
}

fn take_array<T, const N: usize>(b: &mut Box<[T]>) -> Result<[T; N], Box<[T]>> {
let b: Box<[T; N]> = std::mem::take(b).try_into()?;
Ok(*b)
}

memoize!(
pub fn analysis_mir<'tcx>(cx: &AnalysisCtxt<'tcx>, def_id: DefId) -> &'tcx Body<'tcx> {
if let Some(local_def_id) = def_id.as_local() {
Expand Down

0 comments on commit 8138504

Please sign in to comment.