diff options
| author | bors <bors@rust-lang.org> | 2020-10-07 21:51:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-10-07 21:51:12 +0000 |
| commit | 91a79fb29ac78d057d04dbe86be13d5dcc64309a (patch) | |
| tree | beed74a7661470813b008a4c1b58e48d2765a7b3 | |
| parent | 4437b4b1509c3c15b41a05489c4bddd2fe30e33f (diff) | |
| parent | dc655b28424549a4775bc2e8c9021d44482bccb1 (diff) | |
| download | rust-91a79fb29ac78d057d04dbe86be13d5dcc64309a.tar.gz rust-91a79fb29ac78d057d04dbe86be13d5dcc64309a.zip | |
Auto merge of #76985 - hbina:clone_check, r=estebank
Prevent stack overflow in deeply nested types. Related issue #75577 (?) Unfortunately, I am unable to test whether this actually solves the problem because apparently, 12GB RAM + 2GB swap is not enough to compile the (admittedly toy) source file.
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 492d5788fc0..8d9d4123c79 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -27,6 +27,7 @@ use crate::token::{self, CommentKind, DelimToken}; use crate::tokenstream::{DelimSpan, TokenStream, TokenTree}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::sync::Lrc; use rustc_data_structures::thin_vec::ThinVec; use rustc_macros::HashStable_Generic; @@ -1864,7 +1865,7 @@ pub enum AssocTyConstraintKind { Bound { bounds: GenericBounds }, } -#[derive(Clone, Encodable, Decodable, Debug)] +#[derive(Encodable, Decodable, Debug)] pub struct Ty { pub id: NodeId, pub kind: TyKind, @@ -1872,6 +1873,17 @@ pub struct Ty { pub tokens: Option<TokenStream>, } +impl Clone for Ty { + fn clone(&self) -> Self { + ensure_sufficient_stack(|| Self { + id: self.id, + kind: self.kind.clone(), + span: self.span, + tokens: self.tokens.clone(), + }) + } +} + #[derive(Clone, Encodable, Decodable, Debug)] pub struct BareFnTy { pub unsafety: Unsafe, |
