diff options
| author | Michael Sproul <micsproul@gmail.com> | 2015-04-11 08:14:38 +1000 |
|---|---|---|
| committer | Michael Sproul <micsproul@gmail.com> | 2015-04-17 21:30:41 +1000 |
| commit | dd5eed4b8136849537d1b2c8655bd29dc976d89a (patch) | |
| tree | 1e404cc96138eb06608fcd98a973461aaeb379c4 /src/libsyntax/diagnostics/plugin.rs | |
| parent | b7fb57529aded92c4f470568e6b5ea7a5a28f6a4 (diff) | |
| download | rust-dd5eed4b8136849537d1b2c8655bd29dc976d89a.tar.gz rust-dd5eed4b8136849537d1b2c8655bd29dc976d89a.zip | |
Validate format of extended error descriptions.
Diffstat (limited to 'src/libsyntax/diagnostics/plugin.rs')
| -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!( |
