about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/bench/task-perf-alloc-unwind.rs10
-rw-r--r--src/test/compile-fail/check-static-immutable-mut-slices.rs2
-rw-r--r--src/test/compile-fail/check-static-values-constraints.rs15
-rw-r--r--src/test/compile-fail/const-block-non-item-statement.rs8
-rw-r--r--src/test/compile-fail/issue-16538.rs3
-rw-r--r--src/test/compile-fail/issue-17458.rs2
-rw-r--r--src/test/compile-fail/issue-17718-const-bad-values.rs4
-rw-r--r--src/test/compile-fail/issue-18118.rs5
-rw-r--r--src/test/compile-fail/issue-6977.rs15
-rw-r--r--src/test/compile-fail/issue-7364.rs7
-rw-r--r--src/test/compile-fail/issue-8460-const.rs55
-rw-r--r--src/test/compile-fail/repeat_count.rs18
-rw-r--r--src/test/compile-fail/static-mut-not-constant.rs2
-rw-r--r--src/test/compile-fail/static-vec-repeat-not-constant.rs2
-rw-r--r--src/test/debuginfo/basic-types-globals-metadata.rs32
-rw-r--r--src/test/debuginfo/basic-types-globals.rs31
-rw-r--r--src/test/run-make/issue-7349/Makefile4
-rw-r--r--src/test/run-make/issue-7349/foo.rs4
-rw-r--r--src/test/run-pass/const-adt-align-mismatch.rs28
-rw-r--r--src/test/run-pass/issue-17216.rs4
-rw-r--r--src/test/run-pass/issue-8460.rs46
21 files changed, 194 insertions, 103 deletions
diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs
index f09e64cb9c5..c45efe5f54b 100644
--- a/src/test/bench/task-perf-alloc-unwind.rs
+++ b/src/test/bench/task-perf-alloc-unwind.rs
@@ -40,7 +40,9 @@ fn run(repeat: int, depth: int) {
     }
 }
 
-type nillist = List<()>;
+// FIXME(#21721) used to be `List<()>` but that can cause
+// certain LLVM versions to abort during optimizations.
+type nillist = List<[u8; 0]>;
 
 // Filled with things that have to be unwound
 
@@ -81,11 +83,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/compile-fail/check-static-immutable-mut-slices.rs b/src/test/compile-fail/check-static-immutable-mut-slices.rs
index d1e3fe25253..1804b9e04c2 100644
--- a/src/test/compile-fail/check-static-immutable-mut-slices.rs
+++ b/src/test/compile-fail/check-static-immutable-mut-slices.rs
@@ -11,6 +11,6 @@
 // Checks that immutable static items can't have mutable slices
 
 static TEST: &'static mut [isize] = &mut [];
-//~^ ERROR statics are not allowed to have mutable references
+//~^ ERROR references in statics may only refer to immutable values
 
 pub fn main() { }
diff --git a/src/test/compile-fail/check-static-values-constraints.rs b/src/test/compile-fail/check-static-values-constraints.rs
index 7c4f9ada2d3..0180bccbca4 100644
--- a/src/test/compile-fail/check-static-values-constraints.rs
+++ b/src/test/compile-fail/check-static-values-constraints.rs
@@ -99,7 +99,7 @@ static STATIC10: UnsafeStruct = UnsafeStruct;
 struct MyOwned;
 
 static STATIC11: Box<MyOwned> = box MyOwned;
-//~^ ERROR statics are not allowed to have custom pointers
+//~^ ERROR allocations are not allowed in statics
 
 // The following examples test that mutable structs are just forbidden
 // to have types with destructors
@@ -117,16 +117,17 @@ static mut STATIC14: SafeStruct = SafeStruct {
 //~^ ERROR mutable statics are not allowed to have destructors
     field1: SafeEnum::Variant1,
     field2: SafeEnum::Variant4("str".to_string())
+//~^ ERROR static contains unimplemented expression type
 };
 
 static STATIC15: &'static [Box<MyOwned>] = &[
-    box MyOwned, //~ ERROR statics are not allowed to have custom pointers
-    box MyOwned, //~ ERROR statics are not allowed to have custom pointers
+    box MyOwned, //~ ERROR allocations are not allowed in statics
+    box MyOwned, //~ ERROR allocations are not allowed in statics
 ];
 
 static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) = (
-    &box MyOwned, //~ ERROR statics are not allowed to have custom pointers
-    &box MyOwned, //~ ERROR statics are not allowed to have custom pointers
+    &box MyOwned, //~ ERROR allocations are not allowed in statics
+    &box MyOwned, //~ ERROR allocations are not allowed in statics
 );
 
 static mut STATIC17: SafeEnum = SafeEnum::Variant1;
