Display a descriptive error for !include
directives (#1779)
This commit is contained in:
parent
f47c175bc5
commit
86dbed7445
@ -135,6 +135,10 @@ impl Display for CompileError<'_> {
|
|||||||
Count("argument", *found),
|
Count("argument", *found),
|
||||||
expected.display(),
|
expected.display(),
|
||||||
),
|
),
|
||||||
|
Include => write!(
|
||||||
|
f,
|
||||||
|
"The `!include` directive has been stabilized as `import`"
|
||||||
|
),
|
||||||
InconsistentLeadingWhitespace { expected, found } => write!(
|
InconsistentLeadingWhitespace { expected, found } => write!(
|
||||||
f,
|
f,
|
||||||
"Recipe line has inconsistent leading whitespace. Recipe started with `{}` but found \
|
"Recipe line has inconsistent leading whitespace. Recipe started with `{}` but found \
|
||||||
|
@ -58,6 +58,7 @@ pub(crate) enum CompileErrorKind<'src> {
|
|||||||
found: usize,
|
found: usize,
|
||||||
expected: Range<usize>,
|
expected: Range<usize>,
|
||||||
},
|
},
|
||||||
|
Include,
|
||||||
InconsistentLeadingWhitespace {
|
InconsistentLeadingWhitespace {
|
||||||
expected: &'src str,
|
expected: &'src str,
|
||||||
found: &'src str,
|
found: &'src str,
|
||||||
|
@ -481,6 +481,7 @@ impl<'src> Lexer<'src> {
|
|||||||
fn lex_normal(&mut self, start: char) -> CompileResult<'src, ()> {
|
fn lex_normal(&mut self, start: char) -> CompileResult<'src, ()> {
|
||||||
match start {
|
match start {
|
||||||
' ' | '\t' => self.lex_whitespace(),
|
' ' | '\t' => self.lex_whitespace(),
|
||||||
|
'!' if self.rest().starts_with("!include") => Err(self.error(Include)),
|
||||||
'!' => self.lex_digraph('!', '=', BangEquals),
|
'!' => self.lex_digraph('!', '=', BangEquals),
|
||||||
'#' => self.lex_comment(),
|
'#' => self.lex_comment(),
|
||||||
'$' => self.lex_single(Dollar),
|
'$' => self.lex_single(Dollar),
|
||||||
|
@ -110,3 +110,20 @@ fn listed_recipes_in_imports_are_in_load_order() {
|
|||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn include_error() {
|
||||||
|
Test::new()
|
||||||
|
.justfile("!include foo")
|
||||||
|
.status(EXIT_FAILURE)
|
||||||
|
.stderr(
|
||||||
|
"
|
||||||
|
error: The `!include` directive has been stabilized as `import`
|
||||||
|
--> justfile:1:1
|
||||||
|
|
|
||||||
|
1 | !include foo
|
||||||
|
| ^
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user