Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
librustc: Don't reuse same alloca for match on struct/tuple field whi…
…ch we reassign to in match body.
- Loading branch information
Showing
2 changed files
with
85 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} |
2dccb5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from nikomatsakis
at luqmana@2dccb5a
2dccb5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging luqmana/rust/mfb = 2dccb5a into auto
2dccb5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
luqmana/rust/mfb = 2dccb5a merged ok, testing candidate = a099e59a
2dccb5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some tests failed:
failure: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/2570
exception: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/2578
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/2574
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/2566
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/2574
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/2568
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/2566
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/2566
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/2563
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/2562
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2565
exception: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/2227
exception: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/2224
exception: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/2229
exception: http://buildbot.rust-lang.org/builders/auto-win-64-opt/builds/1066
exception: http://buildbot.rust-lang.org/builders/auto-win-64-nopt-t/builds/1060
exception: http://buildbot.rust-lang.org/builders/auto-win-64-nopt-c/builds/1056
2dccb5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from nikomatsakis
at luqmana@2dccb5a
2dccb5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging luqmana/rust/mfb = 2dccb5a into auto
2dccb5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
luqmana/rust/mfb = 2dccb5a merged ok, testing candidate = 84266845
2dccb5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some tests failed:
failure: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/2574
exception: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/2590
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/2586
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/2578
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/2586
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/2580
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/2578
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/2578
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/2582
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/2575
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2577
exception: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/2239
exception: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/2236
exception: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/2241
exception: http://buildbot.rust-lang.org/builders/auto-win-64-opt/builds/1078
exception: http://buildbot.rust-lang.org/builders/auto-win-64-nopt-t/builds/1072
2dccb5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from nikomatsakis
at luqmana@2dccb5a
2dccb5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging luqmana/rust/mfb = 2dccb5a into auto
2dccb5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
luqmana/rust/mfb = 2dccb5a merged ok, testing candidate = 77cd5cc
2dccb5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/2604
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/2600
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/2592
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/2600
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/2594
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/2592
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/2592
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/2596
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/2589
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/2588
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2591
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/2253
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/2250
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/2255
success: http://buildbot.rust-lang.org/builders/auto-win-64-opt/builds/1092
success: http://buildbot.rust-lang.org/builders/auto-win-64-nopt-t/builds/1086
success: http://buildbot.rust-lang.org/builders/auto-win-64-nopt-c/builds/1082
2dccb5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = 77cd5cc