about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2015-02-26 15:22:13 +0200
committerEduard Burtescu <edy.burt@gmail.com>2015-02-26 16:44:07 +0200
commit704ce1d735cc885718fc5d1d4b2b5ca55410271e (patch)
tree259a0f7172c281b021ee8f374d507d9766ff7c6b
parent41f8b1e89b5ca0c79d7bca782ca44085624d4564 (diff)
downloadrust-704ce1d735cc885718fc5d1d4b2b5ca55410271e.tar.gz
rust-704ce1d735cc885718fc5d1d4b2b5ca55410271e.zip
Revert hacks and add test for LLVM aborts due to empty aggregates.
Closes #21721.
-rw-r--r--src/librand/reseeding.rs6
-rw-r--r--src/test/bench/task-perf-alloc-unwind.rs10
-rw-r--r--src/test/run-pass/issue-17216.rs4
-rw-r--r--src/test/run-pass/issue-21721.rs17
4 files changed, 23 insertions, 14 deletions
diff --git a/src/librand/reseeding.rs b/src/librand/reseeding.rs
index f4d3e975b75..06828911471 100644
--- a/src/librand/reseeding.rs
+++ b/src/librand/reseeding.rs
@@ -134,11 +134,7 @@ pub trait Reseeder<R> {
 /// Reseed an RNG using a `Default` instance. This reseeds by
 /// replacing the RNG with the result of a `Default::default` call.
 #[derive(Copy)]
-pub struct ReseedWithDefault { __hack: [u8; 0] }
-// FIXME(#21721) used to be an unit struct but that can cause
-// certain LLVM versions to abort during optimizations.
-#[allow(non_upper_case_globals)]
-pub const ReseedWithDefault: ReseedWithDefault = ReseedWithDefault { __hack: [] };
+pub struct ReseedWithDefault;
 
 impl<R: Rng + Default> Reseeder<R> for ReseedWithDefault {
     fn reseed(&mut self, rng: &mut R) {
diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs
index 6b412c47cd7..896b0ee57a0 100644
--- a/src/test/bench/task-perf-alloc-unwind.rs
+++ b/src/test/bench/task-perf-alloc-unwind.rs
@@ -40,9 +40,7 @@ fn run(repeat: int, depth: int) {
     }
 }
 
-// FIXME(#21721) used to be `List<()>` but that can cause
-// certain LLVM versions to abort during optimizations.
-type nillist = List<[u8; 0]>;
+type nillist = List<()>;
 
 // Filled with things that have to be unwound
 
@@ -83,11 +81,11 @@ fn recurse_or_panic(depth: int, st: Option<State>) {
             }
             Some(st) => {
                 let mut v = st.vec.clone();
-                v.push_all(&[box List::Cons([], st.vec.last().unwrap().clone())]);
+                v.push_all(&[box List::Cons((), st.vec.last().unwrap().clone())]);
                 State {
-                    unique: box List::Cons([], box *st.unique),
+                    unique: box List::Cons((), box *st.unique),
                     vec: v,
-                    res: r(box List::Cons([], st.res._l.clone())),
+                    res: r(box List::Cons((), st.res._l.clone())),
                 }
             }
         };
diff --git a/src/test/run-pass/issue-17216.rs b/src/test/run-pass/issue-17216.rs
index ce5a0aa96e3..aa53a7658e1 100644
--- a/src/test/run-pass/issue-17216.rs
+++ b/src/test/run-pass/issue-17216.rs
@@ -25,9 +25,7 @@ fn main() {
     let mut dropped = false;
     {
         let leak = Leak { dropped: &mut dropped };
-        // FIXME(#21721) "hack" used to be () but that can cause
-        // certain LLVM versions to abort during optimizations.
-        for (_, leaked) in Some(("hack", leak)).into_iter() {}
+        for ((), leaked) in Some(((), leak)).into_iter() {}
     }
 
     assert!(dropped);
diff --git a/src/test/run-pass/issue-21721.rs b/src/test/run-pass/issue-21721.rs
new file mode 100644
index 00000000000..fee14061c56
--- /dev/null
+++ b/src/test/run-pass/issue-21721.rs
@@ -0,0 +1,17 @@
+// Copyright 2015 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.
+
+fn main() {
+    static NONE: Option<((), &'static u8)> = None;
+    let ptr = unsafe {
+        *(&NONE as *const _ as *const *const u8)
+    };
+    assert!(ptr.is_null());
+}