Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proc_macro: Explicitly make everything !Send/Sync #50453

Merged
merged 1 commit into from
May 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,23 @@ 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)]
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")]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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.
Expand Down