Auto merge of #21769 - brooksbp:column-line-macro, r=nick29581

Please see discussion in #19284 .
This commit is contained in:
bors 2015-02-23 01:53:38 +00:00
commit f0f7ca27de
11 changed files with 66 additions and 15 deletions

View file

@ -148,6 +148,7 @@ pub trait AstBuilder {
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr>;
fn expr_int(&self, sp: Span, i: isize) -> P<ast::Expr>;
fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr>;
fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr>;
fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr>;
fn expr_vec(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr>;
@ -704,6 +705,9 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr> {
self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::TyU8)))
}
fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr> {
self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::TyU32)))
}
fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr> {
self.expr_lit(sp, ast::LitBool(value))
}

View file

@ -35,7 +35,7 @@ pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
let topmost = cx.original_span_in_file();
let loc = cx.codemap().lookup_char_pos(topmost.lo);
base::MacExpr::new(cx.expr_usize(topmost, loc.line))
base::MacExpr::new(cx.expr_u32(topmost, loc.line as u32))
}
/* column!(): expands to the current column number */
@ -45,7 +45,8 @@ pub fn expand_column(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
let topmost = cx.original_span_in_file();
let loc = cx.codemap().lookup_char_pos(topmost.lo);
base::MacExpr::new(cx.expr_usize(topmost, loc.col.to_usize()))
base::MacExpr::new(cx.expr_u32(topmost, loc.col.to_usize() as u32))
}
/// file!(): expands to the current filename */