diff --git a/src/test/run-pass/region-return-interior-of-option.rs b/src/test/run-pass/region-return-interior-of-option.rs new file mode 100644 index 00000000000..948a456183b --- /dev/null +++ b/src/test/run-pass/region-return-interior-of-option.rs @@ -0,0 +1,22 @@ +fn get(opt: &option) -> &T { + match *opt { + some(ref v) => v, + none => fail ~"none" + } +} + +fn main() { + let mut x = some(23); + + { + let y = get(&x); + assert *y == 23; + } + + x = some(24); + + { + let y = get(&x); + assert *y == 24; + } +} \ No newline at end of file