@@ -134,9 +135,9 @@ static mut STATIC17: SafeEnum = SafeEnum::Variant1;
 
 static STATIC19: Box<isize> =
     box 3;
-//~^ ERROR statics are not allowed to have custom pointers
+//~^ ERROR allocations are not allowed in statics
 
 pub fn main() {
     let y = { static x: Box<isize> = box 3; x };
-    //~^ ERROR statics are not allowed to have custom pointers
+    //~^ ERROR allocations are not allowed in statics
 }
diff --git a/src/test/compile-fail/const-block-non-item-statement.rs b/src/test/compile-fail/const-block-non-item-statement.rs
index 62e8fccbda0..f66c68541b1 100644
--- a/src/test/compile-fail/const-block-non-item-statement.rs
+++ b/src/test/compile-fail/const-block-non-item-statement.rs
@@ -8,18 +8,18 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-static A: usize = { 1us; 2 };
+const A: usize = { 1us; 2 };
 //~^ ERROR: blocks in constants are limited to items and tail expressions
 
-static B: usize = { { } 2 };
+const B: usize = { { } 2 };
 //~^ ERROR: blocks in constants are limited to items and tail expressions
 
 macro_rules! foo {
     () => (()) //~ ERROR: blocks in constants are limited to items and tail expressions
 }
-static C: usize = { foo!(); 2 };
+const C: usize = { foo!(); 2 };
 
