From b93839408c9f35cd8497d1de5b48639eb8ae7f8d Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 23 May 2012 06:13:54 -0700 Subject: [PATCH] new test --- .../borrowck-unchecked-with-borrow.rs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/test/compile-fail/borrowck-unchecked-with-borrow.rs diff --git a/src/test/compile-fail/borrowck-unchecked-with-borrow.rs b/src/test/compile-fail/borrowck-unchecked-with-borrow.rs new file mode 100644 index 00000000000..2a5447e874b --- /dev/null +++ b/src/test/compile-fail/borrowck-unchecked-with-borrow.rs @@ -0,0 +1,33 @@ +// xfail-fast (compile-flags unsupported on windows) +// compile-flags:--borrowck=err + +fn impure(_i: int) {} + +fn foo(v: &const option) { + alt *v { + some(i) { + //!^ NOTE pure context is required due to an illegal borrow: enum variant in aliasable, mutable location + // check that unchecked alone does not override borrowck: + unchecked { + impure(i); //! ERROR access to non-pure functions prohibited in a pure context + } + } + none { + } + } +} + +fn bar(v: &const option) { + alt *v { + some(i) { + unsafe { + impure(i); + } + } + none { + } + } +} + +fn main() { +} \ No newline at end of file