@@ -72,12 +72,14 @@ const ANNOTATIONS_TO_IGNORE: &[&str] = &[
7272 "//@ normalize-stderr" ,
7373] ;
7474
75+ const LINELENGTH_CHECK : & str = "linelength" ;
76+
7577// If you edit this, also edit where it gets used in `check` (calling `contains_ignore_directives`)
7678const CONFIGURABLE_CHECKS : [ & str ; 11 ] = [
7779 "cr" ,
7880 "undocumented-unsafe" ,
7981 "tab" ,
80- "linelength" ,
82+ LINELENGTH_CHECK ,
8183 "filelength" ,
8284 "end-whitespace" ,
8385 "trailing-newlines" ,
@@ -250,14 +252,24 @@ enum Directive {
250252// Use a fixed size array in the return type to catch mistakes with changing `CONFIGURABLE_CHECKS`
251253// without changing the code in `check` easier.
252254fn contains_ignore_directives < const N : usize > (
255+ path_str : & str ,
253256 can_contain : bool ,
254257 contents : & str ,
255258 checks : [ & str ; N ] ,
256259) -> [ Directive ; N ] {
257- if !can_contain {
260+ // The rustdoc-json test syntax often requires very long lines, so the checks
261+ // for long lines aren't really useful.
262+ let always_ignore_linelength = path_str. contains ( "rustdoc-json" ) ;
263+
264+ if !can_contain && !always_ignore_linelength {
258265 return [ Directive :: Deny ; N ] ;
259266 }
267+
260268 checks. map ( |check| {
269+ if check == LINELENGTH_CHECK && always_ignore_linelength {
270+ return Directive :: Ignore ( false ) ;
271+ }
272+
261273 // Update `can_contain` when changing this
262274 if contents. contains ( & format ! ( "// ignore-tidy-{check}" ) )
263275 || contents. contains ( & format ! ( "# ignore-tidy-{check}" ) )
@@ -367,6 +379,7 @@ pub fn check(path: &Path, bad: &mut bool) {
367379
368380 walk ( path, skip, & mut |entry, contents| {
369381 let file = entry. path ( ) ;
382+ let path_str = file. to_string_lossy ( ) ;
370383 let filename = file. file_name ( ) . unwrap ( ) . to_string_lossy ( ) ;
371384
372385 let is_css_file = filename. ends_with ( ".css" ) ;
@@ -422,7 +435,7 @@ pub fn check(path: &Path, bad: &mut bool) {
422435 mut skip_copyright,
423436 mut skip_dbg,
424437 mut skip_odd_backticks,
425- ] = contains_ignore_directives ( can_contain, & contents, CONFIGURABLE_CHECKS ) ;
438+ ] = contains_ignore_directives ( & path_str , can_contain, & contents, CONFIGURABLE_CHECKS ) ;
426439 let mut leading_new_lines = false ;
427440 let mut trailing_new_lines = 0 ;
428441 let mut lines = 0 ;
@@ -502,7 +515,7 @@ pub fn check(path: &Path, bad: &mut bool) {
502515 let contains_potential_directive =
503516 possible_line_start && ( line. contains ( "-tidy" ) || line. contains ( "tidy-" ) ) ;
504517 let has_recognized_ignore_directive =
505- contains_ignore_directives ( can_contain, line, CONFIGURABLE_CHECKS )
518+ contains_ignore_directives ( & path_str , can_contain, line, CONFIGURABLE_CHECKS )
506519 . into_iter ( )
507520 . any ( |directive| matches ! ( directive, Directive :: Ignore ( _) ) ) ;
508521 let has_alphabetical_directive = line. contains ( "tidy-alphabetical-start" )
0 commit comments