few more
This commit is contained in:
parent
aff6c741d4
commit
b06d5b205c
3 changed files with 1 additions and 50 deletions
|
@ -1023,36 +1023,3 @@ pub fn promote_candidates<'tcx>(
|
|||
|
||||
promotions
|
||||
}
|
||||
|
||||
/// This function returns `true` if the function being called in the array
|
||||
/// repeat expression is a `const` function.
|
||||
pub fn is_const_fn_in_array_repeat_expression<'tcx>(
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
place: &Place<'tcx>,
|
||||
body: &Body<'tcx>,
|
||||
) -> bool {
|
||||
match place.as_local() {
|
||||
// rule out cases such as: `let my_var = some_fn(); [my_var; N]`
|
||||
Some(local) if body.local_decls[local].is_user_variable() => return false,
|
||||
None => return false,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
for block in body.basic_blocks.iter() {
|
||||
if let Some(Terminator { kind: TerminatorKind::Call { func, destination, .. }, .. }) =
|
||||
&block.terminator
|
||||
{
|
||||
if let Operand::Constant(box ConstOperand { const_, .. }) = func {
|
||||
if let ty::FnDef(def_id, _) = *const_.ty().kind() {
|
||||
if destination == place {
|
||||
if ccx.tcx.is_const_fn(def_id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue