diff options
| author | bors <bors@rust-lang.org> | 2014-10-18 17:02:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-10-18 17:02:13 +0000 |
| commit | ce342f522c10eef8799f2b91b7f39947d40f93ce (patch) | |
| tree | 4d73e7388e74acda5c1f1142e726cee91be7929f /src/test | |
| parent | d670919aa43d186317a89a375f4a5b7170fc08a8 (diff) | |
| parent | ccdf8d5b527538d8959b5c76bba917b5326027a8 (diff) | |
auto merge of #18041 : arielb1/rust/no-size-overflow, r=pnkfelix
Should fix #17913. Also clean-up u64/u32-ness. I really should split this commit and add tests (I have no idea how to add them).
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/huge-array-simple.rs | 15 | ||||
| -rw-r--r-- | src/test/compile-fail/huge-array.rs | 20 | ||||
| -rw-r--r-- | src/test/compile-fail/huge-enum.rs | 17 | ||||
| -rw-r--r-- | src/test/compile-fail/huge-struct.rs | 54 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-17913.rs | 25 | ||||
| -rw-r--r-- | src/test/run-pass/vec-fixed-length.rs | 7 |
6 files changed, 135 insertions, 3 deletions
diff --git a/src/test/compile-fail/huge-array-simple.rs b/src/test/compile-fail/huge-array-simple.rs new file mode 100644 index 00000000000..b23d0716e6d --- /dev/null +++ b/src/test/compile-fail/huge-array-simple.rs @@ -0,0 +1,15 @@ +// 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. + +// error-pattern: too big for the current + +fn main() { + let fat : [u8, ..(1<<61)+(1<<31)] = [0, ..(1<<61)+(1<<31)]; +} diff --git a/src/test/compile-fail/huge-array.rs b/src/test/compile-fail/huge-array.rs new file mode 100644 index 00000000000..4b91564154b --- /dev/null +++ b/src/test/compile-fail/huge-array.rs @@ -0,0 +1,20 @@ +// 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. + +// error-pattern: ..1518599999 + +fn generic<T: Copy>(t: T) { + let s: [T, ..1518600000] = [t, ..1518600000]; +} + +fn main() { + let x: [u8, ..1518599999] = [0, ..1518599999]; + generic::<[u8, ..1518599999]>(x); +} diff --git a/src/test/compile-fail/huge-enum.rs b/src/test/compile-fail/huge-enum.rs new file mode 100644 index 00000000000..92f9c41e7ea --- /dev/null +++ b/src/test/compile-fail/huge-enum.rs @@ -0,0 +1,17 @@ +// 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. + +// error-pattern: Option + +// FIXME: work properly with higher limits + +fn main() { + let big: Option<[u32, ..(1<<29)-1]> = None; +} diff --git a/src/test/compile-fail/huge-struct.rs b/src/test/compile-fail/huge-struct.rs new file mode 100644 index 00000000000..a10c61d6606 --- /dev/null +++ b/src/test/compile-fail/huge-struct.rs @@ -0,0 +1,54 @@ +// 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. + +// error-pattern: too big for the current + +struct S32<T> { + v0: T, + v1: T, + v2: T, + v3: T, + v4: T, + v5: T, + v6: T, + v7: T, + v8: T, + u9: T, + v10: T, + v11: T, + v12: T, + v13: T, + v14: T, + v15: T, + v16: T, + v17: T, + v18: T, + v19: T, + v20: T, + v21: T, + v22: T, + v23: T, + v24: T, + u25: T, + v26: T, + v27: T, + v28: T, + v29: T, + v30: T, + v31: T, +} + +struct S1k<T> { val: S32<S32<T>> } + +struct S1M<T> { val: S1k<S1k<T>> } + +fn main() { + let fat: Option<S1M<S1M<S1M<u32>>>> = None; +} diff --git a/src/test/compile-fail/issue-17913.rs b/src/test/compile-fail/issue-17913.rs new file mode 100644 index 00000000000..81f9ed991eb --- /dev/null +++ b/src/test/compile-fail/issue-17913.rs @@ -0,0 +1,25 @@ +// 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. + +// error-pattern: too big for the current architecture + +#[cfg(target_word_size = "64")] +fn main() { + let n = 0u; + let a = box [&n,..0xF000000000000000u]; + println!("{}", a[0xFFFFFFu]); +} + +#[cfg(target_word_size = "32")] +fn main() { + let n = 0u; + let a = box [&n,..0xFFFFFFFFu]; + println!("{}", a[0xFFFFFFu]); +} diff --git a/src/test/run-pass/vec-fixed-length.rs b/src/test/run-pass/vec-fixed-length.rs index 5116b4e746a..05a7388b5e2 100644 --- a/src/test/run-pass/vec-fixed-length.rs +++ b/src/test/run-pass/vec-fixed-length.rs @@ -20,7 +20,8 @@ pub fn main() { assert_eq!(size_of::<[u8, ..4]>(), 4u); // FIXME #10183 - if cfg!(target_word_size = "64") { - assert_eq!(size_of::<[u8, ..(1 << 32)]>(), (1u << 32)); - } + // FIXME #18069 + //if cfg!(target_word_size = "64") { + // assert_eq!(size_of::<[u8, ..(1 << 32)]>(), (1u << 32)); + //} } |
