mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Support manual impl of fn traits in mir interpreter
This commit is contained in:
parent
3a4f9a1416
commit
99a4f2e983
4 changed files with 78 additions and 4 deletions
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue