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.
This commit is contained in:
Ariel Ben-Yehuda 2016-11-15 23:25:59 +02:00
parent 908dba0c94
commit 242cd7ebe2
9 changed files with 137 additions and 7 deletions

View file

@ -10,7 +10,8 @@
#![allow(unused)]
#![recursion_limit = "32"]
#![recursion_limit = "20"]
#![type_length_limit = "20000000"]
#[derive(Clone)]
struct A (B);

View file

@ -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);
}

View file

@ -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();
}

View file

@ -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