@@ -26,14 +26,6 @@ impl<'src> CompileError<'src> {
2626 }
2727}
2828
29- fn capitalize ( s : & str ) -> String {
30- let mut chars = s. chars ( ) ;
31- match chars. next ( ) {
32- None => String :: new ( ) ,
33- Some ( first) => first. to_uppercase ( ) . collect :: < String > ( ) + chars. as_str ( ) ,
34- }
35- }
36-
3729impl Display for CompileError < ' _ > {
3830 fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
3931 use CompileErrorKind :: * ;
@@ -42,11 +34,11 @@ impl Display for CompileError<'_> {
4234 ArgAttributeValueRequiresOption => {
4335 write ! (
4436 f,
45- "Argument attribute `value` only valid with `long` or `short`"
37+ "argument attribute `value` only valid with `long` or `short`"
4638 )
4739 }
4840 ArgumentPatternRegex { .. } => {
49- write ! ( f, "Failed to parse argument pattern" )
41+ write ! ( f, "failed to parse argument pattern" )
5042 }
5143 AttributeArgumentCountMismatch {
5244 attribute,
@@ -56,7 +48,7 @@ impl Display for CompileError<'_> {
5648 } => {
5749 write ! (
5850 f,
59- "Attribute `{attribute}` got {found} {} but takes " ,
51+ "attribute `{attribute}` got {found} {} but takes " ,
6052 Count ( "argument" , * found) ,
6153 ) ?;
6254
@@ -72,34 +64,34 @@ impl Display for CompileError<'_> {
7264 AttributeArgumentExpression { attribute } => {
7365 write ! (
7466 f,
75- "Attribute `{attribute}` arguments must be string literals"
67+ "attribute `{attribute}` arguments must be string literals"
7668 )
7769 }
7870 AttributePositionalFollowsKeyword => {
7971 write ! (
8072 f,
81- "Positional attribute arguments cannot follow keyword attribute arguments"
73+ "positional attribute arguments cannot follow keyword attribute arguments"
8274 )
8375 }
84- BacktickShebang => write ! ( f, "Backticks may not start with `#!`" ) ,
76+ BacktickShebang => write ! ( f, "backticks may not start with `#!`" ) ,
8577 CircularRecipeDependency { recipe, circle } => {
8678 if circle. len ( ) == 2 {
87- write ! ( f, "Recipe `{recipe}` depends on itself" )
79+ write ! ( f, "recipe `{recipe}` depends on itself" )
8880 } else {
8981 write ! (
9082 f,
91- "Recipe `{recipe}` has circular dependency `{}`" ,
83+ "recipe `{recipe}` has circular dependency `{}`" ,
9284 circle. join( " -> " )
9385 )
9486 }
9587 }
9688 CircularVariableDependency { variable, circle } => {
9789 if circle. len ( ) == 2 {
98- write ! ( f, "Variable `{variable}` is defined in terms of itself" )
90+ write ! ( f, "variable `{variable}` is defined in terms of itself" )
9991 } else {
10092 write ! (
10193 f,
102- "Variable `{variable}` depends on its own value: `{}`" ,
94+ "variable `{variable}` depends on its own value: `{}`" ,
10395 circle. join( " -> " ) ,
10496 )
10597 }
@@ -112,7 +104,7 @@ impl Display for CompileError<'_> {
112104 } => {
113105 write ! (
114106 f,
115- "Dependency `{dependency}` got {found} {} but takes " ,
107+ "dependency `{dependency}` got {found} {} but takes " ,
116108 Count ( "argument" , * found) ,
117109 ) ?;
118110
@@ -127,98 +119,98 @@ impl Display for CompileError<'_> {
127119 }
128120 DuplicateArgAttribute { arg, first } => write ! (
129121 f,
130- "Recipe attribute for argument `{arg}` first used on line {} is duplicated on line {}" ,
122+ "recipe attribute for argument `{arg}` first used on line {} is duplicated on line {}" ,
131123 first. ordinal( ) ,
132124 self . token. line. ordinal( ) ,
133125 ) ,
134126 DuplicateAttribute { attribute, first } => write ! (
135127 f,
136- "Recipe attribute `{attribute}` first used on line {} is duplicated on line {}" ,
128+ "recipe attribute `{attribute}` first used on line {} is duplicated on line {}" ,
137129 first. ordinal( ) ,
138130 self . token. line. ordinal( ) ,
139131 ) ,
140132 DuplicateEnvAttribute { variable, first } => write ! (
141133 f,
142- "Environment variable `{variable}` first set on line {} is set again on line {}" ,
134+ "environment variable `{variable}` first set on line {} is set again on line {}" ,
143135 first. ordinal( ) ,
144136 self . token. line. ordinal( ) ,
145137 ) ,
146138 DuplicateDefault { recipe } => write ! (
147139 f,
148- "Recipe `{recipe}` has duplicate `[default]` attribute, which may only appear once per module" ,
140+ "recipe `{recipe}` has duplicate `[default]` attribute, which may only appear once per module" ,
149141 ) ,
150142 DuplicateOption { recipe, option } => {
151143 write ! (
152144 f,
153- "Recipe `{recipe}` defines option `{option}` multiple times"
145+ "recipe `{recipe}` defines option `{option}` multiple times"
154146 )
155147 }
156148 DuplicateParameter { recipe, parameter } => {
157- write ! ( f, "Recipe `{recipe}` has duplicate parameter `{parameter}`" )
149+ write ! ( f, "recipe `{recipe}` has duplicate parameter `{parameter}`" )
158150 }
159151 DuplicateSet { setting, first } => write ! (
160152 f,
161- "Setting `{setting}` first set on line {} is redefined on line {}" ,
153+ "setting `{setting}` first set on line {} is redefined on line {}" ,
162154 first. ordinal( ) ,
163155 self . token. line. ordinal( ) ,
164156 ) ,
165157 DuplicateVariable { variable } => {
166- write ! ( f, "Variable `{variable}` has multiple definitions" )
158+ write ! ( f, "variable `{variable}` has multiple definitions" )
167159 }
168160 DuplicateUnexport { variable } => {
169- write ! ( f, "Variable `{variable}` is unexported multiple times" )
161+ write ! ( f, "variable `{variable}` is unexported multiple times" )
170162 }
171163 ExitMessageAndNoExitMessageAttribute { recipe } => write ! (
172164 f,
173- "Recipe `{recipe}` has both `[exit-message]` and `[no-exit-message]` attributes"
165+ "recipe `{recipe}` has both `[exit-message]` and `[no-exit-message]` attributes"
174166 ) ,
175167 ExpectedKeyword { expected, found } => {
176168 let expected = List :: or_ticked ( expected) ;
177169 if found. kind == TokenKind :: Identifier {
178170 write ! (
179171 f,
180- "Expected keyword {expected} but found identifier `{}`" ,
172+ "expected keyword {expected} but found identifier `{}`" ,
181173 found. lexeme( )
182174 )
183175 } else {
184- write ! ( f, "Expected keyword {expected} but found `{}`" , found. kind)
176+ write ! ( f, "expected keyword {expected} but found `{}`" , found. kind)
185177 }
186178 }
187179 ExportUnexported { variable } => {
188- write ! ( f, "Variable {variable} is both exported and unexported" )
180+ write ! ( f, "variable {variable} is both exported and unexported" )
189181 }
190- ExtraLeadingWhitespace => write ! ( f, "Recipe line has extra leading whitespace" ) ,
182+ ExtraLeadingWhitespace => write ! ( f, "recipe line has extra leading whitespace" ) ,
191183 ExtraneousAttributes { count } => {
192- write ! ( f, "Extraneous {}" , Count ( "attribute" , * count) )
184+ write ! ( f, "extraneous {}" , Count ( "attribute" , * count) )
193185 }
194186 FunctionArgumentCountMismatch {
195187 function,
196188 arguments,
197189 expected,
198190 } => write ! (
199191 f,
200- "Function `{function}` called with {arguments} {} but takes {}" ,
192+ "function `{function}` called with {arguments} {} but takes {}" ,
201193 Count ( "argument" , * arguments) ,
202194 expected. display( ) ,
203195 ) ,
204196 GuardAndInfallibleSigil => write ! (
205197 f,
206- "The guard `?` and infallible `-` sigils may not be used together"
198+ "the guard `?` and infallible `-` sigils may not be used together"
207199 ) ,
208200 Include => write ! (
209201 f,
210- "The `!include` directive has been stabilized as `import`"
202+ "the `!include` directive has been stabilized as `import`"
211203 ) ,
212204 InconsistentLeadingWhitespace { expected, found } => write ! (
213205 f,
214- "Recipe line has inconsistent leading whitespace. Recipe started with `{}` but found \
206+ "recipe line has inconsistent leading whitespace. Recipe started with `{}` but found \
215207 line with `{}`",
216208 ShowWhitespace ( expected) ,
217209 ShowWhitespace ( found)
218210 ) ,
219211 Internal { message } => write ! (
220212 f,
221- "Internal error, this may indicate a bug in just: {message}\n \
213+ "internal error, this may indicate a bug in just: {message}\n \
222214 consider filing an issue: https://github.com/casey/just/issues/new"
223215 ) ,
224216 InvalidAttribute {
@@ -247,34 +239,34 @@ impl Display for CompileError<'_> {
247239 close,
248240 } => write ! (
249241 f,
250- "Mismatched closing delimiter `{}`. (Did you mean to close the `{}` on line {}?)" ,
242+ "mismatched closing delimiter `{}`. (Did you mean to close the `{}` on line {}?)" ,
251243 close. close( ) ,
252244 open. open( ) ,
253245 open_line. ordinal( ) ,
254246 ) ,
255247 MixedLeadingWhitespace { whitespace } => write ! (
256248 f,
257- "Found a mix of tabs and spaces in leading whitespace: `{}`\n Leading whitespace may \
249+ "found a mix of tabs and spaces in leading whitespace: `{}`\n Leading whitespace may \
258250 consist of tabs or spaces, but not both",
259251 ShowWhitespace ( whitespace)
260252 ) ,
261253 NoCdAndWorkingDirectoryAttribute { recipe } => write ! (
262254 f,
263- "Recipe `{recipe}` has both `[no-cd]` and `[working-directory]` attributes"
255+ "recipe `{recipe}` has both `[no-cd]` and `[working-directory]` attributes"
264256 ) ,
265257 OptionNameContainsEqualSign { parameter } => {
266258 write ! (
267259 f,
268- "Option name for parameter `{parameter}` contains equal sign"
260+ "option name for parameter `{parameter}` contains equal sign"
269261 )
270262 }
271263 OptionNameEmpty { parameter } => {
272- write ! ( f, "Option name for parameter `{parameter}` is empty" )
264+ write ! ( f, "option name for parameter `{parameter}` is empty" )
273265 }
274266 ParameterFollowsVariadicParameter { parameter } => {
275- write ! ( f, "Parameter `{parameter}` follows variadic parameter" )
267+ write ! ( f, "parameter `{parameter}` follows variadic parameter" )
276268 }
277- ParsingRecursionDepthExceeded => write ! ( f, "Parsing recursion depth exceeded" ) ,
269+ ParsingRecursionDepthExceeded => write ! ( f, "parsing recursion depth exceeded" ) ,
278270 Redefinition {
279271 first,
280272 first_type,
@@ -284,53 +276,51 @@ impl Display for CompileError<'_> {
284276 if first_type == second_type {
285277 write ! (
286278 f,
287- "{} `{name}` first defined on line {} is redefined on line {}" ,
288- capitalize( first_type) ,
279+ "{first_type} `{name}` first defined on line {} is redefined on line {}" ,
289280 first. ordinal( ) ,
290281 self . token. line. ordinal( ) ,
291282 )
292283 } else {
293284 write ! (
294285 f,
295- "{} `{name}` defined on line {} is redefined as {} {second_type} on line {}" ,
296- capitalize( first_type) ,
286+ "{first_type} `{name}` defined on line {} is redefined as {} {second_type} on line {}" ,
297287 first. ordinal( ) ,
298288 if * second_type == "alias" { "an" } else { "a" } ,
299289 self . token. line. ordinal( ) ,
300290 )
301291 }
302292 }
303- ShellExpansion { err } => write ! ( f, "Shell expansion failed: {err}" ) ,
293+ ShellExpansion { err } => write ! ( f, "shell expansion failed: {err}" ) ,
304294 ShortOptionWithMultipleCharacters { parameter } => {
305295 write ! (
306296 f,
307- "Short option name for parameter `{parameter}` contains multiple characters"
297+ "short option name for parameter `{parameter}` contains multiple characters"
308298 )
309299 }
310300 RequiredParameterFollowsDefaultParameter { parameter } => write ! (
311301 f,
312- "Non -default parameter `{parameter}` follows default parameter"
302+ "non -default parameter `{parameter}` follows default parameter"
313303 ) ,
314304 UndefinedArgAttribute { argument } => {
315- write ! ( f, "Argument attribute for undefined argument `{argument}`" )
305+ write ! ( f, "argument attribute for undefined argument `{argument}`" )
316306 }
317- UndefinedFunction { function } => write ! ( f, "Call to undefined function `{function}`" ) ,
318- UndefinedVariable { variable } => write ! ( f, "Variable `{variable}` not defined" ) ,
307+ UndefinedFunction { function } => write ! ( f, "call to undefined function `{function}`" ) ,
308+ UndefinedVariable { variable } => write ! ( f, "variable `{variable}` not defined" ) ,
319309 UnexpectedCharacter { expected } => {
320- write ! ( f, "Expected character {}" , List :: or_ticked( expected) )
310+ write ! ( f, "expected character {}" , List :: or_ticked( expected) )
321311 }
322312 UnexpectedClosingDelimiter { close } => {
323- write ! ( f, "Unexpected closing delimiter `{}`" , close. close( ) )
313+ write ! ( f, "unexpected closing delimiter `{}`" , close. close( ) )
324314 }
325315 UnexpectedEndOfToken { expected } => {
326316 write ! (
327317 f,
328- "Expected character {} but found end-of-file" ,
318+ "expected character {} but found end-of-file" ,
329319 List :: or_ticked( expected) ,
330320 )
331321 }
332322 UnexpectedToken { expected, found } => {
333- write ! ( f, "Expected {}, but found {found}" , List :: or( expected) )
323+ write ! ( f, "expected {}, but found {found}" , List :: or( expected) )
334324 }
335325 UnicodeEscapeCharacter { character } => {
336326 write ! ( f, "expected hex digit [0-9A-Fa-f] but found `{character}`" )
@@ -352,31 +342,31 @@ impl Display for CompileError<'_> {
352342 }
353343 UnicodeEscapeUnterminated => write ! ( f, "unterminated unicode escape sequence" ) ,
354344 UnknownAliasTarget { alias, target } => {
355- write ! ( f, "Alias `{alias}` has an unknown target `{target}`" )
345+ write ! ( f, "alias `{alias}` has an unknown target `{target}`" )
356346 }
357347 AttributeKeyMissingValue { key } => {
358- write ! ( f, "Attribute key `{key}` requires value" )
348+ write ! ( f, "attribute key `{key}` requires value" )
359349 }
360350 UnknownAttributeKeyword { attribute, keyword } => {
361- write ! ( f, "Unknown keyword `{keyword}` for `{attribute}` attribute" )
351+ write ! ( f, "unknown keyword `{keyword}` for `{attribute}` attribute" )
362352 }
363- UnknownAttribute { attribute } => write ! ( f, "Unknown attribute `{attribute}`" ) ,
353+ UnknownAttribute { attribute } => write ! ( f, "unknown attribute `{attribute}`" ) ,
364354 UnknownDependency { recipe, unknown } => {
365- write ! ( f, "Recipe `{recipe}` has unknown dependency `{unknown}`" )
355+ write ! ( f, "recipe `{recipe}` has unknown dependency `{unknown}`" )
366356 }
367- UnknownSetting { setting } => write ! ( f, "Unknown setting `{setting}`" ) ,
357+ UnknownSetting { setting } => write ! ( f, "unknown setting `{setting}`" ) ,
368358 UnknownStartOfToken { start } => {
369- write ! ( f, "Unknown start of token '{start}'" ) ?;
359+ write ! ( f, "unknown start of token '{start}'" ) ?;
370360 if !start. is_ascii_graphic ( ) {
371361 write ! ( f, " (U+{:04X})" , * start as u32 ) ?;
372362 }
373363 Ok ( ( ) )
374364 }
375- UnpairedCarriageReturn => write ! ( f, "Unpaired carriage return" ) ,
376- UnterminatedBacktick => write ! ( f, "Unterminated backtick" ) ,
377- UnterminatedInterpolation => write ! ( f, "Unterminated interpolation" ) ,
378- UnterminatedString => write ! ( f, "Unterminated string" ) ,
379- VariadicParameterWithOption => write ! ( f, "Variadic parameters may not be options" ) ,
365+ UnpairedCarriageReturn => write ! ( f, "unpaired carriage return" ) ,
366+ UnterminatedBacktick => write ! ( f, "unterminated backtick" ) ,
367+ UnterminatedInterpolation => write ! ( f, "unterminated interpolation" ) ,
368+ UnterminatedString => write ! ( f, "unterminated string" ) ,
369+ VariadicParameterWithOption => write ! ( f, "variadic parameters may not be options" ) ,
380370 }
381371 }
382372}
0 commit comments