Skip to content

Commit dc655b2

Browse files
committed
Prevent stackoverflow
1 parent 2e0edc0 commit dc655b2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

compiler/rustc_ast/src/ast.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use crate::token::{self, CommentKind, DelimToken};
2727
use crate::tokenstream::{DelimSpan, TokenStream, TokenTree};
2828

2929
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
30+
use rustc_data_structures::stack::ensure_sufficient_stack;
3031
use rustc_data_structures::sync::Lrc;
3132
use rustc_data_structures::thin_vec::ThinVec;
3233
use rustc_macros::HashStable_Generic;
@@ -1864,14 +1865,25 @@ pub enum AssocTyConstraintKind {
18641865
Bound { bounds: GenericBounds },
18651866
}
18661867

1867-
#[derive(Clone, Encodable, Decodable, Debug)]
1868+
#[derive(Encodable, Decodable, Debug)]
18681869
pub struct Ty {
18691870
pub id: NodeId,
18701871
pub kind: TyKind,
18711872
pub span: Span,
18721873
pub tokens: Option<TokenStream>,
18731874
}
18741875

1876+
impl Clone for Ty {
1877+
fn clone(&self) -> Self {
1878+
ensure_sufficient_stack(|| Self {
1879+
id: self.id,
1880+
kind: self.kind.clone(),
1881+
span: self.span,
1882+
tokens: self.tokens.clone(),
1883+
})
1884+
}
1885+
}
1886+
18751887
#[derive(Clone, Encodable, Decodable, Debug)]
18761888
pub struct BareFnTy {
18771889
pub unsafety: Unsafe,

0 commit comments

Comments
 (0)