diff options
| -rw-r--r-- | src/libsyntax/diagnostics/plugin.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index 59fe3658437..de7964c9230 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -92,6 +92,18 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt, } _ => unreachable!() }; + // Check that the description starts and ends with a newline. + description.map(|raw_msg| { + let msg = raw_msg.as_str(); + let last = msg.len() - 1; + if &msg[0..1] != "\n" || &msg[last..] != "\n" { + ecx.span_err(span, &format!( + "description for error code {} doesn't start and end with a newline", + token::get_ident(*code) + )); + } + raw_msg + }); with_registered_diagnostics(|diagnostics| { if diagnostics.insert(code.name, description).is_some() { ecx.span_err(span, &format!( |
