Skip to content

Commit 3f0cb8c

Browse files
committed
Make SyntaxExtension thread-safe
1 parent 11ccc4c commit 3f0cb8c

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/libsyntax/ext/base.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use std::collections::HashMap;
2828
use std::iter;
2929
use std::path::PathBuf;
3030
use std::rc::Rc;
31-
use rustc_data_structures::sync::Lrc;
31+
use rustc_data_structures::sync::{self, Lrc};
3232
use std::default::Default;
3333
use tokenstream::{self, TokenStream};
3434

@@ -529,26 +529,26 @@ pub enum SyntaxExtension {
529529
/// `#[derive(...)]` is a `MultiItemDecorator`.
530530
///
531531
/// Prefer ProcMacro or MultiModifier since they are more flexible.
532-
MultiDecorator(Box<MultiItemDecorator>),
532+
MultiDecorator(Box<MultiItemDecorator + sync::Sync + sync::Send>),
533533

534534
/// A syntax extension that is attached to an item and modifies it
535535
/// in-place. Also allows decoration, i.e., creating new items.
536-
MultiModifier(Box<MultiItemModifier>),
536+
MultiModifier(Box<MultiItemModifier + sync::Sync + sync::Send>),
537537

538538
/// A function-like procedural macro. TokenStream -> TokenStream.
539-
ProcMacro(Box<ProcMacro>),
539+
ProcMacro(Box<ProcMacro + sync::Sync + sync::Send>),
540540

541541
/// An attribute-like procedural macro. TokenStream, TokenStream -> TokenStream.
542542
/// The first TokenSteam is the attribute, the second is the annotated item.
543543
/// Allows modification of the input items and adding new items, similar to
544544
/// MultiModifier, but uses TokenStreams, rather than AST nodes.
545-
AttrProcMacro(Box<AttrProcMacro>),
545+
AttrProcMacro(Box<AttrProcMacro + sync::Sync + sync::Send>),
546546

547547
/// A normal, function-like syntax extension.
548548
///
549549
/// `bytes!` is a `NormalTT`.
550550
NormalTT {
551-
expander: Box<TTMacroExpander>,
551+
expander: Box<TTMacroExpander + sync::Sync + sync::Send>,
552552
def_info: Option<(ast::NodeId, Span)>,
553553
/// Whether the contents of the macro can
554554
/// directly use `#[unstable]` things (true == yes).
@@ -563,21 +563,23 @@ pub enum SyntaxExtension {
563563
/// A function-like syntax extension that has an extra ident before
564564
/// the block.
565565
///
566-
IdentTT(Box<IdentMacroExpander>, Option<Span>, bool),
566+
IdentTT(Box<IdentMacroExpander + sync::Sync + sync::Send>, Option<Span>, bool),
567567

568568
/// An attribute-like procedural macro. TokenStream -> TokenStream.
569569
/// The input is the annotated item.
570570
/// Allows generating code to implement a Trait for a given struct
571571
/// or enum item.
572-
ProcMacroDerive(Box<MultiItemModifier>, Vec<Symbol> /* inert attribute names */),
572+
ProcMacroDerive(Box<MultiItemModifier +
573+
sync::Sync +
574+
sync::Send>, Vec<Symbol> /* inert attribute names */),
573575

574576
/// An attribute-like procedural macro that derives a builtin trait.
575577
BuiltinDerive(BuiltinDeriveFn),
576578

577579
/// A declarative macro, e.g. `macro m() {}`.
578580
///
579581
/// The second element is the definition site span.
580-
DeclMacro(Box<TTMacroExpander>, Option<(ast::NodeId, Span)>),
582+
DeclMacro(Box<TTMacroExpander + sync::Sync + sync::Send>, Option<(ast::NodeId, Span)>),
581583
}
582584

583585
impl SyntaxExtension {

src/libsyntax/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#![feature(const_atomic_usize_new)]
2929
#![feature(rustc_attrs)]
3030

31+
#![recursion_limit="256"]
32+
3133
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
3234
#[allow(unused_extern_crates)]
3335
extern crate rustc_cratesio_shim;

0 commit comments

Comments
 (0)