cleanup: convert some remaining #foo invocations to foo! form.

This commit is contained in:
Graydon Hoare 2012-11-07 13:41:02 -08:00
parent 2b93ab5a21
commit 4e1ce014c8
15 changed files with 22 additions and 34 deletions

View file

@ -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. // and injected into each crate the compiler builds. Keep it small.
mod intrinsic { mod intrinsic {

View file

@ -1536,7 +1536,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
// Probably a bad error message (what's an rvalue?) // Probably a bad error message (what's an rvalue?)
// but I can't think of anything better // but I can't think of anything better
self.tcx.sess.span_err(arg_expr.span, 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, (move %s) instead", expr_to_str(*arg_expr,
self.tcx.sess.intr()))); self.tcx.sess.intr())));
} }

View file

@ -1533,7 +1533,7 @@ fn subst(cx: ctxt,
cx, typ, cx, typ,
|r| match r { |r| match r {
re_bound(br_self) => substs.self_r.expect( re_bound(br_self) => substs.self_r.expect(
#fmt("ty::subst: \ fmt!("ty::subst: \
Reference to self region when given substs with no \ Reference to self region when given substs with no \
self region, ty = %s", ty_to_str(cx, typ))), self region, ty = %s", ty_to_str(cx, typ))),
_ => r _ => r

View file

@ -2430,7 +2430,7 @@ fn check_enum_variants(ccx: @crate_ctxt,
} }
Err(err) => { Err(err) => {
ccx.tcx.sess.span_err(e.span, ccx.tcx.sess.span_err(e.span,
#fmt("expected constant: %s", err)); fmt!("expected constant: %s", err));
} }
} }

View file

@ -376,7 +376,7 @@ pub impl<D: Deserializer, T: Deserializable<D>> Option<T>: Deserializable<D> {
match i { match i {
0 => None, 0 => None,
1 => Some(d.read_enum_variant_arg(0u, || deserialize(d))), 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))
} }
} }
} }

View file

@ -57,7 +57,7 @@ fn expand_mod(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body)
fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
_body: ast::mac_body) -> @ast::expr { _body: ast::mac_body) -> @ast::expr {
let args = get_mac_args(cx, sp, arg, 1u, option::Some(1u), ~"include"); let args = get_mac_args(cx, sp, arg, 1u, option::Some(1u), ~"include");
let file = expr_to_str(cx, args[0], ~"#include_str requires a string"); let file = expr_to_str(cx, args[0], ~"include_str! requires a string");
let p = parse::new_parser_from_file(cx.parse_sess(), cx.cfg(), let p = parse::new_parser_from_file(cx.parse_sess(), cx.cfg(),
&res_rel_file(cx, sp, &Path(file)), &res_rel_file(cx, sp, &Path(file)),
parse::parser::SOURCE_FILE); parse::parser::SOURCE_FILE);
@ -68,7 +68,7 @@ fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
_body: ast::mac_body) -> @ast::expr { _body: ast::mac_body) -> @ast::expr {
let args = get_mac_args(cx,sp,arg,1u,option::Some(1u),~"include_str"); let args = get_mac_args(cx,sp,arg,1u,option::Some(1u),~"include_str");
let file = expr_to_str(cx, args[0], ~"#include_str requires a string"); let file = expr_to_str(cx, args[0], ~"include_str! requires a string");
let res = io::read_whole_file_str(&res_rel_file(cx, sp, &Path(file))); let res = io::read_whole_file_str(&res_rel_file(cx, sp, &Path(file)));
match res { match res {
@ -85,7 +85,7 @@ fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
_body: ast::mac_body) -> @ast::expr { _body: ast::mac_body) -> @ast::expr {
let args = get_mac_args(cx,sp,arg,1u,option::Some(1u),~"include_bin"); let args = get_mac_args(cx,sp,arg,1u,option::Some(1u),~"include_bin");
let file = expr_to_str(cx, args[0], ~"#include_bin requires a string"); let file = expr_to_str(cx, args[0], ~"include_bin! requires a string");
match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) { match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) {
result::Ok(src) => { result::Ok(src) => {

View file

@ -8,14 +8,12 @@ use std::map::{Map, HashMap};
use io::{Reader, ReaderUtil}; use io::{Reader, ReaderUtil};
macro_rules! bench (
($id:ident) => (maybe_run_test(argv, stringify!($id), $id))
)
fn main() { fn main() {
let argv = os::args(); let argv = os::args();
#macro[
[#bench[id],
maybe_run_test(argv, #stringify(id), id)
]
];
let tests = vec::view(argv, 1, argv.len()); let tests = vec::view(argv, 1, argv.len());
bench!(shift_push); bench!(shift_push);

View file

@ -18,12 +18,9 @@ proto! ring (
} }
) )
fn macros() { macro_rules! move_out (
#macro[ ($x:expr) => { unsafe { let y = move *ptr::addr_of(&$x); move y } }
[#move_out[x], )
unsafe { let y = move *ptr::addr_of(&x); move y }]
];
}
fn thread_ring(i: uint, fn thread_ring(i: uint,
count: uint, count: uint,

View file

@ -132,7 +132,7 @@ fn main() {
let args = os::args(); let args = os::args();
let rdr = if os::getenv(~"RUST_BENCH").is_some() { let rdr = if os::getenv(~"RUST_BENCH").is_some() {
// FIXME: Using this compile-time env variable is a crummy way to // FIXME: Using this compile-time env variable is a crummy way to
// get to this massive data set, but #include_bin chokes on it (#2598) // get to this massive data set, but include_bin! chokes on it (#2598)
let path = Path(env!("CFG_SRC_DIR")) let path = Path(env!("CFG_SRC_DIR"))
.push_rel(&Path("src/test/bench/shootout-k-nucleotide.data")); .push_rel(&Path("src/test/bench/shootout-k-nucleotide.data"));
result::get(&io::file_reader(&path)) result::get(&io::file_reader(&path))

View file

@ -129,7 +129,7 @@ fn main() {
let args = os::args(); let args = os::args();
let rdr = if os::getenv(~"RUST_BENCH").is_some() { let rdr = if os::getenv(~"RUST_BENCH").is_some() {
// FIXME: Using this compile-time env variable is a crummy way to // FIXME: Using this compile-time env variable is a crummy way to
// get to this massive data set, but #include_bin chokes on it (#2598) // get to this massive data set, but include_bin! chokes on it (#2598)
let path = Path(env!("CFG_SRC_DIR")) let path = Path(env!("CFG_SRC_DIR"))
.push_rel(&Path("src/test/bench/shootout-k-nucleotide.data")); .push_rel(&Path("src/test/bench/shootout-k-nucleotide.data"));
result::get(&io::file_reader(&path)) result::get(&io::file_reader(&path))

View file

@ -1,12 +1,12 @@
struct C { struct C {
x: int, x: int,
drop { drop {
#error("dropping: %?", self.x); error!("dropping: %?", self.x);
} }
} }
fn main() { fn main() {
let c = C{ x: 2}; let c = C{ x: 2};
let d = copy c; //~ ERROR copying a noncopyable value let d = copy c; //~ ERROR copying a noncopyable value
#error("%?", d.x); error!("%?", d.x);
} }

View file

@ -71,7 +71,7 @@ mod test {
#[test] #[test]
fn read_simple_board() { fn read_simple_board() {
let s = #include_str("./maps/contest1.map"); let s = include_str!("./maps/contest1.map");
io::with_str_reader(s, read_board_grid) io::with_str_reader(s, read_board_grid)
} }
} }

View file

@ -1,13 +1,6 @@
// xfail-pretty - token trees can't pretty print // xfail-pretty - token trees can't pretty print
fn main() { fn main() {
#macro[[#mylambda[x, body],
{
fn f(x: int) -> int { return body; }
f
}]];
assert (mylambda!(y, y * 2)(8) == 16);
macro_rules! mylambda_tt( macro_rules! mylambda_tt(
($x:ident, $body:expr) => { ($x:ident, $body:expr) => {

View file

@ -1,5 +1,5 @@
// xfail-test // xfail-test
fn main() { fn main() {
auto s = #shell { uname -a }; let s = shell!( uname -a );
log(debug, s); log(debug, s);
} }

View file

@ -1,5 +1,5 @@
// This test is brittle! // This test is brittle!
// xfail-pretty - the pretty tests lose path information, breaking #include // xfail-pretty - the pretty tests lose path information, breaking include!
#[legacy_exports]; #[legacy_exports];
mod m1 { mod m1 {