Closed
Description
This is an unfortunate consequence of the fix for #15750.
plugin.rs
:
#![crate_type="dylib"]
#![feature(plugin_registrar, quote)]
extern crate syntax;
extern crate rustc;
use rustc::plugin::Registry;
use syntax::codemap::Span;
use syntax::ext::base::{ExtCtxt, MacResult, MacExpr};
use syntax::parse;
use syntax::ast;
fn expand(cx: &mut ExtCtxt, _span: Span, tts: &[ast::TokenTree])
-> Box<MacResult+'static> {
// Parse an expression and emit it unchanged.
let mut parser = parse::new_parser_from_tts(cx.parse_sess(),
cx.cfg(), Vec::from_slice(tts));
let expr = parser.parse_expr();
MacExpr::new(quote_expr!(&mut *cx, $expr))
}
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_macro("mymacro", expand);
}
test.rs
:
#![feature(phase)]
#[phase(plugin)]
extern crate plugin;
fn main() {
let x: int = 3;
let y: uint = 4;
println!("{}", mymacro!(x + y));
}
Result:
$ rustc -L . test.rs
<quote expansion>:1:21: 1:38 error: mismatched types: expected `int`, found `uint` (expected int, found uint)
<quote expansion>:1 name_60,ctxt_12 + name_63,ctxt_12
^~~~~~~~~~~~~~~~~
test.rs:1:1: 10:1 note: in expansion of mymacro!
test.rs:9:20: 9:35 note: expansion site
note: in expansion of format_args!
<std macros>:2:23: 2:77 note: expansion site
<std macros>:1:1: 3:2 note: in expansion of println!
test.rs:9:5: 9:37 note: expansion site
error: aborting due to previous error
The error output actually contains NULL characters, which is why the caret is misaligned.