-static D: usize = { let x = 4us; 2 };
+const D: usize = { let x = 4us; 2 };
 //~^ ERROR: blocks in constants are limited to items and tail expressions
 
 pub fn main() {
diff --git a/src/test/compile-fail/issue-16538.rs b/src/test/compile-fail/issue-16538.rs
index a6b73dcc19c..6d2cfcab04e 100644
--- a/src/test/compile-fail/issue-16538.rs
+++ b/src/test/compile-fail/issue-16538.rs
@@ -20,6 +20,7 @@ mod Y {
 
 static foo: *const Y::X = Y::foo(Y::x as *const Y::X);
 //~^ ERROR cannot refer to other statics by value
-//~| ERROR: the trait `core::marker::Sync` is not implemented for the type
+//~| ERROR the trait `core::marker::Sync` is not implemented for the type
+//~| ERROR function calls in statics are limited to struct and enum constructors
 
 fn main() {}
diff --git a/src/test/compile-fail/issue-17458.rs b/src/test/compile-fail/issue-17458.rs
index d9fd67f9197..d6f70ae1e57 100644
--- a/src/test/compile-fail/issue-17458.rs
+++ b/src/test/compile-fail/issue-17458.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 static X: usize = 0 as *const usize as usize;
-//~^ ERROR: can not cast a pointer to an integer in a constant expression
+//~^ ERROR: can not cast a pointer to an integer in statics
 
 fn main() {
     assert_eq!(X, 0);
diff --git a/src/test/compile-fail/issue-17718-const-bad-values.rs b/src/test/compile-fail/issue-17718-const-bad-values.rs
index daa250d12f5..2347d3f3d5c 100644
--- a/src/test/compile-fail/issue-17718-const-bad-values.rs
+++ b/src/test/compile-fail/issue-17718-const-bad-values.rs
@@ -9,12 +9,12 @@
 // except according to those terms.
 
 const C1: &'static mut [usize] = &mut [];
-//~^ ERROR: constants are not allowed to have mutable references
+//~^ ERROR: references in constants may only refer to immutable values
 
 static mut S: usize = 3;
 const C2: &'static mut usize = &mut S;
 //~^ ERROR: constants cannot refer to other statics
-//~^^ ERROR: are not allowed to have mutable references
+//~^^ ERROR: references in constants may only refer to immutable values
 
 fn main() {}
 
diff --git a/src/test/compile-fail/issue-18118.rs b/src/test/compile-fail/issue-18118.rs
index 129f28f1d89..c5370879cc2 100644
--- a/src/test/compile-fail/issue-18118.rs
+++ b/src/test/compile-fail/issue-18118.rs
@@ -9,9 +9,10 @@
 // except according to those terms.
 
 pub fn main() {
-    static z: &'static isize = {
+    const z: &'static isize = {
         let p = 3;
+        //~^ ERROR blocks in constants are limited to items and tail expressions
         &p
-//~^ ERROR cannot borrow a local variable inside a static block, define a separate static instead
+        //~^ ERROR paths in constants may only refer to constants or functions
     };
 }
diff --git a/src/test/compile-fail/issue-6977.rs b/src/test/compile-fail/issue-6977.rs
deleted file mode 100644
index c2bd810abad..00000000000
--- a/src/test/compile-fail/issue-6977.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// 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.
-
-// Trying to create a fixed-length vector with a negative size
-
-fn main() {
-      let _x = [0; -1]; //~ ERROR found negative integer
-}
diff --git a/src/test/compile-fail/issue-7364.rs b/src/test/compile-fail/issue-7364.rs
index 465a38111ba..6a36b2f84bf 100644
--- a/src/test/compile-fail/issue-7364.rs
+++ b/src/test/compile-fail/issue-7364.rs
@@ -14,8 +14,9 @@ use std::cell::RefCell;
 
 // Regression test for issue 7364
 static boxed: Box<RefCell<isize>> = box RefCell::new(0);
-//~^ ERROR statics are not allowed to have custom pointers
-//~| ERROR: the trait `core::marker::Sync` is not implemented for the type
-//~| ERROR: the trait `core::marker::Sync` is not implemented for the type
+//~^ ERROR allocations are not allowed in statics
+//~| ERROR the trait `core::marker::Sync` is not implemented for the type
+//~| ERROR the trait `core::marker::Sync` is not implemented for the type
+//~| ERROR function calls in statics are limited to struct and enum constructors
 
 fn main() { }
diff --git a/src/test/compile-fail/issue-8460-const.rs b/src/test/compile-fail/issue-8460-const.rs
new file mode 100644
index 00000000000..01bed69fb1d
--- /dev/null
+++ b/src/test/compile-fail/issue-8460-const.rs
@@ -0,0 +1,55 @@
+// 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.
+
+use std::{int, i8, i16, i32, i64};
+use std::thread::Thread;
+
+fn main() {
+    assert!(Thread::scoped(move|| int::MIN / -1).join().is_err());
+    //~^ ERROR attempted to divide with overflow in a constant expression
+    assert!(Thread::scoped(move|| i8::MIN / -1).join().is_err());
+    //~^ ERROR attempted to divide with overflow in a constant expression
+    assert!(Thread::scoped(move|| i16::MIN / -1).join().is_err());
+    //~^ ERROR attempted to divide with overflow in a constant expression
+    assert!(Thread::scoped(move|| i32::MIN / -1).join().is_err());
+    //~^ ERROR attempted to divide with overflow in a constant expression
+    assert!(Thread::scoped(move|| i64::MIN / -1).join().is_err());
+    //~^ ERROR attempted to divide with overflow in a constant expression
+    assert!(Thread::scoped(move|| 1is / 0).join().is_err());
+    //~^ ERROR attempted to divide by zero in a constant expression
+    assert!(Thread::scoped(move|| 1i8 / 0).join().is_err());
+    //~^ ERROR attempted to divide by zero in a constant expression
+    assert!(Thread::scoped(move|| 1i16 / 0).join().is_err());
+    //~^ ERROR attempted to divide by zero in a constant expression
+    assert!(Thread::scoped(move|| 1i32 / 0).join().is_err());
+    //~^ ERROR attempted to divide by zero in a constant expression
+    assert!(Thread::scoped(move|| 1i64 / 0).join().is_err());
+    //~^ ERROR attempted to divide by zero in a constant expression
+    assert!(Thread::scoped(move|| int::MIN % -1).join().is_err());
+    //~^ ERROR attempted remainder with overflow in a constant expression
+    assert!(Thread::scoped(move|| i8::MIN % -1).join().is_err());
+    //~^ ERROR attempted remainder with overflow in a constant expression
+    assert!(Thread::scoped(move|| i16::MIN % -1).join().is_err());
+    //~^ ERROR attempted remainder with overflow in a constant expression
+    assert!(Thread::scoped(move|| i32::MIN % -1).join().is_err());
+    //~^ ERROR attempted remainder with overflow in a constant expression
+    assert!(Thread::scoped(move|| i64::MIN % -1).join().is_err());
+    //~^ ERROR attempted remainder with overflow in a constant expression
+    assert!(Thread::scoped(move|| 1is % 0).join().is_err());
+    //~^ ERROR attempted remainder with a divisor of zero in a constant expression
+    assert!(Thread::scoped(move|| 1i8 % 0).join().is_err());
+    //~^ ERROR attempted remainder with a divisor of zero in a constant expression
+    assert!(Thread::scoped(move|| 1i16 % 0).join().is_err());
+    //~^ ERROR attempted remainder with a divisor of zero in a constant expression
+    assert!(Thread::scoped(move|| 1i32 % 0).join().is_err());
+    //~^ ERROR attempted remainder with a divisor of zero in a constant expression
+    assert!(Thread::scoped(move|| 1i64 % 0).join().is_err());
+    //~^ ERROR attempted remainder with a divisor of zero in a constant expression
+}
diff --git a/src/test/compile-fail/repeat_count.rs b/src/test/compile-fail/repeat_count.rs
index df69e13bf1e..d730add00b7 100644
--- a/src/test/compile-fail/repeat_count.rs
+++ b/src/test/compile-fail/repeat_count.rs
@@ -41,8 +41,18 @@ fn main() {
     //~| expected usize
     //~| found &-ptr
     //~| ERROR expected positive integer for repeat count, found string
-    let f = [0; -4];
-    //~^ ERROR expected positive integer for repeat count, found negative integer
-    let f = [0us; -1];
-    //~^ ERROR expected positive integer for repeat count, found negative integer
+    let f = [0; -4is];
+    //~^ ERROR mismatched types
+    //~| expected `usize`
+    //~| found `isize`
+    //~| expected usize
+    //~| found isize
+    //~| ERROR expected positive integer for repeat count, found negative integer
+    let f = [0us; -1is];
+    //~^ ERROR mismatched types
+    //~| expected `usize`
+    //~| found `isize`
+    //~| expected usize
+    //~| found isize
+    //~| ERROR expected positive integer for repeat count, found negative integer
 }
diff --git a/src/test/compile-fail/static-mut-not-constant.rs b/src/test/compile-fail/static-mut-not-constant.rs
index 7c228ce413f..08148328edc 100644
--- a/src/test/compile-fail/static-mut-not-constant.rs
+++ b/src/test/compile-fail/static-mut-not-constant.rs
@@ -11,7 +11,7 @@
 #![feature(box_syntax)]
 
 static mut a: Box<isize> = box 3;
-//~^ ERROR statics are not allowed to have custom pointers
+//~^ ERROR allocations are not allowed in statics
 //~^^ ERROR mutable statics are not allowed to have owned pointers
 
 fn main() {}
diff --git a/src/test/compile-fail/static-vec-repeat-not-constant.rs b/src/test/compile-fail/static-vec-repeat-not-constant.rs
index 7cb7615526a..7a957564587 100644
--- a/src/test/compile-fail/static-vec-repeat-not-constant.rs
+++ b/src/test/compile-fail/static-vec-repeat-not-constant.rs
@@ -11,6 +11,6 @@
 fn foo() -> isize { 23 }
 
 static a: [isize; 2] = [foo(); 2];
-//~^ ERROR: function calls in constants are limited to struct and enum constructors
+//~^ ERROR: function calls in statics are limited to struct and enum constructors
 
 fn main() {}
diff --git a/src/test/debuginfo/basic-types-globals-metadata.rs b/src/test/debuginfo/basic-types-globals-metadata.rs
index e9f801c5f05..91e78c820e6 100644
--- a/src/test/debuginfo/basic-types-globals-metadata.rs
+++ b/src/test/debuginfo/basic-types-globals-metadata.rs
@@ -47,26 +47,26 @@
 #![allow(dead_code)]
 #![omit_gdb_pretty_printer_section]
 
-
-static B: bool = false;
-static I: int = -1;
-static C: char = 'a';
-static I8: i8 = 68;
-static I16: i16 = -16;
-static I32: i32 = -32;
-static I64: i64 = -64;
-static U: uint = 1;
-static U8: u8 = 100;
-static U16: u16 = 16;
-static U32: u32 = 32;
-static U64: u64 = 64;
-static F32: f32 = 2.5;
-static F64: f64 = 3.5;
+// N.B. These are `mut` only so they don't constant fold away.
+static mut B: bool = false;
+static mut I: int = -1;
+static mut C: char = 'a';
+static mut I8: i8 = 68;
+static mut I16: i16 = -16;
+static mut I32: i32 = -32;
+static mut I64: i64 = -64;
+static mut U: uint = 1;
+static mut U8: u8 = 100;
+static mut U16: u16 = 16;
+static mut U32: u32 = 32;
+static mut U64: u64 = 64;
+static mut F32: f32 = 2.5;
+static mut F64: f64 = 3.5;
 
 fn main() {
     _zzz(); // #break
 
-    let a = (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64);
+    let a = unsafe { (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64) };
 }
 
 fn _zzz() {()}
diff --git a/src/test/debuginfo/basic-types-globals.rs b/src/test/debuginfo/basic-types-globals.rs
index a4d4ddfea53..d37b0f60d3d 100644
--- a/src/test/debuginfo/basic-types-globals.rs
+++ b/src/test/debuginfo/basic-types-globals.rs
@@ -52,25 +52,26 @@
 #![allow(unused_variables)]
 #![omit_gdb_pretty_printer_section]
 
-static B: bool = false;
-static I: int = -1;
-static C: char = 'a';
-static I8: i8 = 68;
-static I16: i16 = -16;
-static I32: i32 = -32;
-static I64: i64 = -64;
-static U: uint = 1;
-static U8: u8 = 100;
-static U16: u16 = 16;
-static U32: u32 = 32;
-static U64: u64 = 64;
-static F32: f32 = 2.5;
-static F64: f64 = 3.5;
+// N.B. These are `mut` only so they don't constant fold away.
+static mut B: bool = false;
+static mut I: int = -1;
+static mut C: char = 'a';
+static mut I8: i8 = 68;
+static mut I16: i16 = -16;
+static mut I32: i32 = -32;
+static mut I64: i64 = -64;
+static mut U: uint = 1;
+static mut U8: u8 = 100;
+static mut U16: u16 = 16;
+static mut U32: u32 = 32;
+static mut U64: u64 = 64;
+static mut F32: f32 = 2.5;
+static mut F64: f64 = 3.5;
 
 fn main() {
     _zzz(); // #break
 
-    let a = (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64);
+    let a = unsafe { (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64) };
 }
 
 fn _zzz() {()}
diff --git a/src/test/run-make/issue-7349/Makefile b/src/test/run-make/issue-7349/Makefile
index f24933cac01..50dc63b1deb 100644
--- a/src/test/run-make/issue-7349/Makefile
+++ b/src/test/run-make/issue-7349/Makefile
@@ -7,5 +7,5 @@
 
 all:
 	$(RUSTC) foo.rs --emit=llvm-ir
-	[ "$$(grep -c 8675309 "$(TMPDIR)/foo.ll")" -eq "1" ]
-	[ "$$(grep -c 11235813 "$(TMPDIR)/foo.ll")" -eq "1" ]
+	[ "$$(grep -c 'ret i32 8675309' "$(TMPDIR)/foo.ll")" -eq "1" ]
+	[ "$$(grep -c 'ret i32 11235813' "$(TMPDIR)/foo.ll")" -eq "1" ]
diff --git a/src/test/run-make/issue-7349/foo.rs b/src/test/run-make/issue-7349/foo.rs
index 870d1749278..3a2ced80ef4 100644
--- a/src/test/run-make/issue-7349/foo.rs
+++ b/src/test/run-make/issue-7349/foo.rs
@@ -10,14 +10,14 @@
 
 fn outer<T>() {
     #[allow(dead_code)]
-    fn inner() -> uint {
+    fn inner() -> u32 {
         8675309
     }
 }
 
 extern "C" fn outer_foreign<T>() {
     #[allow(dead_code)]
-    fn inner() -> uint {
+    fn inner() -> u32 {
         11235813
     }
 }
diff --git a/src/test/run-pass/const-adt-align-mismatch.rs b/src/test/run-pass/const-adt-align-mismatch.rs
new file mode 100644
index 00000000000..5377d9a62b9
--- /dev/null
+++ b/src/test/run-pass/const-adt-align-mismatch.rs
@@ -0,0 +1,28 @@
+// 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.
+
+use std::mem;
+
+#[derive(PartialEq, Show)]
+enum Foo {
+    A(u32),
+    Bar([u16; 4]),
+    C
+}
+
+// NOTE(eddyb) Don't make this a const, needs to be a static
+// so it is always instantiated as a LLVM constant value.
+static FOO: Foo = Foo::C;
+
+fn main() {
+    assert_eq!(FOO, Foo::C);
+    assert_eq!(mem::size_of::<Foo>(), 12);
+    assert_eq!(mem::min_align_of::<Foo>(), 4);
+}
diff --git a/src/test/run-pass/issue-17216.rs b/src/test/run-pass/issue-17216.rs
index e48d7b0756c..ce5a0aa96e3 100644
--- a/src/test/run-pass/issue-17216.rs
+++ b/src/test/run-pass/issue-17216.rs
@@ -25,7 +25,9 @@ fn main() {
     let mut dropped = false;
     {
         let leak = Leak { dropped: &mut dropped };
-        for ((), leaked) in Some(((),leak)).into_iter() {}
+        // 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() {}
     }
 
     assert!(dropped);
diff --git a/src/test/run-pass/issue-8460.rs b/src/test/run-pass/issue-8460.rs
index 3944895460f..4b9ed44c7cd 100644
--- a/src/test/run-pass/issue-8460.rs
+++ b/src/test/run-pass/issue-8460.rs
@@ -8,28 +8,32 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::{int, i8, i16, i32, i64};
+use std::num::Int;
 use std::thread::Thread;
 
+// Avoid using constants, which would trigger compile-time errors.
+fn min_val<T: Int>() -> T { Int::min_value() }
+fn zero<T: Int>() -> T { Int::zero() }
+
 fn main() {
-    assert!(Thread::scoped(move|| int::MIN / -1).join().is_err());
-    assert!(Thread::scoped(move|| i8::MIN / -1).join().is_err());
-    assert!(Thread::scoped(move|| i16::MIN / -1).join().is_err());
-    assert!(Thread::scoped(move|| i32::MIN / -1).join().is_err());
-    assert!(Thread::scoped(move|| i64::MIN / -1).join().is_err());
-    assert!(Thread::scoped(move|| 1 / 0).join().is_err());
-    assert!(Thread::scoped(move|| 1i8 / 0).join().is_err());
-    assert!(Thread::scoped(move|| 1i16 / 0).join().is_err());
-    assert!(Thread::scoped(move|| 1i32 / 0).join().is_err());
-    assert!(Thread::scoped(move|| 1i64 / 0).join().is_err());
-    assert!(Thread::scoped(move|| int::MIN % -1).join().is_err());
-    assert!(Thread::scoped(move|| i8::MIN % -1).join().is_err());
-    assert!(Thread::scoped(move|| i16::MIN % -1).join().is_err());
-    assert!(Thread::scoped(move|| i32::MIN % -1).join().is_err());
-    assert!(Thread::scoped(move|| i64::MIN % -1).join().is_err());
-    assert!(Thread::scoped(move|| 1 % 0).join().is_err());
-    assert!(Thread::scoped(move|| 1i8 % 0).join().is_err());
-    assert!(Thread::scoped(move|| 1i16 % 0).join().is_err());
-    assert!(Thread::scoped(move|| 1i32 % 0).join().is_err());
-    assert!(Thread::scoped(move|| 1i64 % 0).join().is_err());
+    assert!(Thread::scoped(move|| min_val::<isize>() / -1).join().is_err());
+    assert!(Thread::scoped(move|| min_val::<i8>() / -1).join().is_err());
+    assert!(Thread::scoped(move|| min_val::<i16>() / -1).join().is_err());
+    assert!(Thread::scoped(move|| min_val::<i32>() / -1).join().is_err());
+    assert!(Thread::scoped(move|| min_val::<i64>() / -1).join().is_err());
+    assert!(Thread::scoped(move|| 1is / zero()).join().is_err());
+    assert!(Thread::scoped(move|| 1i8 / zero()).join().is_err());
+    assert!(Thread::scoped(move|| 1i16 / zero()).join().is_err());
+    assert!(Thread::scoped(move|| 1i32 / zero()).join().is_err());
+    assert!(Thread::scoped(move|| 1i64 / zero()).join().is_err());
+    assert!(Thread::scoped(move|| min_val::<isize>() % -1).join().is_err());
+    assert!(Thread::scoped(move|| min_val::<i8>() % -1).join().is_err());
+    assert!(Thread::scoped(move|| min_val::<i16>() % -1).join().is_err());
+    assert!(Thread::scoped(move|| min_val::<i32>() % -1).join().is_err());
+    assert!(Thread::scoped(move|| min_val::<i64>() % -1).join().is_err());
+    assert!(Thread::scoped(move|| 1is % zero()).join().is_err());
+    assert!(Thread::scoped(move|| 1i8 % zero()).join().is_err());
+    assert!(Thread::scoped(move|| 1i16 % zero()).join().is_err());
+    assert!(Thread::scoped(move|| 1i32 % zero()).join().is_err());
+    assert!(Thread::scoped(move|| 1i64 % zero()).join().is_err());
 }