diff options
| author | bors <bors@rust-lang.org> | 2014-12-07 19:02:18 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-07 19:02:18 +0000 |
| commit | 77cd5cc54eda4243614be32b893db512beab0f8e (patch) | |
| tree | f9eaccb9816417e85ef1d9c62b594d48580daabd /src/test | |
| parent | 558f8d8e3ea6b7da3d6d338740637149a7e45840 (diff) | |
| parent | 2dccb5a77fe6f163ee090800c61efef4a62775d9 (diff) | |
| download | rust-77cd5cc54eda4243614be32b893db512beab0f8e.tar.gz rust-77cd5cc54eda4243614be32b893db512beab0f8e.zip | |
auto merge of #19548 : luqmana/rust/mfb, r=nikomatsakis
Fixes #19367.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/issue-19367.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/test/run-pass/issue-19367.rs b/src/test/run-pass/issue-19367.rs new file mode 100644 index 00000000000..6083b340825 --- /dev/null +++ b/src/test/run-pass/issue-19367.rs @@ -0,0 +1,42 @@ +// Copyright 2014 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. + +#![feature(tuple_indexing)] +struct S { + o: Option<String> +} + +// Make sure we don't reuse the same alloca when matching +// on field of struct or tuple which we reassign in the match body. + +fn main() { + let mut a = (0i, Some("right".into_string())); + let b = match a.1 { + Some(v) => { + a.1 = Some("wrong".into_string()); + v + } + None => String::new() + }; + println!("{}", b); + assert_eq!(b, "right"); + + + let mut s = S{ o: Some("right".into_string()) }; + let b = match s.o { + Some(v) => { + s.o = Some("wrong".into_string()); + v + } + None => String::new(), + }; + println!("{}", b); + assert_eq!(b, "right"); +} |
