Skip to content

rustc: bunch of frontend hacking in pursuit of removing old #macros #3936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/front/intrinsic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// NB: this file is #include_str'ed into the compiler, re-parsed
// NB: this file is include_str!'ed into the compiler, re-parsed
// and injected into each crate the compiler builds. Keep it small.

mod intrinsic {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
// Probably a bad error message (what's an rvalue?)
// but I can't think of anything better
self.tcx.sess.span_err(arg_expr.span,
#fmt("Move mode argument must be an rvalue: try \
fmt!("Move mode argument must be an rvalue: try \
(move %s) instead", expr_to_str(*arg_expr,
self.tcx.sess.intr())));
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,7 @@ fn subst(cx: ctxt,
cx, typ,
|r| match r {
re_bound(br_self) => substs.self_r.expect(
#fmt("ty::subst: \
fmt!("ty::subst: \
Reference to self region when given substs with no \
self region, ty = %s", ty_to_str(cx, typ))),
_ => r
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2425,7 +2425,7 @@ fn check_enum_variants(ccx: @crate_ctxt,
}
Err(err) => {
ccx.tcx.sess.span_err(e.span,
#fmt("expected constant: %s", err));
fmt!("expected constant: %s", err));

}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ pub impl<D: Deserializer, T: Deserializable<D>> Option<T>: Deserializable<D> {
match i {
0 => None,
1 => Some(d.read_enum_variant_arg(0u, || deserialize(d))),
_ => fail(#fmt("Bad variant for option: %u", i))
_ => fail(fmt!("Bad variant for option: %u", i))
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ fn syntax_expander_table() -> HashMap<~str, syntax_extension> {
ext::log_syntax::expand_syntax_ext));
syntax_expanders.insert(~"ast",
builtin(ext::qquote::expand_ast));
syntax_expanders.insert(~"quote",
builtin_expr_tt(ext::quote::expand_quote));
syntax_expanders.insert(~"line",
builtin(ext::source_util::expand_line));
syntax_expanders.insert(~"col",
Expand Down
70 changes: 53 additions & 17 deletions src/libsyntax/ext/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ fn mk_unary(cx: ext_ctxt, sp: span, op: ast::unop, e: @ast::expr)
cx.next_id(); // see ast_util::op_expr_callee_id
mk_expr(cx, sp, ast::expr_unary(op, e))
}
fn mk_raw_path(sp: span, idents: ~[ast::ident]) -> @ast::path {
let p : @ast::path = @{span: sp, global: false, idents: idents,
rp: None, types: ~[]};
return p;
}
fn mk_path(cx: ext_ctxt, sp: span, idents: ~[ast::ident]) ->
@ast::expr {
let path = @{span: sp, global: false, idents: idents,
rp: None, types: ~[]};
let pathexpr = ast::expr_path(path);
mk_expr(cx, sp, pathexpr)
mk_expr(cx, sp, ast::expr_path(mk_raw_path(sp, idents)))
}
fn mk_access_(cx: ext_ctxt, sp: span, p: @ast::expr, m: ast::ident)
-> @ast::expr {
Expand All @@ -53,7 +55,6 @@ fn mk_access(cx: ext_ctxt, sp: span, p: ~[ast::ident], m: ast::ident)
fn mk_addr_of(cx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
return mk_expr(cx, sp, ast::expr_addr_of(ast::m_imm, e));
}

fn mk_call_(cx: ext_ctxt, sp: span, fn_expr: @ast::expr,
args: ~[@ast::expr]) -> @ast::expr {
mk_expr(cx, sp, ast::expr_call(fn_expr, args, false))
Expand Down Expand Up @@ -90,19 +91,54 @@ fn mk_base_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr {
fn mk_uniq_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr {
mk_vstore_e(cx, sp, mk_base_str(cx, sp, s), ast::expr_vstore_uniq)
}

fn mk_field(sp: span, f: &{ident: ast::ident, ex: @ast::expr})
-> ast::field {
{node: {mutbl: ast::m_imm, ident: f.ident, expr: f.ex}, span: sp}
}
fn mk_fields(sp: span, fields: ~[{ident: ast::ident, ex: @ast::expr}]) ->
~[ast::field] {
move fields.map(|f| mk_field(sp, f))
}
fn mk_rec_e(cx: ext_ctxt, sp: span,
fields: ~[{ident: ast::ident, ex: @ast::expr}]) ->
@ast::expr {
let mut astfields: ~[ast::field] = ~[];
for fields.each |field| {
let ident = field.ident;
let val = field.ex;
let astfield =
{node: {mutbl: ast::m_imm, ident: ident, expr: val}, span: sp};
astfields.push(astfield);
}
let recexpr = ast::expr_rec(astfields, option::None::<@ast::expr>);
mk_expr(cx, sp, recexpr)
mk_expr(cx, sp, ast::expr_rec(mk_fields(sp, fields),
option::None::<@ast::expr>))
}
fn mk_struct_e(cx: ext_ctxt, sp: span,
ctor_path: ~[ast::ident],
fields: ~[{ident: ast::ident, ex: @ast::expr}]) ->
@ast::expr {
mk_expr(cx, sp,
ast::expr_struct(mk_raw_path(sp, ctor_path),
mk_fields(sp, fields),
option::None::<@ast::expr>))
}
fn mk_glob_use(cx: ext_ctxt, sp: span,
path: ~[ast::ident]) -> @ast::view_item {
let glob = @{node: ast::view_path_glob(mk_raw_path(sp, path),
cx.next_id()),
span: sp};
@{node: ast::view_item_import(~[glob]),
attrs: ~[],
vis: ast::private,
span: sp}
}
fn mk_block(cx: ext_ctxt, sp: span,
view_items: ~[@ast::view_item],
stmts: ~[@ast::stmt],
expr: Option<@ast::expr>) -> @ast::expr {
let blk = {node: {view_items: view_items,
stmts: stmts,
expr: expr,
id: cx.next_id(),
rules: ast::default_blk },
span: sp };
mk_expr(cx, sp, ast::expr_block(blk))
}
fn mk_copy(cx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
mk_expr(cx, sp, ast::expr_copy(e))
}
fn mk_managed(cx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
mk_expr(cx, sp, ast::expr_unary(ast::box(ast::m_imm), e))
}

Loading