@@ -41,7 +41,7 @@ pub enum EWarningRule {
4141/// A rule as specified in the rules document
4242pub trait TWarningRule {
4343 /// every rule may have a comment describing why it failed
44- fn get_comment ( & self ) -> & str ;
44+ fn get_comment ( & self ) -> String ;
4545 fn get_plugins ( & self ) -> Vec < String > ;
4646
4747 fn set_comment ( & mut self , comment : String ) ;
@@ -50,7 +50,7 @@ pub trait TWarningRule {
5050}
5151
5252impl TWarningRule for EWarningRule {
53- fn get_comment ( & self ) -> & str {
53+ fn get_comment ( & self ) -> String {
5454 match self {
5555 EWarningRule :: Note ( x) => x. get_comment ( ) ,
5656 EWarningRule :: Conflict ( x) => x. get_comment ( ) ,
@@ -417,8 +417,8 @@ impl Note {
417417 }
418418}
419419impl TWarningRule for Note {
420- fn get_comment ( & self ) -> & str {
421- self . comment . as_str ( )
420+ fn get_comment ( & self ) -> String {
421+ self . comment . clone ( )
422422 }
423423 fn get_plugins ( & self ) -> Vec < String > {
424424 self . plugins . clone ( )
@@ -499,8 +499,8 @@ impl Conflict {
499499 }
500500}
501501impl TWarningRule for Conflict {
502- fn get_comment ( & self ) -> & str {
503- self . comment . as_str ( )
502+ fn get_comment ( & self ) -> String {
503+ self . comment . clone ( )
504504 }
505505 fn get_plugins ( & self ) -> Vec < String > {
506506 self . plugins . clone ( )
@@ -578,8 +578,17 @@ impl Requires {
578578 }
579579}
580580impl TWarningRule for Requires {
581- fn get_comment ( & self ) -> & str {
582- self . comment . as_str ( )
581+ fn get_comment ( & self ) -> String {
582+ let mut comment = self . comment . clone ( ) ;
583+
584+ // automatically set the comment to the two expressions
585+ if let Some ( expr_a) = & self . expression_a {
586+ if let Some ( expr_b) = & self . expression_b {
587+ comment = format ! ( "'{}' requires '{}' ({})" , expr_a, expr_b, self . comment) ;
588+ }
589+ }
590+
591+ comment
583592 }
584593 fn get_plugins ( & self ) -> Vec < String > {
585594 self . plugins . clone ( )
@@ -670,8 +679,8 @@ impl Patch {
670679 }
671680}
672681impl TWarningRule for Patch {
673- fn get_comment ( & self ) -> & str {
674- self . comment . as_str ( )
682+ fn get_comment ( & self ) -> String {
683+ self . comment . clone ( )
675684 }
676685 fn get_plugins ( & self ) -> Vec < String > {
677686 self . plugins . clone ( )
0 commit comments