diff options
| author | bors <bors@rust-lang.org> | 2015-06-15 01:57:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-06-15 01:57:17 +0000 |
| commit | 7d046230338e117c8a7c85bb4d542f2787d5ef9d (patch) | |
| tree | 8f6e4abc1082b4f91251bc76338663f6f41349ed /src/libsyntax | |
| parent | 8937ec10041e7cb9edaeb87f0d5a721a8be6c8df (diff) | |
| parent | 328df8ebf9dc35d48c7aa829425413af3fc3a08c (diff) | |
| download | rust-7d046230338e117c8a7c85bb4d542f2787d5ef9d.tar.gz rust-7d046230338e117c8a7c85bb4d542f2787d5ef9d.zip | |
Auto merge of #26290 - michaelsproul:url-line-limit, r=alexcrichton
The plugin that enforces error explanation line-length is a bit restrictive, particularly when attempting to use URLs in explanations (cf #26163). Jashank will still have to do some mucking around with `#[cfg(not(stage0))]` attributes or else wait until a snapshot with this commit lands.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/diagnostics/plugin.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index 54b09d863a3..2f7e4a16145 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -99,6 +99,7 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt, } _ => unreachable!() }; + // Check that the description starts and ends with a newline and doesn't // overflow the maximum line width. description.map(|raw_msg| { @@ -109,9 +110,15 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt, token::get_ident(*code) )); } - if msg.lines().any(|line| line.len() > MAX_DESCRIPTION_WIDTH) { + + // URLs can be unavoidably longer than the line limit, so we allow them. + // Allowed format is: `[name]: http://rust-lang.org/` + let is_url = |l: &str| l.starts_with('[') && l.contains("]:") && l.contains("http"); + + if msg.lines().any(|line| line.len() > MAX_DESCRIPTION_WIDTH && !is_url(line)) { ecx.span_err(span, &format!( - "description for error code {} contains a line longer than {} characters", + "description for error code {} contains a line longer than {} characters.\n\ + if you're inserting a long URL use the footnote style to bypass this check.", token::get_ident(*code), MAX_DESCRIPTION_WIDTH )); } |
