Uh oh!
There was an error while loading. Please reload this page.
Document the proc_macro feature in the Unstable Book - #41476
Conversation
There was a problem hiding this comment.
Do I need to show adding the dependency on my_macro_crate to my_macro_user/Cargo.toml?
There was a problem hiding this comment.
Maybe at the top where I show adding the [lib] proc-macro = true section, so it doesn't get repetitive? Or do we want to make the dependency relationship clearer in this specific example (and presumably in its sibling below as well)?
abonander
commented
Apr 23, 2017
I realized I used "which" a lot and now it's bothering me. |
abonander
commented
Apr 23, 2017
I would like to have doctesting work for the code examples but I don't think doctests can test code snippets as separate crates. |
steveklabnik
left a comment
There was a problem hiding this comment.
this is a great start 👍
There was a problem hiding this comment.
Usually, it's better to write things in a "timeless" way, if that makes any sense. Basically, if we miss updating these docs when different error reporting stuff is added, does this still make sense? With this phrasing, it doesn't, but if you remove the first sentence, it does. We might be able to find a way to re-phrase the first sentence too...
There was a problem hiding this comment.
If that's the convention you want to enforce, I won't argue it.
But in my mind, saying "currently" tends to encourage the reader to be a little more forgiving with outdated information (context helps, being the "unstable" book and all). If that first bit was dropped so that it read "The only support for error reporting [...]" and then that fact changed later without the book updating, it would seem... disingenuous? Something like that.
I would also note that using "currently" tells the reader to expect this aspect to change/improve in the future, though I guess they've probably already acknowledged that by this point.
There was a problem hiding this comment.
Eh, after some consideration, dropping the whole first sentence seems okay.
There was a problem hiding this comment.
(context helps, being the "unstable" book and all)
I think this might be it, that is, it's true that for now, this stuff is not too stable, but we also don't want to do too much massaging once things actually need to go in stable places. It's possible I'm thinking too much of the future here.
I would also note that using "currently" tells the reader to expect this aspect to change/improve in the future,
Right, so the problem with this has been that in the future, changes get made, and then docs don't change, and then they're left with the incorrect impression that changes never happened. It's just tough.
Regardless, all of this is fairly minor and I'm happy to land it either way, to be honest. As you said, it is the unstable book 😄
There was a problem hiding this comment.
Just a note, I like ()s because it distinguishes functions from public fields in this kind of context.
There was a problem hiding this comment.
I also prefer it, unfortunately, the RFC process yielded different results 😄
There was a problem hiding this comment.
we do need to sort out these names at some point 😄
There was a problem hiding this comment.
I'm personally leaning towards "function-like" just because it sounds more formal. "bang" or "bang-style" just does not sound like it belongs in a technical document.
There was a problem hiding this comment.
Actually, is mentioning both all that bad? It might help the reader if they later come across discussions where the two terms are used interchangeably.
There was a problem hiding this comment.
nudging people toward proper use is a good idea, IMHO. there's no reason to have two names.
There was a problem hiding this comment.
I wonder if we should steal the formatting from the book:
Check out the *src/main.rs* file:
<span class="filename">Filename: src/main.rs</span>
```rust
fn main() {
println!("Hello, world!");
}
```
There was a problem hiding this comment.
At what point does it stop being "stealing" and becomes "following convention"? 😄
abonander
commented
Apr 24, 2017
@steveklabnik Requested revisions made. Now I'm mainly just waiting for an executive decision from either @nrc or @jseyfried on the preferred terminology as mentioned above. |
abonander
commented
Apr 25, 2017
@steveklabnik Weird error in the test failure, it's trying to test a slice of an ignored code block...? |
Mark-Simulacrum
commented
Apr 25, 2017
I suspect that the placing of the filename directly above the code block is causing the parser (hoedown? pulldown? I don't recall what we're at right now) to misinterpret the code block somehow. Perhaps a blank line would be a good idea. |
abonander
commented
Apr 25, 2017
Worth a shot but the other code blocks work fine so it's weird. It's also starting to interpret the code block halfway through it as far as I can tell. |
steveklabnik
commented
Apr 25, 2017
/cc @GuillaumeGomez for the weird errors |
We're back to hoedown so it should be the old (and long running) doc test system. Ping me if you can't figure it out once tests finished. |
abonander
commented
Apr 25, 2017
Huh, looks like these latest test failures are truly unrelated. |
abonander
commented
Apr 26, 2017
@steveklabnik Can you get bors to retry the build? |
GuillaumeGomez
commented
Apr 27, 2017
@bors: retry |
alexcrichton
commented
May 4, 2017
@steveklabnik it looks like some updates have happened since you last took a look I think, mind taking another look? |
abonander
commented
May 4, 2017
Still waiting on answers to the questions in the OP as well. @jseyfried@nrc |
steveklabnik
commented
May 9, 2017
This looks great to me; we still have the naming question to resolve though. Unsure exactly how best to do that... |
Mark-Simulacrum
commented
May 14, 2017
@jseyfried@nrc Is there a chance you could take a look and provide some thoughts on the naming? Specifically, what do we call function-like / bang-macros? note: Also pinged @nrc on IRC; jseyfried wasn't present. |
nrc
commented
May 15, 2017
Hey, sorry I missed the earlier pings - I was on parental leave and then had to rather forcefully clear my inbox. I definitely prefer 'function-like' to 'bang' macros - I think it is highly likely that readers will not associate |
There was a problem hiding this comment.
I call these 'attribute-like' since they only look like attributes and are implemented differently - also for symmetry with 'function-like'
There was a problem hiding this comment.
I wouldn't describe these as the main APIs - they are kind of a stop-gap measure for custom derives. Macro authors should prefer using quote! to create tokens. (And of course more APIs will be arriving in the future).
There was a problem hiding this comment.
terminology nit - I prefer 'declarative macros' to 'macro_rules! macros' since the former is a descriptive name and the latter is a detail of how they are (currently) declared.
abonander
commented
May 15, 2017
@nrc nits fixed |
steveklabnik
commented
May 15, 2017
r? @nrc |
nrc
commented
May 16, 2017
@bors: r+ |
proc_macro feature in the Unstable Bookproc_macro feature in the Unstable Bookabonander
commented
May 16, 2017
@nrc squashed and PR post cleaned up. |
Mark-Simulacrum
commented
May 16, 2017
@bors r=nrc |
bors
commented
May 16, 2017
📌 Commit e4208d5 has been approved by |
bors
commented
May 16, 2017
⌛ Testing commit e4208d5 with merge 88d44aa... |
bors
commented
May 16, 2017
💔 Test failed - status-travis |
abonander
commented
May 16, 2017
Can I get an @bors retry |
abonander
commented
May 16, 2017
Ugh, it's hitting a wall with the broken-link-checker, on a relative link to the chapter for |
steveklabnik
commented
May 16, 2017
Hm, I am not sure why it fails in that case, looks right to me. @frewsxcv any ideas? |
alexcrichton
commented
May 16, 2017
It looks like CI is still failing? |
frewsxcv
commented
May 16, 2017
@abonander can you try rebasing this off master? there's a chance this could be fixed with #41992, not entirely sure though what's going on with the linkchecker |
abonander
commented
May 16, 2017
Rebased, let's see. |
abonander
commented
May 17, 2017
I think the link is supposed to be to |
frewsxcv
commented
May 17, 2017
So it turns out that for subdirectories (like Anyways, tests seem to be passing now so: @bors r=nrc |
bors
commented
May 17, 2017
📌 Commit e616d12 has been approved by |
bors
commented
May 17, 2017
Document the `proc_macro` feature in the Unstable Book Discusses the `proc_macro` feature flag and the features it enables: * Implicit enable of `extern_use_macros` feature and how to import proc macros * Error handling in proc macros (using panic messages) * Function-like proc macros using `#[proc_macro]` and a usage example for creating and invoking * Attribute-like proc macros using `#[proc_macro_attribute]` and a usage example for creating and invoking [Rendered](https://github.com/abonander/rust/blob/book_proc_macro/src/doc/unstable-book/src/language-features/proc-macro.md)
bors
commented
May 17, 2017
☀️ Test successful - status-appveyor, status-travis |
Discusses the
proc_macrofeature flag and the features it enables:extern_use_macrosfeature and how to import proc macros#[proc_macro]and a usage example for creating and invoking#[proc_macro_attribute]and a usage example for creating and invokingRendered