From 1ee345a87b05a4972e100f148819d2020c55381f Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Wed, 15 Oct 2014 01:53:37 +0300 Subject: add some tests --- src/test/compile-fail/issue-17913.rs | 17 ++++++++ src/test/compile-fail/oversized-array.rs | 20 +++++++++ src/test/compile-fail/oversized-discriminant.rs | 17 ++++++++ src/test/compile-fail/oversized-struct.rs | 54 +++++++++++++++++++++++++ src/test/compile-fail/simple-oversized-array.rs | 15 +++++++ 5 files changed, 123 insertions(+) create mode 100644 src/test/compile-fail/issue-17913.rs create mode 100644 src/test/compile-fail/oversized-array.rs create mode 100644 src/test/compile-fail/oversized-discriminant.rs create mode 100644 src/test/compile-fail/oversized-struct.rs create mode 100644 src/test/compile-fail/simple-oversized-array.rs (limited to 'src/test') diff --git a/src/test/compile-fail/issue-17913.rs b/src/test/compile-fail/issue-17913.rs new file mode 100644 index 00000000000..8420ea3f4b3 --- /dev/null +++ b/src/test/compile-fail/issue-17913.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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: too big for the current ABI + +fn main() { + let n = 0u; + let a = box [&n,..0xF000000000000000u]; + println!("{}", a[0xFFFFFFu]); +} diff --git a/src/test/compile-fail/oversized-array.rs b/src/test/compile-fail/oversized-array.rs new file mode 100644 index 00000000000..37a5bca424d --- /dev/null +++ b/src/test/compile-fail/oversized-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: 1518599999 + +fn generic(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/oversized-discriminant.rs b/src/test/compile-fail/oversized-discriminant.rs new file mode 100644 index 00000000000..92f9c41e7ea --- /dev/null +++ b/src/test/compile-fail/oversized-discriminant.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 or the MIT license +// , 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/oversized-struct.rs b/src/test/compile-fail/oversized-struct.rs new file mode 100644 index 00000000000..c1274ba1c01 --- /dev/null +++ b/src/test/compile-fail/oversized-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: are too big for the current ABI + +struct S32 { + 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 { val: S32> } + +struct S1M { val: S1k> } + +fn main() { + let fat: Option>>> = None; +} diff --git a/src/test/compile-fail/simple-oversized-array.rs b/src/test/compile-fail/simple-oversized-array.rs new file mode 100644 index 00000000000..3edabc0b5db --- /dev/null +++ b/src/test/compile-fail/simple-oversized-array.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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: too big for the current ABI + +fn main() { + let fat : [u8, ..1<<61] = [0, ..1<<61]; +} -- cgit 1.4.1-3-g733a5 From 61ab2ea08ae669711c5d9c0c069da2d0a8606639 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Wed, 15 Oct 2014 20:03:44 +0300 Subject: response for review comments --- src/librustc/middle/trans/context.rs | 4 +- src/librustc/middle/trans/controlflow.rs | 4 +- src/librustc/middle/trans/type_of.rs | 6 +-- src/test/compile-fail/huge-array-simple.rs | 15 +++++++ src/test/compile-fail/huge-array.rs | 20 +++++++++ src/test/compile-fail/huge-enum.rs | 17 ++++++++ src/test/compile-fail/huge-struct.rs | 54 +++++++++++++++++++++++++ src/test/compile-fail/oversized-array.rs | 20 --------- src/test/compile-fail/oversized-discriminant.rs | 17 -------- src/test/compile-fail/oversized-struct.rs | 54 ------------------------- src/test/compile-fail/simple-oversized-array.rs | 15 ------- 11 files changed, 113 insertions(+), 113 deletions(-) create mode 100644 src/test/compile-fail/huge-array-simple.rs create mode 100644 src/test/compile-fail/huge-array.rs create mode 100644 src/test/compile-fail/huge-enum.rs create mode 100644 src/test/compile-fail/huge-struct.rs delete mode 100644 src/test/compile-fail/oversized-array.rs delete mode 100644 src/test/compile-fail/oversized-discriminant.rs delete mode 100644 src/test/compile-fail/oversized-struct.rs delete mode 100644 src/test/compile-fail/simple-oversized-array.rs (limited to 'src/test') diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs index 0ef9cde56f9..9c37bd4ec14 100644 --- a/src/librustc/middle/trans/context.rs +++ b/src/librustc/middle/trans/context.rs @@ -720,12 +720,12 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { } pub fn max_obj_size(&self) -> u64 { - 1<<31 /* FIXME: select based on architecture */ + 1<<31 /* FIXME #18069: select based on architecture */ } pub fn report_overbig_object(&self, obj: ty::t) -> ! { self.sess().fatal( - format!("Objects of type `{}` are too big for the current ABI", + format!("the type `{}` is too big for the current architecture", obj.repr(self.tcx())).as_slice()) } } diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 3f08061ca88..bbd4233625f 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -499,7 +499,7 @@ pub fn trans_fail<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let loc = bcx.sess().codemap().lookup_char_pos(sp.lo); let filename = token::intern_and_get_ident(loc.file.name.as_slice()); let filename = C_str_slice(ccx, filename); - let line = C_int(ccx, loc.line as i64); + let line = C_uint(ccx, loc.line); let expr_file_line_const = C_struct(ccx, &[v_str, filename, line], false); let expr_file_line = consts::const_addr_of(ccx, expr_file_line_const, ast::MutImmutable); let args = vec!(expr_file_line); @@ -526,7 +526,7 @@ pub fn trans_fail_bounds_check<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // Invoke the lang item let filename = C_str_slice(ccx, filename); - let line = C_int(ccx, loc.line as i64); + let line = C_uint(ccx, loc.line); let file_line_const = C_struct(ccx, &[filename, line], false); let file_line = consts::const_addr_of(ccx, file_line_const, ast::MutImmutable); let args = vec!(file_line, index, len); diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 87b63478ea1..29bf3d3dc3d 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -28,9 +28,9 @@ use std::num::CheckedMul; // LLVM doesn't like objects that are too big. Issue #17913 fn ensure_array_fits_in_address_space(ccx: &CrateContext, - llet: Type, - size: machine::llsize, - scapegoat: ty::t) { + llet: Type, + size: machine::llsize, + scapegoat: ty::t) { let esz = machine::llsize_of_alloc(ccx, llet); match esz.checked_mul(&size) { Some(n) if n < ccx.max_obj_size() => {} 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..badaa4b922f --- /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 or the MIT license +// , 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] = [0, ..1<<61]; +} diff --git a/src/test/compile-fail/huge-array.rs b/src/test/compile-fail/huge-array.rs new file mode 100644 index 00000000000..37a5bca424d --- /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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: 1518599999 + +fn generic(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 or the MIT license +// , 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 or the MIT license +// , 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 { + 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 { val: S32> } + +struct S1M { val: S1k> } + +fn main() { + let fat: Option>>> = None; +} diff --git a/src/test/compile-fail/oversized-array.rs b/src/test/compile-fail/oversized-array.rs deleted file mode 100644 index 37a5bca424d..00000000000 --- a/src/test/compile-fail/oversized-array.rs +++ /dev/null @@ -1,20 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: 1518599999 - -fn generic(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/oversized-discriminant.rs b/src/test/compile-fail/oversized-discriminant.rs deleted file mode 100644 index 92f9c41e7ea..00000000000 --- a/src/test/compile-fail/oversized-discriminant.rs +++ /dev/null @@ -1,17 +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 or the MIT license -// , 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/oversized-struct.rs b/src/test/compile-fail/oversized-struct.rs deleted file mode 100644 index c1274ba1c01..00000000000 --- a/src/test/compile-fail/oversized-struct.rs +++ /dev/null @@ -1,54 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: are too big for the current ABI - -struct S32 { - 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 { val: S32> } - -struct S1M { val: S1k> } - -fn main() { - let fat: Option>>> = None; -} diff --git a/src/test/compile-fail/simple-oversized-array.rs b/src/test/compile-fail/simple-oversized-array.rs deleted file mode 100644 index 3edabc0b5db..00000000000 --- a/src/test/compile-fail/simple-oversized-array.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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: too big for the current ABI - -fn main() { - let fat : [u8, ..1<<61] = [0, ..1<<61]; -} -- cgit 1.4.1-3-g733a5 From ca27ccc8e7506e0b19257c7768803b10a53503b5 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Wed, 15 Oct 2014 23:57:01 +0300 Subject: fix a failing test --- src/test/run-pass/vec-fixed-length.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/test') 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)); + //} } -- cgit 1.4.1-3-g733a5 From 50db061173a2a54a9897e2d42f88b95d2b820cc4 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Thu, 16 Oct 2014 23:36:00 +0300 Subject: fix test patterns - should rebase the commits properly --- src/test/compile-fail/huge-array.rs | 2 +- src/test/compile-fail/issue-17913.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/compile-fail/huge-array.rs b/src/test/compile-fail/huge-array.rs index 37a5bca424d..4b91564154b 100644 --- a/src/test/compile-fail/huge-array.rs +++ b/src/test/compile-fail/huge-array.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: 1518599999 +// error-pattern: ..1518599999 fn generic(t: T) { let s: [T, ..1518600000] = [t, ..1518600000]; diff --git a/src/test/compile-fail/issue-17913.rs b/src/test/compile-fail/issue-17913.rs index 8420ea3f4b3..7baab03c119 100644 --- a/src/test/compile-fail/issue-17913.rs +++ b/src/test/compile-fail/issue-17913.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: too big for the current ABI +// error-pattern: too big for the current architecture fn main() { let n = 0u; -- cgit 1.4.1-3-g733a5 From 3ce5a9539fc7c20cf6a228bfc7d7fde03b9c6b93 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Fri, 17 Oct 2014 12:37:27 +0300 Subject: Make the tests green as they should on 32-bit architectures On 32-bit architectures, the size calculations on two of the tests wrap-around in typeck, which gives the relevant arrays a size of 0, which is (correctly) successfully allocated. --- src/test/compile-fail/huge-array-simple.rs | 2 +- src/test/compile-fail/issue-17913.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/compile-fail/huge-array-simple.rs b/src/test/compile-fail/huge-array-simple.rs index badaa4b922f..b23d0716e6d 100644 --- a/src/test/compile-fail/huge-array-simple.rs +++ b/src/test/compile-fail/huge-array-simple.rs @@ -11,5 +11,5 @@ // error-pattern: too big for the current fn main() { - let fat : [u8, ..1<<61] = [0, ..1<<61]; + let fat : [u8, ..(1<<61)+(1<<31)] = [0, ..(1<<61)+(1<<31)]; } diff --git a/src/test/compile-fail/issue-17913.rs b/src/test/compile-fail/issue-17913.rs index 7baab03c119..037674aaa07 100644 --- a/src/test/compile-fail/issue-17913.rs +++ b/src/test/compile-fail/issue-17913.rs @@ -10,8 +10,16 @@ // 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]); +} -- cgit 1.4.1-3-g733a5 From ccdf8d5b527538d8959b5c76bba917b5326027a8 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Sat, 18 Oct 2014 19:34:00 +0300 Subject: trailing whitespace --- src/test/compile-fail/issue-17913.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/compile-fail/issue-17913.rs b/src/test/compile-fail/issue-17913.rs index 037674aaa07..81f9ed991eb 100644 --- a/src/test/compile-fail/issue-17913.rs +++ b/src/test/compile-fail/issue-17913.rs @@ -16,7 +16,7 @@ fn main() { let a = box [&n,..0xF000000000000000u]; println!("{}", a[0xFFFFFFu]); } - + #[cfg(target_word_size = "32")] fn main() { let n = 0u; -- cgit 1.4.1-3-g733a5