From 4504df751448dce8427ac244d07dfecc020319b7 Mon Sep 17 00:00:00 2001 From: Jacob Clark Date: Tue, 7 Jun 2016 11:38:32 +0100 Subject: [PATCH 1/3] Test case for borrowk ICE #25579 --- src/test/run-pass/issue-25579.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/test/run-pass/issue-25579.rs diff --git a/src/test/run-pass/issue-25579.rs b/src/test/run-pass/issue-25579.rs new file mode 100644 index 0000000000000..53fe67cfc5aae --- /dev/null +++ b/src/test/run-pass/issue-25579.rs @@ -0,0 +1,27 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Sexpression { + Num(()), + Cons(&'static mut Sexpression) +} + +fn causes_ice(mut l: &mut Sexpression) +{ + loop { match l { + &mut Sexpression::Num(ref mut n) => {}, + &mut Sexpression::Cons(ref mut expr) => { + l = &mut **expr; + } + }} +} + +fn main() { +} From 0379493bd9def567b73f105319495e9ca106deca Mon Sep 17 00:00:00 2001 From: Jacob Clark Date: Tue, 7 Jun 2016 12:35:41 +0100 Subject: [PATCH 2/3] Resolving build failure --- src/test/{run-pass => compile-fail}/issue-25579.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename src/test/{run-pass => compile-fail}/issue-25579.rs (60%) diff --git a/src/test/run-pass/issue-25579.rs b/src/test/compile-fail/issue-25579.rs similarity index 60% rename from src/test/run-pass/issue-25579.rs rename to src/test/compile-fail/issue-25579.rs index 53fe67cfc5aae..95b07b208d15b 100644 --- a/src/test/run-pass/issue-25579.rs +++ b/src/test/compile-fail/issue-25579.rs @@ -9,19 +9,19 @@ // except according to those terms. enum Sexpression { - Num(()), - Cons(&'static mut Sexpression) + Num(()), + Cons(&'static mut Sexpression) } -fn causes_ice(mut l: &mut Sexpression) -{ +fn causes_ice(mut l: &mut Sexpression) { loop { match l { &mut Sexpression::Num(ref mut n) => {}, - &mut Sexpression::Cons(ref mut expr) => { - l = &mut **expr; + &mut Sexpression::Cons(ref mut expr) => { //~ ERROR cannot borrow `l.0` as mutable more than once at a time [E0499] + //~| ERROR cannot borrow `l.0` as mutable more than once at a time [E0499] + l = &mut **expr; //~ ERROR cannot assign to `l` because it is borrowed [E0506] } }} } fn main() { -} +} \ No newline at end of file From 4c5f3a6d65247cafc44cf676111770899daa1c0f Mon Sep 17 00:00:00 2001 From: Jacob Clark Date: Wed, 8 Jun 2016 13:26:18 +0100 Subject: [PATCH 3/3] Resolving line length build fail --- src/test/compile-fail/issue-25579.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/compile-fail/issue-25579.rs b/src/test/compile-fail/issue-25579.rs index 95b07b208d15b..849c9aa18c905 100644 --- a/src/test/compile-fail/issue-25579.rs +++ b/src/test/compile-fail/issue-25579.rs @@ -16,12 +16,12 @@ enum Sexpression { fn causes_ice(mut l: &mut Sexpression) { loop { match l { &mut Sexpression::Num(ref mut n) => {}, - &mut Sexpression::Cons(ref mut expr) => { //~ ERROR cannot borrow `l.0` as mutable more than once at a time [E0499] - //~| ERROR cannot borrow `l.0` as mutable more than once at a time [E0499] - l = &mut **expr; //~ ERROR cannot assign to `l` because it is borrowed [E0506] + &mut Sexpression::Cons(ref mut expr) => { //~ ERROR cannot borrow `l.0` + //~| ERROR cannot borrow `l.0` + l = &mut **expr; //~ ERROR cannot assign to `l` } }} } fn main() { -} \ No newline at end of file +}