Skip to content

Commit

Permalink
Rollup merge of rust-lang#35962 - regexident:compiler-plugin-docs, r=…
Browse files Browse the repository at this point in the history
…steveklabnik

Updated code sample in chapter on syntax extensions.

The affected API apparently had changed with commit d59accf.

---

Further more I had to add

```toml
[lib]
name = "roman_numerals"
crate-type = ["dylib"]
```

to `Cargo.toml` as I otherwise got this compiler error (despite `#![crate_type="dylib"]`):

    [E0457]: plugin `roman_numerals` only found in rlib format, but must be available in dylib format

Might be worth adding a note about that?
  • Loading branch information
GuillaumeGomez committed Aug 30, 2016
2 parents 325b711 + bf22a7a commit 8d808a2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/doc/book/compiler-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ extern crate rustc;
extern crate rustc_plugin;
use syntax::parse::token;
use syntax::ast::TokenTree;
use syntax::tokenstream::TokenTree;
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
use syntax::ext::build::AstBuilder; // trait for expr_usize
use syntax_pos::Span;
use syntax::ext::quote::rt::Span;
use rustc_plugin::Registry;
fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
Expand All @@ -69,7 +69,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
}
let text = match args[0] {
TokenTree::Token(_, token::Ident(s, _)) => s.to_string(),
TokenTree::Token(_, token::Ident(s)) => s.to_string(),
_ => {
cx.span_err(sp, "argument should be a single identifier");
return DummyResult::any(sp);
Expand Down

0 comments on commit 8d808a2

Please sign in to comment.