@@ -56,20 +56,18 @@ const PARSER_OPTIONS: ParserOptions = ParserOptions {
5656/// (e.g. single quotes inside double quotes are preserved as literal characters).
5757/// Returns `None` if the word contains expansions that cannot be statically resolved
5858/// (parameter expansion, command substitution, arithmetic).
59- #[ expect( clippy:: disallowed_types, reason = "brush_parser word API uses String" ) ]
60- fn unquote ( word : & Word ) -> Option < String > {
59+ fn unquote ( word : & Word ) -> Option < Str > {
6160 let Word { value, loc : _ } = word;
6261 let pieces = brush_parser:: word:: parse ( value. as_str ( ) , & PARSER_OPTIONS ) . ok ( ) ?;
63- let mut result = String :: with_capacity ( value. len ( ) ) ;
62+ let mut result = Str :: with_capacity ( value. len ( ) ) ;
6463 flatten_pieces ( & pieces, & mut result) ?;
6564 Some ( result)
6665}
6766
6867/// Recursively extract literal text from parsed word pieces.
6968///
7069/// Returns `None` if any piece requires runtime expansion.
71- #[ expect( clippy:: disallowed_types, reason = "brush_parser word API uses String" ) ]
72- fn flatten_pieces ( pieces : & [ WordPieceWithSource ] , result : & mut String ) -> Option < ( ) > {
70+ fn flatten_pieces ( pieces : & [ WordPieceWithSource ] , result : & mut Str ) -> Option < ( ) > {
7371 for piece in pieces {
7472 match & piece. piece {
7573 WordPiece :: Text ( s) | WordPiece :: SingleQuotedText ( s) | WordPiece :: AnsiCQuotedText ( s) => {
@@ -122,7 +120,7 @@ fn pipeline_to_command(pipeline: &Pipeline) -> Option<(TaskParsedCommand, Range<
122120 let AssignmentValue :: Scalar ( value) = value else {
123121 return None ;
124122 } ;
125- envs. insert ( name. as_str ( ) . into ( ) , unquote ( value) ?. into ( ) ) ;
123+ envs. insert ( name. as_str ( ) . into ( ) , unquote ( value) ?) ;
126124 }
127125 }
128126 let mut args = Vec :: < Str > :: new ( ) ;
@@ -131,10 +129,10 @@ fn pipeline_to_command(pipeline: &Pipeline) -> Option<(TaskParsedCommand, Range<
131129 let CommandPrefixOrSuffixItem :: Word ( word) = suffix_item else {
132130 return None ;
133131 } ;
134- args. push ( unquote ( word) ?. into ( ) ) ;
132+ args. push ( unquote ( word) ?) ;
135133 }
136134 }
137- Some ( ( TaskParsedCommand { envs, program : unquote ( program) ?. into ( ) , args } , range) )
135+ Some ( ( TaskParsedCommand { envs, program : unquote ( program) ?, args } , range) )
138136}
139137
140138#[ must_use]
@@ -263,11 +261,9 @@ mod tests {
263261
264262 #[ test]
265263 fn test_flatten_pieces_recursion ( ) {
266- #[ expect( clippy:: disallowed_types, reason = "flatten_pieces uses String" ) ]
267- fn parse_and_flatten ( input : & str ) -> Option < String > {
264+ fn parse_and_flatten ( input : & str ) -> Option < Str > {
268265 let pieces = brush_parser:: word:: parse ( input, & PARSER_OPTIONS ) . ok ( ) ?;
269- #[ expect( clippy:: disallowed_types, reason = "flatten_pieces uses String" ) ]
270- let mut result = String :: new ( ) ;
266+ let mut result = Str :: default ( ) ;
271267 flatten_pieces ( & pieces, & mut result) ?;
272268 Some ( result)
273269 }
0 commit comments