about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-05-06 04:15:02 +0000
committerbors <bors@rust-lang.org>2018-05-06 04:15:02 +0000
commitce0cb144fbfd361b48a7710d3eb8a576ffda7ef8 (patch)
tree71a7d2628c5e84a17e3d6e0a0c68ff3bb8eee297 /src
parent2c315475eaf22c1e1d1c3e8efc0f9d1c720eb886 (diff)
parent3e0ed2fc05780f2d2a0709fb2716631c9eaa47df (diff)
downloadrust-ce0cb144fbfd361b48a7710d3eb8a576ffda7ef8.tar.gz
rust-ce0cb144fbfd361b48a7710d3eb8a576ffda7ef8.zip
Auto merge of #50453 - alexcrichton:proc-macro-not-send, r=eddyb
proc_macro: Explicitly make everything !Send/Sync

This commit adds explicit imp blocks to ensure that all publicly exported types
(except simple enums) are not `Send` nor `Sync` in the `proc_macro` crate.

cc #38356
Diffstat (limited to 'src')
-rw-r--r--src/libproc_macro/lib.rs47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs
index f51dbc3772f..8451e5987e9 100644
--- a/src/libproc_macro/lib.rs
+++ b/src/libproc_macro/lib.rs
@@ -74,6 +74,11 @@ use syntax_pos::hygiene::Mark;
 #[derive(Clone)]
 pub struct TokenStream(tokenstream::TokenStream);
 
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Send for TokenStream {}
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Sync for TokenStream {}
+
 /// Error returned from `TokenStream::from_str`.
 #[stable(feature = "proc_macro_lib", since = "1.15.0")]
 #[derive(Debug)]
@@ -81,6 +86,11 @@ pub struct LexError {
     _inner: (),
 }
 
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Send for LexError {}
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Sync for LexError {}
+
 impl TokenStream {
     /// Returns an empty `TokenStream`.
     #[unstable(feature = "proc_macro", issue = "38356")]
@@ -231,6 +241,11 @@ pub fn quote_span(span: Span) -> TokenStream {
 #[derive(Copy, Clone)]
 pub struct Span(syntax_pos::Span);
 
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Send for Span {}
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Sync for Span {}
+
 macro_rules! diagnostic_method {
     ($name:ident, $level:expr) => (
         /// Create a new `Diagnostic` with the given `message` at the span
@@ -363,6 +378,11 @@ pub struct LineColumn {
     pub column: usize
 }
 
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Send for LineColumn {}
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Sync for LineColumn {}
+
 /// The source file of a given `Span`.
 #[unstable(feature = "proc_macro", issue = "38356")]
 #[derive(Clone)]
@@ -393,7 +413,7 @@ impl SourceFile {
 
     /// Returns `true` if this source file is a real source file, and not generated by an external
     /// macro's expansion.
-    # [unstable(feature = "proc_macro", issue = "38356")]
+    #[unstable(feature = "proc_macro", issue = "38356")]
     pub fn is_real(&self) -> bool {
         // This is a hack until intercrate spans are implemented and we can have real source files
         // for spans generated in external macros.
@@ -450,6 +470,11 @@ pub enum TokenTree {
     Literal(Literal),
 }
 
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Send for TokenTree {}
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Sync for TokenTree {}
+
 impl TokenTree {
     /// Returns the span of this token, accessing the `span` method of each of
     /// the internal tokens.
@@ -546,6 +571,11 @@ pub struct Group {
     span: Span,
 }
 
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Send for Group {}
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Sync for Group {}
+
 /// Describes how a sequence of token trees is delimited.
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 #[unstable(feature = "proc_macro", issue = "38356")]
@@ -628,6 +658,11 @@ pub struct Op {
     span: Span,
 }
 
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Send for Op {}
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Sync for Op {}
+
 /// Whether an `Op` is either followed immediately by another `Op` or followed by whitespace.
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 #[unstable(feature = "proc_macro", issue = "38356")]
@@ -694,6 +729,11 @@ pub struct Term {
     span: Span,
 }
 
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Send for Term {}
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Sync for Term {}
+
 impl Term {
     /// Creates a new `Term` with the given `string` as well as the specified
     /// `span`.
@@ -752,6 +792,11 @@ pub struct Literal {
     span: Span,
 }
 
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Send for Literal {}
+#[unstable(feature = "proc_macro", issue = "38356")]
+impl !Sync for Literal {}
+
 macro_rules! suffixed_int_literals {
     ($($name:ident => $kind:ident,)*) => ($(
         /// Creates a new suffixed integer literal with the specified value.