File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/libsyntax/diagnostics Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments