diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr b/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr index 3fbb747db24f..ee5ad58290e9 100644 --- a/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr +++ b/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr @@ -1,3 +1,13 @@ +error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-unboxed-closures.rs:13:5 + | +LL | let g = &mut f; + | ------ mutable borrow occurs here +LL | f(1, 2); //~ ERROR cannot borrow `f` as immutable + | ^ immutable borrow occurs here +LL | use_mut(g); + | - mutable borrow later used here + error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable --> $DIR/borrowck-unboxed-closures.rs:17:5 | @@ -16,7 +26,7 @@ LL | f(1, 2); //~ ERROR use of moved value | = note: move occurs because `f` has type `F`, which does not implement the `Copy` trait -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -Some errors occurred: E0382, E0596. +Some errors occurred: E0382, E0502, E0596. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.rs b/src/test/ui/borrowck/borrowck-unboxed-closures.rs index 4813b4b6a72c..43f143a492fd 100644 --- a/src/test/ui/borrowck/borrowck-unboxed-closures.rs +++ b/src/test/ui/borrowck/borrowck-unboxed-closures.rs @@ -11,8 +11,8 @@ fn a isize>(mut f: F) { let g = &mut f; f(1, 2); //~ ERROR cannot borrow `f` as immutable + use_mut(g); } - fn b isize>(f: F) { f(1, 2); //~ ERROR cannot borrow immutable argument } @@ -23,3 +23,5 @@ fn c isize>(f: F) { } fn main() {} + +fn use_mut(_: &mut T) { } diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.stderr b/src/test/ui/borrowck/borrowck-unboxed-closures.stderr index 0c067c47004c..6ee1a6245a55 100644 --- a/src/test/ui/borrowck/borrowck-unboxed-closures.stderr +++ b/src/test/ui/borrowck/borrowck-unboxed-closures.stderr @@ -5,6 +5,7 @@ LL | let g = &mut f; | - mutable borrow occurs here LL | f(1, 2); //~ ERROR cannot borrow `f` as immutable | ^ immutable borrow occurs here +LL | use_mut(g); LL | } | - mutable borrow ends here