From efb231cc18b9d63a72879e4f4eed82525939307c Mon Sep 17 00:00:00 2001 From: Per Lindgren <per.lindgren@ltu.se> Date: Thu, 24 Sep 2020 20:48:06 +0200 Subject: [PATCH] borrow check, wip4 --- examples/borrow2.rs | 2 +- examples/borrow3.rs | 7 +++++++ tests/test_check.rs | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 examples/borrow3.rs diff --git a/examples/borrow2.rs b/examples/borrow2.rs index 3adba68..f84101e 100644 --- a/examples/borrow2.rs +++ b/examples/borrow2.rs @@ -1,5 +1,5 @@ fn f(a: &i32, b: &mut i32) {} fn main() { let mut a = 1; - f(&a, &mut a) + f(&mut a, &mut a) } diff --git a/examples/borrow3.rs b/examples/borrow3.rs new file mode 100644 index 0000000..f2aac53 --- /dev/null +++ b/examples/borrow3.rs @@ -0,0 +1,7 @@ +fn f(a: &i32, b: &mut i32) {} +fn main() { + let mut a = 1; + let b = &mut a; + let c = &mut a; + let d = *b + *c; +} diff --git a/tests/test_check.rs b/tests/test_check.rs index 484e5c8..c62dd64 100644 --- a/tests/test_check.rs +++ b/tests/test_check.rs @@ -180,3 +180,8 @@ fn borrow() { fn borrow2() { check(&read_file::parse("examples/borrow2.rs")).unwrap(); } + +#[test] +fn borrow3() { + check(&read_file::parse("examples/borrow3.rs")).unwrap(); +} -- GitLab