diff options
| author | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2016-11-15 23:25:59 +0200 |
|---|---|---|
| committer | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2016-12-02 00:54:22 +0200 |
| commit | 242cd7ebe295d44c7b612e2e1da8b83412d31f49 (patch) | |
| tree | efd32ff8f3e43532eb32d66e57c676375920885e /src/test | |
| parent | 908dba0c9477b7dd022a236cb1514ddfca9369f2 (diff) | |
| download | rust-242cd7ebe295d44c7b612e2e1da8b83412d31f49.tar.gz rust-242cd7ebe295d44c7b612e2e1da8b83412d31f49.zip | |
limit the length of types in monomorphization
This adds the new insta-stable `#![type_size_limit]` crate attribute to control the limit, and is obviously a [breaking-change] fixable by that.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/issue-22638.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/type_length_limit.rs | 35 | ||||
| -rw-r--r-- | src/test/ui/issue-37311-type-length-limit/issue-37311.rs | 30 | ||||
| -rw-r--r-- | src/test/ui/issue-37311-type-length-limit/issue-37311.stderr | 13 |
4 files changed, 80 insertions, 1 deletions
diff --git a/src/test/compile-fail/issue-22638.rs b/src/test/compile-fail/issue-22638.rs index 0c8c2311dca..65d1d837d7d 100644 --- a/src/test/compile-fail/issue-22638.rs +++ b/src/test/compile-fail/issue-22638.rs @@ -10,7 +10,8 @@ #![allow(unused)] -#![recursion_limit = "32"] +#![recursion_limit = "20"] +#![type_length_limit = "20000000"] #[derive(Clone)] struct A (B); diff --git a/src/test/compile-fail/type_length_limit.rs b/src/test/compile-fail/type_length_limit.rs new file mode 100644 index 00000000000..d283f392d76 --- /dev/null +++ b/src/test/compile-fail/type_length_limit.rs @@ -0,0 +1,35 @@ +// Copyright 2016 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: reached the type-length limit while instantiating + +// Test that the type length limit can be changed. + +#![allow(dead_code)] +#![type_length_limit="256"] + +macro_rules! link { + ($id:ident, $t:ty) => { + pub type $id = ($t, $t, $t); + } +} + +link! { A, B } +link! { B, C } +link! { C, D } +link! { D, E } +link! { E, F } +link! { F, G } + +pub struct G; + +fn main() { + drop::<Option<A>>(None); +} diff --git a/src/test/ui/issue-37311-type-length-limit/issue-37311.rs b/src/test/ui/issue-37311-type-length-limit/issue-37311.rs new file mode 100644 index 00000000000..add96461f1b --- /dev/null +++ b/src/test/ui/issue-37311-type-length-limit/issue-37311.rs @@ -0,0 +1,30 @@ +// Copyright 2016 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. + +trait Mirror { + type Image; +} + +impl<T> Mirror for T { type Image = T; } + +trait Foo { + fn recurse(&self); +} + +impl<T> Foo for T { + #[allow(unconditional_recursion)] + fn recurse(&self) { + (self, self).recurse(); + } +} + +fn main() { + ().recurse(); +} diff --git a/src/test/ui/issue-37311-type-length-limit/issue-37311.stderr b/src/test/ui/issue-37311-type-length-limit/issue-37311.stderr new file mode 100644 index 00000000000..5a63d235a7f --- /dev/null +++ b/src/test/ui/issue-37311-type-length-limit/issue-37311.stderr @@ -0,0 +1,13 @@ +error: reached the type-length limit while instantiating `<T as Foo><(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(), &()), &(&()...` + --> $DIR/issue-37311.rs:23:5 + | +23 | fn recurse(&self) { + | _____^ starting here... +24 | | (self, self).recurse(); +25 | | } + | |_____^ ...ending here + | + = note: consider adding a `#![type_length_limit="2097152"]` attribute to your crate + +error: aborting due to previous error + |
