Support manual impl of fn traits in mir interpreter

This commit is contained in:
hkalbasi 2023-06-22 22:24:21 +03:30
parent 3a4f9a1416
commit 99a4f2e983
4 changed files with 78 additions and 4 deletions

View file

@ -1550,6 +1550,30 @@ fn closures() {
);
}
#[test]
fn manual_fn_trait_impl() {
check_number(
r#"
//- minicore: fn, copy
struct S(i32);
impl FnOnce<(i32, i32)> for S {
type Output = i32;
extern "rust-call" fn call_once(self, arg: (i32, i32)) -> i32 {
arg.0 + arg.1 + self.0
}
}
const GOAL: i32 = {
let s = S(1);
s(2, 3)
};
"#,
6,
);
}
#[test]
fn closure_and_impl_fn() {
check_number(

View file

@ -32,6 +32,7 @@ fn transmute() {
fn const_eval_select() {
check_number(
r#"
//- minicore: fn
extern "rust-intrinsic" {
pub fn const_eval_select<ARG, F, G, RET>(arg: ARG, called_in_const: F, called_at_rt: G) -> RET
where