diff options
| author | kennytm <kennytm@gmail.com> | 2018-01-18 01:57:21 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-18 01:57:21 +0800 |
| commit | 1bf513e165b6d2daba57a7fc61eca9519f9c6a21 (patch) | |
| tree | 83bf88bfc380e3c8ef7a314bfb85d1dcbb11913b | |
| parent | 4cb87899d9a513fd4fab78e632e419758005e051 (diff) | |
| parent | f9e1b9c2c2fba742d1c4f6b8ab413ed614ed63d6 (diff) | |
| download | rust-1bf513e165b6d2daba57a7fc61eca9519f9c6a21.tar.gz rust-1bf513e165b6d2daba57a7fc61eca9519f9c6a21.zip | |
Rollup merge of #47456 - chrisvittal:nll-tests, r=nikomatsakis
Add NLL test for #45045 cc #45045 Part of #47366 r? @nikomatsakis
| -rw-r--r-- | src/test/ui/nll/borrowed-match-issue-45045.rs | 30 | ||||
| -rw-r--r-- | src/test/ui/nll/borrowed-match-issue-45045.stderr | 11 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/test/ui/nll/borrowed-match-issue-45045.rs b/src/test/ui/nll/borrowed-match-issue-45045.rs new file mode 100644 index 00000000000..8688bfa86dc --- /dev/null +++ b/src/test/ui/nll/borrowed-match-issue-45045.rs @@ -0,0 +1,30 @@ +// Copyright 2018 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for issue #45045 + +#![feature(nll)] + +enum Xyz { + A, + B, +} + +fn main() { + let mut e = Xyz::A; + let f = &mut e; + let g = f; + match e { + Xyz::A => println!("a"), + //~^ cannot use `e` because it was mutably borrowed [E0503] + Xyz::B => println!("b"), + }; + *g = Xyz::B; +} diff --git a/src/test/ui/nll/borrowed-match-issue-45045.stderr b/src/test/ui/nll/borrowed-match-issue-45045.stderr new file mode 100644 index 00000000000..15ca30010a5 --- /dev/null +++ b/src/test/ui/nll/borrowed-match-issue-45045.stderr @@ -0,0 +1,11 @@ +error[E0503]: cannot use `e` because it was mutably borrowed + --> $DIR/borrowed-match-issue-45045.rs:25:9 + | +22 | let f = &mut e; + | ------ borrow of `e` occurs here +... +25 | Xyz::A => println!("a"), + | ^^^^^^ use of borrowed `e` + +error: aborting due to previous error + |
