diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-11-26 20:49:36 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-12-04 10:04:51 -0500 |
| commit | cc32f867d8337cfb97fbddf832169dc79556e31d (patch) | |
| tree | 94a49893e7879d5124c0cea555d13e5a05306ec5 /src/libsyntax/diagnostics | |
| parent | 1e112e94c3cd71f792e59318f7f7197999e30cf6 (diff) | |
| download | rust-cc32f867d8337cfb97fbddf832169dc79556e31d.tar.gz rust-cc32f867d8337cfb97fbddf832169dc79556e31d.zip | |
Modify libsyntax/diagnostics to not be so persnickety. The scheme
doesn't work in a multi-crate context. We'll need to come up with something better.
Diffstat (limited to 'src/libsyntax/diagnostics')
| -rw-r--r-- | src/libsyntax/diagnostics/plugin.rs | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index 5f4e675aad5..2be11a236d3 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -45,15 +45,6 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt, [ast::TtToken(_, token::Ident(code, _))] => code, _ => unreachable!() }; - with_registered_diagnostics(|diagnostics| { - if !diagnostics.contains_key(&code.name) { - ecx.span_err(span, format!( - "unknown diagnostic code {}; add to librustc/diagnostics.rs", - token::get_ident(code).get() - ).as_slice()); - } - () - }); with_used_diagnostics(|diagnostics| { match diagnostics.insert(code.name, span) { Some(previous_span) => { @@ -106,25 +97,19 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt, _ => unreachable!() }; - let (count, expr) = with_used_diagnostics(|diagnostics_in_use| { + let (count, expr) = with_registered_diagnostics(|diagnostics| { - let descriptions: Vec<P<ast::Expr>> = diagnostics - .iter().filter_map(|(code, description)| { - if !diagnostics_in_use.contains_key(code) { - ecx.span_warn(span, format!( - "diagnostic code {} never used", token::get_name(*code).get() - ).as_slice()); - } - description.map(|description| { - ecx.expr_tuple(span, vec![ - ecx.expr_str(span, token::get_name(*code)), - ecx.expr_str(span, token::get_name(description)) - ]) - }) - }).collect(); + let descriptions: Vec<P<ast::Expr>> = + diagnostics.iter().filter_map(|(code, description)| { + description.map(|description| { + ecx.expr_tuple(span, vec![ + ecx.expr_str(span, token::get_name(*code)), + ecx.expr_str(span, token::get_name(description))]) + }) + }).collect(); (descriptions.len(), ecx.expr_vec(span, descriptions)) - }) - }); + }); + MacItems::new(vec![quote_item!(ecx, pub static $name: [(&'static str, &'static str), ..$count] = $expr; ).unwrap()].into_iter()) |
