@@ -44,7 +44,7 @@ pub struct ViolationIdentifier {
44
44
}
45
45
#[ derive( PartialEq , Clone , Eq , Hash , Debug ) ]
46
46
pub struct Violation {
47
- message : String ,
47
+ pub message : String ,
48
48
pub identifier : ViolationIdentifier ,
49
49
}
50
50
@@ -66,7 +66,7 @@ pub(crate) trait ValidatorInterface {
66
66
pub struct CheckAllResult {
67
67
reportable_violations : HashSet < Violation > ,
68
68
stale_violations : Vec < ViolationIdentifier > ,
69
- strict_mode_violations : Vec < ViolationIdentifier > ,
69
+ strict_mode_violations : HashSet < Violation > ,
70
70
}
71
71
72
72
impl CheckAllResult {
@@ -99,7 +99,8 @@ impl CheckAllResult {
99
99
100
100
if !self . strict_mode_violations . is_empty ( ) {
101
101
for v in self . strict_mode_violations . iter ( ) {
102
- let error_message = build_strict_violation_message ( v) ;
102
+ let error_message =
103
+ build_strict_violation_message ( & v. identifier ) ;
103
104
writeln ! ( f, "{}" , error_message) ?;
104
105
}
105
106
}
@@ -154,7 +155,6 @@ impl<'a> CheckAllBuilder<'a> {
154
155
strict_mode_violations : self
155
156
. build_strict_mode_violations ( )
156
157
. into_iter ( )
157
- . cloned ( )
158
158
. collect ( ) ,
159
159
} )
160
160
}
@@ -239,12 +239,12 @@ impl<'a> CheckAllBuilder<'a> {
239
239
}
240
240
}
241
241
242
- fn build_strict_mode_violations ( & self ) -> Vec < & ' a ViolationIdentifier > {
242
+ fn build_strict_mode_violations ( & self ) -> Vec < Violation > {
243
243
self . found_violations
244
244
. violations
245
245
. iter ( )
246
246
. filter ( |v| v. identifier . strict )
247
- . map ( |v| & v . identifier )
247
+ . cloned ( )
248
248
. collect ( )
249
249
}
250
250
}
@@ -508,6 +508,8 @@ fn remove_reference_to_dependency(
508
508
}
509
509
#[ cfg( test) ]
510
510
mod tests {
511
+ use std:: collections:: HashSet ;
512
+
511
513
use crate :: packs:: checker:: {
512
514
CheckAllResult , Violation , ViolationIdentifier ,
513
515
} ;
@@ -540,7 +542,7 @@ mod tests {
540
542
}
541
543
] . iter ( ) . cloned ( ) . collect ( ) ,
542
544
stale_violations : Vec :: new ( ) ,
543
- strict_mode_violations : Vec :: new ( ) ,
545
+ strict_mode_violations : HashSet :: new ( ) ,
544
546
} ;
545
547
546
548
let expected_output = "2 violation(s) detected:
0 commit comments