Skip to content

Commit 328df8e

Browse files
committed
diagnostics: Allow long URLs in error explanations.
1 parent 6e7fcc4 commit 328df8e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/libsyntax/diagnostics/plugin.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
9999
}
100100
_ => unreachable!()
101101
};
102+
102103
// Check that the description starts and ends with a newline and doesn't
103104
// overflow the maximum line width.
104105
description.map(|raw_msg| {
@@ -109,9 +110,15 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
109110
token::get_ident(*code)
110111
));
111112
}
112-
if msg.lines().any(|line| line.len() > MAX_DESCRIPTION_WIDTH) {
113+
114+
// URLs can be unavoidably longer than the line limit, so we allow them.
115+
// Allowed format is: `[name]: http://rust-lang.org/`
116+
let is_url = |l: &str| l.starts_with('[') && l.contains("]:") && l.contains("http");
117+
118+
if msg.lines().any(|line| line.len() > MAX_DESCRIPTION_WIDTH && !is_url(line)) {
113119
ecx.span_err(span, &format!(
114-
"description for error code {} contains a line longer than {} characters",
120+
"description for error code {} contains a line longer than {} characters.\n\
121+
if you're inserting a long URL use the footnote style to bypass this check.",
115122
token::get_ident(*code), MAX_DESCRIPTION_WIDTH
116123
));
117124
}

0 commit comments

Comments
 (0)