Skip to content

Commit ead9ab8

Browse files
committed
Auto merge of #23167 - rprichard:fix-plugin-rustbook, r=steveklabnik
* "let mut text" was previously of &String type. Now it is of &str type. * Update the slicing syntax. Both &text[] and text.slice_from() evaluate to a &str. * We were passing a u32 to expr_usize. Call expr_u32 instead. r? @steveklabnik Fixes #23166
2 parents b2f09c1 + 52124d7 commit ead9ab8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/doc/trpl/plugins.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ that implements Roman numeral integer literals.
6363

6464
```ignore
6565
#![crate_type="dylib"]
66-
#![feature(plugin_registrar)]
66+
#![feature(plugin_registrar, rustc_private)]
6767
6868
extern crate syntax;
6969
extern crate rustc;
@@ -92,13 +92,13 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
9292
}
9393
};
9494
95-
let mut text = &text;
95+
let mut text = &*text;
9696
let mut total = 0;
9797
while !text.is_empty() {
9898
match NUMERALS.iter().find(|&&(rn, _)| text.starts_with(rn)) {
9999
Some(&(rn, val)) => {
100100
total += val;
101-
text = text.slice_from(rn.len());
101+
text = &text[rn.len()..];
102102
}
103103
None => {
104104
cx.span_err(sp, "invalid Roman numeral");
@@ -107,7 +107,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
107107
}
108108
}
109109
110-
MacEager::expr(cx.expr_usize(sp, total))
110+
MacEager::expr(cx.expr_u32(sp, total))
111111
}
112112
113113
#[plugin_registrar]

0 commit comments

Comments
 (0)