@@ -54,14 +54,21 @@ use rustc::plugin::Registry;
54
54
fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
55
55
-> Box<MacResult + 'static> {
56
56
57
- static NUMERALS: &'static [(&'static str, u32 )] = &[
57
+ static NUMERALS: &'static [(&'static str, usize )] = &[
58
58
("M", 1000), ("CM", 900), ("D", 500), ("CD", 400),
59
59
("C", 100), ("XC", 90), ("L", 50), ("XL", 40),
60
60
("X", 10), ("IX", 9), ("V", 5), ("IV", 4),
61
61
("I", 1)];
62
62
63
- let text = match args {
64
- [TokenTree::Token(_, token::Ident(s, _))] => s.to_string(),
63
+ if args.len() != 1 {
64
+ cx.span_err(
65
+ sp,
66
+ &format!("argument should be a single identifier, but got {} arguments", args.len()));
67
+ return DummyResult::any(sp);
68
+ }
69
+
70
+ let text = match args[0] {
71
+ TokenTree::Token(_, token::Ident(s, _)) => s.to_string(),
65
72
_ => {
66
73
cx.span_err(sp, "argument should be a single identifier");
67
74
return DummyResult::any(sp);
@@ -83,7 +90,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
83
90
}
84
91
}
85
92
86
- MacEager::expr(cx.expr_u32 (sp, total))
93
+ MacEager::expr(cx.expr_usize (sp, total))
87
94
}
88
95
89
96
#[plugin_registrar]
0 commit comments