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

Lex doc comments as attributes #74

Merged
merged 1 commit into from
Apr 4, 2018
Merged

Lex doc comments as attributes #74

merged 1 commit into from
Apr 4, 2018

Conversation

alexcrichton
Copy link
Contributor

This means they no longer round trip but it should be more faithful to what
macro_rules! is doing

Closes #73

src/stable.rs Outdated
}
if let Ok((a, comment)) = doc_comment(input_no_ws) {
input = a;
trees.push(TokenTree::Op(Op::new('#', Spacing::Alone)));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is an inner doc comment //! or /*!, then we need both # !. See rust-lang/rust#49656.

This means they no longer round trip but it should be more faithful to what
macro_rules! is doing

Closes #73
@alexcrichton
Copy link
Contributor Author

Ok I've updated but I'm going to hold off on merging until syn's tests pass

@alexcrichton
Copy link
Contributor Author

@dtolnay hm so interestingly as expected this is causing some syn round trip tests to fail. I think they're of the category:

foo! {
    /// ...
}

That is, if you parse that with syn you'll get the #[doc = "..."] tokens, so when you quote! it and to_string it'll have the #[...] attribute tokens. With libsyntax, however, these tokens are different because the /// token isn't expanded to #[...] until it expands the macro. This in turn means that libsyntax parsing the original source stream and then parsing the to_string + quote stream looks different.

I think though those test can likely be ignored/updated, but I'm curious what you think?

@alexcrichton alexcrichton merged commit 6e05dac into master Apr 4, 2018
@alexcrichton alexcrichton deleted the lex-doc-comments branch April 4, 2018 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants