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:
parent
908dba0c94
commit
242cd7ebe2
9 changed files with 137 additions and 7 deletions
|
|
@ -10,7 +10,8 @@
|
|||
|
||||
#![allow(unused)]
|
||||
|
||||
#![recursion_limit = "32"]
|
||||
#![recursion_limit = "20"]
|
||||
#![type_length_limit = "20000000"]
|
||||
|
||||
#[derive(Clone)]
|
||||
struct A (B);
|
||||
|
|
|
|||
35
src/test/compile-fail/type_length_limit.rs
Normal file
35
src/test/compile-fail/type_length_limit.rs
Normal 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);
|
||||
}
|
||||
30
src/test/ui/issue-37311-type-length-limit/issue-37311.rs
Normal file
30
src/test/ui/issue-37311-type-length-limit/issue-37311.rs
Normal 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();
|
||||
}
|
||||
13
src/test/ui/issue-37311-type-length-limit/issue-37311.stderr
Normal file
13
src/test/ui/issue-37311-type-length-limit/issue-37311.stderr
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue