diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-01-18 01:53:10 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-01-18 02:03:04 +1100 |
| commit | 4be3262058a151699cb66f95cbdcf39cf0263a83 (patch) | |
| tree | 238b722025df2639984d7f1cb0d64e0369cf19c1 /src/libsyntax/ext/source_util.rs | |
| parent | 5fdc81262a5d44f10e335384b5d69b938d6d729c (diff) | |
| download | rust-4be3262058a151699cb66f95cbdcf39cf0263a83.tar.gz rust-4be3262058a151699cb66f95cbdcf39cf0263a83.zip | |
syntax::ext: replace span_fatal with span_err in many places.
This means that compilation continues for longer, and so we can see more errors per compile. This is mildly more user-friendly because it stops users having to run rustc n times to see n macro errors: just run it once to see all of them.
Diffstat (limited to 'src/libsyntax/ext/source_util.rs')
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 3e781451b08..711f8ff11ee 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -79,7 +79,10 @@ pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) // unhygienically. pub fn expand_include(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { - let file = get_single_str_from_tts(cx, sp, tts, "include!"); + let file = match get_single_str_from_tts(cx, sp, tts, "include!") { + Some(f) => f, + None => return MacResult::dummy_expr(), + }; // The file will be added to the code map by the parser let mut p = parse::new_sub_parser_from_file(cx.parse_sess(), @@ -94,12 +97,15 @@ pub fn expand_include(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) // include_str! : read the given file, insert it as a literal string expr pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { - let file = get_single_str_from_tts(cx, sp, tts, "include_str!"); + let file = match get_single_str_from_tts(cx, sp, tts, "include_str!") { + Some(f) => f, + None => return MacResult::dummy_expr() + }; let file = res_rel_file(cx, sp, &Path::new(file)); let bytes = match io::result(|| File::open(&file).read_to_end()) { Err(e) => { - cx.span_fatal(sp, format!("couldn't read {}: {}", - file.display(), e.desc)); + cx.span_err(sp, format!("couldn't read {}: {}", file.display(), e.desc)); + return MacResult::dummy_expr(); } Ok(bytes) => bytes, }; @@ -114,7 +120,8 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) base::MRExpr(cx.expr_str(sp, src)) } None => { - cx.span_fatal(sp, format!("{} wasn't a utf-8 file", file.display())); + cx.span_err(sp, format!("{} wasn't a utf-8 file", file.display())); + return MacResult::dummy_expr(); } } } @@ -124,12 +131,15 @@ pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) { use std::at_vec; - let file = get_single_str_from_tts(cx, sp, tts, "include_bin!"); + let file = match get_single_str_from_tts(cx, sp, tts, "include_bin!") { + Some(f) => f, + None => return MacResult::dummy_expr() + }; let file = res_rel_file(cx, sp, &Path::new(file)); match io::result(|| File::open(&file).read_to_end()) { Err(e) => { - cx.span_fatal(sp, format!("couldn't read {}: {}", - file.display(), e.desc)); + cx.span_err(sp, format!("couldn't read {}: {}", file.display(), e.desc)); + return MacResult::dummy_expr(); } Ok(bytes) => { let bytes = at_vec::to_managed_move(bytes); |
