@@ -11,9 +11,10 @@ pub fn read2_abbreviated(mut child: Child, exclude_from_len: &[String]) -> io::R
11
11
12
12
const HEAD_LEN : usize = 160 * 1024 ;
13
13
const TAIL_LEN : usize = 256 * 1024 ;
14
+ const EXCLUDED_PLACEHOLDER_LEN : isize = 32 ;
14
15
15
16
enum ProcOutput {
16
- Full { bytes : Vec < u8 > , excluded_len : usize } ,
17
+ Full { bytes : Vec < u8 > , excluded_len : isize } ,
17
18
Abbreviated { head : Vec < u8 > , skipped : usize , tail : Box < [ u8 ] > } ,
18
19
}
19
20
@@ -30,17 +31,22 @@ pub fn read2_abbreviated(mut child: Child, exclude_from_len: &[String]) -> io::R
30
31
// paths when calculating the string length, while still including the full
31
32
// path in the output. This could result in some output being larger than the
32
33
// threshold, but it's better than having nondeterministic failures.
34
+ //
35
+ // The compiler emitting only excluded strings is addressed by adding a
36
+ // placeholder size for each excluded segment, which will eventually reach
37
+ // the configured threshold.
33
38
for pattern in exclude_from_len {
34
39
let pattern_bytes = pattern. as_bytes ( ) ;
35
40
let matches = data
36
41
. windows ( pattern_bytes. len ( ) )
37
42
. filter ( |window| window == & pattern_bytes)
38
43
. count ( ) ;
39
- * excluded_len += matches * pattern_bytes. len ( ) ;
44
+ * excluded_len += matches as isize
45
+ * ( EXCLUDED_PLACEHOLDER_LEN - pattern_bytes. len ( ) as isize ) ;
40
46
}
41
47
42
48
let new_len = bytes. len ( ) ;
43
- if new_len . saturating_sub ( * excluded_len) <= HEAD_LEN + TAIL_LEN {
49
+ if ( new_len as isize + * excluded_len) as usize <= HEAD_LEN + TAIL_LEN {
44
50
return ;
45
51
}
46
52
0 commit comments