File tree 1 file changed +9
-2
lines changed
src/libsyntax/diagnostics
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,
99
99
}
100
100
_ => unreachable ! ( )
101
101
} ;
102
+
102
103
// Check that the description starts and ends with a newline and doesn't
103
104
// overflow the maximum line width.
104
105
description. map ( |raw_msg| {
@@ -109,9 +110,15 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
109
110
token:: get_ident( * code)
110
111
) ) ;
111
112
}
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) ) {
113
119
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.",
115
122
token:: get_ident( * code) , MAX_DESCRIPTION_WIDTH
116
123
) ) ;
117
124
}
You can’t perform that action at this time.
0 commit comments