Skip to content

Commit

Permalink
Prevent stackoverflow
Browse files Browse the repository at this point in the history
  • Loading branch information
hbina committed Sep 20, 2020
1 parent 2e0edc0 commit dc655b2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1864,14 +1865,25 @@ pub enum AssocTyConstraintKind {
Bound { bounds: GenericBounds },
}

#[derive(Clone, Encodable, Decodable, Debug)]
#[derive(Encodable, Decodable, Debug)]
pub struct Ty {
pub id: NodeId,
pub kind: TyKind,
pub span: Span,
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,
Expand Down

0 comments on commit dc655b2

Please sign in to comment.