@@ -114,16 +114,17 @@ pub(crate) struct Suppression {
114114
115115impl Suppression {
116116 /// Creates a suppression from a suppression comment line.
117- /// The line start must match `-- pgt-ignore`, otherwise, this will panic.
117+ /// The line start must match `-- pgt-ignore` or `-- pgls-ignore` , otherwise, this will panic.
118118 /// Leading whitespace is ignored.
119119 pub ( crate ) fn from_line ( line : & str , offset : & TextSize ) -> Result < Self , SuppressionDiagnostic > {
120120 let start_trimmed = line. trim_ascii_start ( ) ;
121121 let leading_whitespace_offset = line. len ( ) - start_trimmed. len ( ) ;
122122 let trimmed = start_trimmed. trim_ascii_end ( ) ;
123123
124124 assert ! (
125- start_trimmed. starts_with( "-- pgt-ignore" ) ,
126- "Only try parsing suppressions from lines starting with `-- pgt-ignore`."
125+ start_trimmed. starts_with( "-- pgt-ignore" )
126+ || start_trimmed. starts_with( "-- pgls-ignore" ) ,
127+ "Only try parsing suppressions from lines starting with `-- pgt-ignore` or `-- pgls-ignore`."
127128 ) ;
128129
129130 let full_offset = * offset + TextSize :: new ( leading_whitespace_offset. try_into ( ) . unwrap ( ) ) ;
@@ -141,10 +142,10 @@ impl Suppression {
141142
142143 let _ = parts. next ( ) ;
143144 let kind = match parts. next ( ) . unwrap ( ) {
144- "pgt-ignore-all" => SuppressionKind :: File ,
145- "pgt-ignore-start" => SuppressionKind :: Start ,
146- "pgt-ignore-end" => SuppressionKind :: End ,
147- "pgt-ignore" => SuppressionKind :: Line ,
145+ "pgt-ignore-all" | "pgls-ignore-all" => SuppressionKind :: File ,
146+ "pgt-ignore-start" | "pgls-ignore-start" => SuppressionKind :: Start ,
147+ "pgt-ignore-end" | "pgls-ignore-end" => SuppressionKind :: End ,
148+ "pgt-ignore" | "pgls-ignore" => SuppressionKind :: Line ,
148149 k => {
149150 return Err ( SuppressionDiagnostic {
150151 span,
@@ -452,4 +453,57 @@ mod tests {
452453 ] ;
453454 assert ! ( spec. is_disabled( & disabled5) ) ;
454455 }
456+
457+ #[ test]
458+ fn test_pgls_prefix_line_suppressions ( ) {
459+ let line = "-- pgls-ignore lint/safety/banDropColumn: explanation" ;
460+ let offset = & TextSize :: new ( 0 ) ;
461+ let suppression = Suppression :: from_line ( line, offset) . unwrap ( ) ;
462+
463+ assert_eq ! ( suppression. kind, SuppressionKind :: Line ) ;
464+ assert_eq ! (
465+ suppression. rule_specifier,
466+ RuleSpecifier :: Rule (
467+ "lint" . to_string( ) ,
468+ "safety" . to_string( ) ,
469+ "banDropColumn" . to_string( )
470+ )
471+ ) ;
472+ assert_eq ! ( suppression. explanation. as_deref( ) , Some ( "explanation" ) ) ;
473+ }
474+
475+ #[ test]
476+ fn test_pgls_prefix_file_kind ( ) {
477+ let line = "-- pgls-ignore-all lint/safety: explanation" ;
478+ let offset = & TextSize :: new ( 0 ) ;
479+ let suppression = Suppression :: from_line ( line, offset) . unwrap ( ) ;
480+
481+ assert_eq ! ( suppression. kind, SuppressionKind :: File ) ;
482+ assert_eq ! (
483+ suppression. rule_specifier,
484+ RuleSpecifier :: Group ( "lint" . to_string( ) , "safety" . to_string( ) )
485+ ) ;
486+ assert_eq ! ( suppression. explanation. as_deref( ) , Some ( "explanation" ) ) ;
487+ }
488+
489+ #[ test]
490+ fn test_pgls_prefix_start_and_end_kind ( ) {
491+ let start_line = "-- pgls-ignore-start typecheck" ;
492+ let end_line = "-- pgls-ignore-end typecheck" ;
493+ let offset = & TextSize :: new ( 0 ) ;
494+
495+ let start_suppression = Suppression :: from_line ( start_line, offset) . unwrap ( ) ;
496+ assert_eq ! ( start_suppression. kind, SuppressionKind :: Start ) ;
497+ assert_eq ! (
498+ start_suppression. rule_specifier,
499+ RuleSpecifier :: Category ( "typecheck" . to_string( ) )
500+ ) ;
501+
502+ let end_suppression = Suppression :: from_line ( end_line, offset) . unwrap ( ) ;
503+ assert_eq ! ( end_suppression. kind, SuppressionKind :: End ) ;
504+ assert_eq ! (
505+ end_suppression. rule_specifier,
506+ RuleSpecifier :: Category ( "typecheck" . to_string( ) )
507+ ) ;
508+ }
455509}
0 commit comments