summaryrefslogtreecommitdiffstats
path: root/src/test/ui/regions/regions-infer-contravariance-due-to-ret.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/regions/regions-infer-contravariance-due-to-ret.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/ui/regions/regions-infer-contravariance-due-to-ret.rs b/src/test/ui/regions/regions-infer-contravariance-due-to-ret.rs
new file mode 100644
index 000000000..fbd895015
--- /dev/null
+++ b/src/test/ui/regions/regions-infer-contravariance-due-to-ret.rs
@@ -0,0 +1,22 @@
+// run-pass
+#![allow(non_camel_case_types)]
+
+
+struct boxed_int<'a> {
+ f: &'a isize,
+}
+
+fn max<'r>(bi: &'r boxed_int, f: &'r isize) -> isize {
+ if *bi.f > *f {*bi.f} else {*f}
+}
+
+fn with(bi: &boxed_int) -> isize {
+ let i = 22;
+ max(bi, &i)
+}
+
+pub fn main() {
+ let g = 21;
+ let foo = boxed_int { f: &g };
+ assert_eq!(with(&foo), 22);
+}