@@ -44,7 +44,7 @@ pub struct ViolationIdentifier {
4444}
4545#[ derive( PartialEq , Clone , Eq , Hash , Debug ) ]
4646pub struct Violation {
47- message : String ,
47+ pub message : String ,
4848 pub identifier : ViolationIdentifier ,
4949}
5050
@@ -66,7 +66,7 @@ pub(crate) trait ValidatorInterface {
6666pub struct CheckAllResult {
6767 reportable_violations : HashSet < Violation > ,
6868 stale_violations : Vec < ViolationIdentifier > ,
69- strict_mode_violations : Vec < ViolationIdentifier > ,
69+ strict_mode_violations : HashSet < Violation > ,
7070}
7171
7272impl CheckAllResult {
@@ -99,7 +99,8 @@ impl CheckAllResult {
9999
100100 if !self . strict_mode_violations . is_empty ( ) {
101101 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 ) ;
103104 writeln ! ( f, "{}" , error_message) ?;
104105 }
105106 }
@@ -154,7 +155,6 @@ impl<'a> CheckAllBuilder<'a> {
154155 strict_mode_violations : self
155156 . build_strict_mode_violations ( )
156157 . into_iter ( )
157- . cloned ( )
158158 . collect ( ) ,
159159 } )
160160 }
@@ -239,12 +239,12 @@ impl<'a> CheckAllBuilder<'a> {
239239 }
240240 }
241241
242- fn build_strict_mode_violations ( & self ) -> Vec < & ' a ViolationIdentifier > {
242+ fn build_strict_mode_violations ( & self ) -> Vec < Violation > {
243243 self . found_violations
244244 . violations
245245 . iter ( )
246246 . filter ( |v| v. identifier . strict )
247- . map ( |v| & v . identifier )
247+ . cloned ( )
248248 . collect ( )
249249 }
250250}
@@ -508,6 +508,8 @@ fn remove_reference_to_dependency(
508508}
509509#[ cfg( test) ]
510510mod tests {
511+ use std:: collections:: HashSet ;
512+
511513 use crate :: packs:: checker:: {
512514 CheckAllResult , Violation , ViolationIdentifier ,
513515 } ;
@@ -540,7 +542,7 @@ mod tests {
540542 }
541543 ] . iter ( ) . cloned ( ) . collect ( ) ,
542544 stale_violations : Vec :: new ( ) ,
543- strict_mode_violations : Vec :: new ( ) ,
545+ strict_mode_violations : HashSet :: new ( ) ,
544546 } ;
545547
546548 let expected_output = "2 violation(s) detected:
0 commit comments