diff options
| author | Wesley Wiser <wwiser@gmail.com> | 2020-01-12 21:19:44 -0500 |
|---|---|---|
| committer | Wesley Wiser <wwiser@gmail.com> | 2020-01-12 22:27:39 -0500 |
| commit | 7f65475d00c9a3048d0d664a80314734a8c6989e (patch) | |
| tree | bd635f1c4f17cc1ea2cacd3fcc493246056871fb /src/test/ui | |
| parent | f363745872f9b45cfec575f3c2cac42f0c242c03 (diff) | |
| download | rust-7f65475d00c9a3048d0d664a80314734a8c6989e.tar.gz rust-7f65475d00c9a3048d0d664a80314734a8c6989e.zip | |
Turn off const propagation of ref taking
Fixes #67529 Fixes #67640 Fixes #67641 Fixes #67862
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/consts/issue-67529.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/consts/issue-67640.rs | 24 | ||||
| -rw-r--r-- | src/test/ui/consts/issue-67641.rs | 24 | ||||
| -rw-r--r-- | src/test/ui/consts/issue-67862.rs | 18 |
4 files changed, 77 insertions, 0 deletions
diff --git a/src/test/ui/consts/issue-67529.rs b/src/test/ui/consts/issue-67529.rs new file mode 100644 index 00000000000..df4bc668bee --- /dev/null +++ b/src/test/ui/consts/issue-67529.rs @@ -0,0 +1,11 @@ +// compile-flags: -Z mir-opt-level=2 +// run-pass + +struct Baz<T: ?Sized> { + a: T +} + +fn main() { + let d : Baz<[i32; 4]> = Baz { a: [1,2,3,4] }; + assert_eq!([1, 2, 3, 4], d.a); +} diff --git a/src/test/ui/consts/issue-67640.rs b/src/test/ui/consts/issue-67640.rs new file mode 100644 index 00000000000..bc0ee8d386f --- /dev/null +++ b/src/test/ui/consts/issue-67640.rs @@ -0,0 +1,24 @@ +// compile-flags: -Z mir-opt-level=3 +// run-pass + +struct X { + x: isize +} + +fn f1(a: &mut X, b: &mut isize, c: isize) -> isize { + let r = a.x + *b + c; + a.x = 0; + *b = 10; + return r; +} + +fn f2<F>(a: isize, f: F) -> isize where F: FnOnce(isize) { f(1); return a; } + +pub fn main() { + let mut a = X {x: 1}; + let mut b = 2; + let c = 3; + assert_eq!(f1(&mut a, &mut b, c), 6); + assert_eq!(a.x, 0); + assert_eq!(f2(a.x, |_| a.x = 50), 0); +} diff --git a/src/test/ui/consts/issue-67641.rs b/src/test/ui/consts/issue-67641.rs new file mode 100644 index 00000000000..f50fba287a2 --- /dev/null +++ b/src/test/ui/consts/issue-67641.rs @@ -0,0 +1,24 @@ +// compile-flags: -Z mir-opt-level=2 +// run-pass + +use std::cell::Cell; + +#[derive(Debug)] +struct B<'a> { + a: [Cell<Option<&'a B<'a>>>; 2] +} + +impl<'a> B<'a> { + fn new() -> B<'a> { + B { a: [Cell::new(None), Cell::new(None)] } + } +} + +fn f() { + let b2 = B::new(); + b2.a[0].set(Some(&b2)); +} + +fn main() { + f(); +} diff --git a/src/test/ui/consts/issue-67862.rs b/src/test/ui/consts/issue-67862.rs new file mode 100644 index 00000000000..84f72154d26 --- /dev/null +++ b/src/test/ui/consts/issue-67862.rs @@ -0,0 +1,18 @@ +// compile-flags: -Z mir-opt-level=2 +// run-pass + +fn e220() -> (i64, i64) { + #[inline(never)] + fn get_displacement() -> [i64; 2] { + [139776, 963904] + } + + let res = get_displacement(); + match (&res[0], &res[1]) { + (arg0, arg1) => (*arg0, *arg1), + } +} + +fn main() { + assert_eq!(e220(), (139776, 963904)); +} |
