libsyntax: De-@str literal strings in the AST
This commit is contained in:
committed by
Huon Wilson
parent
70c5a0fbf7
commit
8e52b85d5a
@@ -16,7 +16,8 @@ use ext::base::*;
|
||||
use ext::base;
|
||||
use ext::build::AstBuilder;
|
||||
use parse;
|
||||
use parse::token::{get_ident_interner};
|
||||
use parse::token::get_ident_interner;
|
||||
use parse::token;
|
||||
use print::pprust;
|
||||
|
||||
use std::io;
|
||||
@@ -57,21 +58,21 @@ pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
||||
|
||||
let topmost = topmost_expn_info(cx.backtrace().unwrap());
|
||||
let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo);
|
||||
let filename = loc.file.name;
|
||||
let filename = token::intern_and_get_ident(loc.file.name);
|
||||
base::MRExpr(cx.expr_str(topmost.call_site, filename))
|
||||
}
|
||||
|
||||
pub fn expand_stringify(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
||||
-> base::MacResult {
|
||||
let s = pprust::tts_to_str(tts, get_ident_interner());
|
||||
base::MRExpr(cx.expr_str(sp, s.to_managed()))
|
||||
base::MRExpr(cx.expr_str(sp, token::intern_and_get_ident(s)))
|
||||
}
|
||||
|
||||
pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
||||
-> base::MacResult {
|
||||
base::check_zero_tts(cx, sp, tts, "module_path!");
|
||||
base::MRExpr(cx.expr_str(sp,
|
||||
cx.mod_path().map(|x| cx.str_of(*x)).connect("::").to_managed()))
|
||||
let string = cx.mod_path().map(|x| cx.str_of(*x)).connect("::");
|
||||
base::MRExpr(cx.expr_str(sp, token::intern_and_get_ident(string)))
|
||||
}
|
||||
|
||||
// include! : parse the given file as an expr
|
||||
@@ -117,7 +118,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
||||
let filename = file.display().to_str().to_managed();
|
||||
cx.parse_sess.cm.new_filemap(filename, src);
|
||||
|
||||
base::MRExpr(cx.expr_str(sp, src))
|
||||
base::MRExpr(cx.expr_str(sp, token::intern_and_get_ident(src)))
|
||||
}
|
||||
None => {
|
||||
cx.span_err(sp, format!("{} wasn't a utf-8 file", file.display()));
|
||||
|
||||
Reference in New Issue
Block a user