From 80e65a4db4c4fc87a2c1782309cbf65d4dbcfc6a Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Tue, 17 Sep 2024 00:14:33 -0700 Subject: [PATCH 01/16] WIP globbing https://github.com/casey/just/issues/1641 --- src/analyzer.rs | 6 +++--- src/compiler.rs | 7 +++++-- src/item.rs | 2 +- src/parser.rs | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/analyzer.rs b/src/analyzer.rs index ef6bcb2293..a35a608235 100644 --- a/src/analyzer.rs +++ b/src/analyzer.rs @@ -52,9 +52,9 @@ impl<'run, 'src> Analyzer<'run, 'src> { self.assignments.push(assignment); } Item::Comment(_) => (), - Item::Import { absolute, .. } => { - if let Some(absolute) = absolute { - stack.push(asts.get(absolute).unwrap()); + Item::Import { absolute_paths, .. } => { + for p in absolute_paths { + stack.push(asts.get(p).unwrap()); } } Item::Module { diff --git a/src/compiler.rs b/src/compiler.rs index 1a555ebabb..b46e67f3b6 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -64,7 +64,7 @@ impl Compiler { } Item::Import { relative, - absolute, + absolute_paths, optional, path, } => { @@ -75,6 +75,8 @@ impl Compiler { .join(Self::expand_tilde(&relative.cooked)?) .lexiclean(); + println!("IMPORT: {}", import.display()); + if import.is_file() { if current.file_path.contains(&import) { return Err(Error::CircularImport { @@ -82,7 +84,8 @@ impl Compiler { import, }); } - *absolute = Some(import.clone()); + //*absolute = Some(import.clone()); + *absolute_paths = vec![import.clone()]; stack.push(current.import(import, path.offset)); } else if !*optional { return Err(Error::MissingImportFile { path: *path }); diff --git a/src/item.rs b/src/item.rs index 08d723fe70..23cbb0176e 100644 --- a/src/item.rs +++ b/src/item.rs @@ -7,7 +7,7 @@ pub(crate) enum Item<'src> { Assignment(Assignment<'src>), Comment(&'src str), Import { - absolute: Option, + absolute_paths: Vec, optional: bool, path: Token<'src>, relative: StringLiteral<'src>, diff --git a/src/parser.rs b/src/parser.rs index da2ff76f3f..a82f15b241 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -365,7 +365,7 @@ impl<'run, 'src> Parser<'run, 'src> { let optional = self.accepted(QuestionMark)?; let (path, relative) = self.parse_string_literal_token()?; items.push(Item::Import { - absolute: None, + absolute_paths: vec![], optional, path, relative, From 79f1e53ca9d7566eedf20dd240ff8c3ac1322775 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Tue, 17 Sep 2024 00:33:28 -0700 Subject: [PATCH 02/16] glob crate --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + src/compiler.rs | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 80a7276d9d..c1be4e1688 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -454,6 +454,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "heck" version = "0.5.0" @@ -536,6 +542,7 @@ dependencies = [ "dotenvy", "edit-distance", "executable-path", + "glob", "heck", "lexiclean", "libc", diff --git a/Cargo.toml b/Cargo.toml index f74367d02f..f6ab4f2747 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ derivative = "2.0.0" dirs = "5.0.1" dotenvy = "0.15" edit-distance = "2.0.0" +glob = "0.3.1" heck = "0.5.0" lexiclean = "0.0.1" libc = "0.2.0" diff --git a/src/compiler.rs b/src/compiler.rs index b46e67f3b6..f39529727f 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -68,7 +68,7 @@ impl Compiler { optional, path, } => { - let import = current + let import_base = current .path .parent() .unwrap() @@ -77,6 +77,23 @@ impl Compiler { println!("IMPORT: {}", import.display()); + let glob_options = glob::MatchOptions { + case_sensitive: true, + require_literal_separator: false, + require_literal_leading_dot: false, + }; + + let import_paths = glob::glob_with(&import_base.display().to_string(), glob_options); + for import in import_paths { + if import.is_file() { + + } + + } + + + + if import.is_file() { if current.file_path.contains(&import) { return Err(Error::CircularImport { From 715ddd1a85f4df772e2a5f324cc4d61d13c865e5 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Thu, 19 Sep 2024 01:37:55 -0700 Subject: [PATCH 03/16] Work --- src/compiler.rs | 86 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 64 insertions(+), 22 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index f39529727f..d7d6f04638 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -68,41 +68,45 @@ impl Compiler { optional, path, } => { - let import_base = current + let import = current .path .parent() .unwrap() .join(Self::expand_tilde(&relative.cooked)?) .lexiclean(); - println!("IMPORT: {}", import.display()); - - let glob_options = glob::MatchOptions { - case_sensitive: true, - require_literal_separator: false, - require_literal_leading_dot: false, - }; - - let import_paths = glob::glob_with(&import_base.display().to_string(), glob_options); - for import in import_paths { - if import.is_file() { - + let import_base_str = import.to_string_lossy(); + let has_glob = import_base_str.find('*').is_some(); + + if has_glob { + let glob_options = glob::MatchOptions { + case_sensitive: true, + require_literal_separator: false, + require_literal_leading_dot: false, + }; + let import_paths = glob::glob_with(&import_base_str, glob_options).unwrap(); + for import in import_paths { + let import = import.unwrap(); + + if import.is_file() { + if current.file_path.contains(&import) { + return Err(Error::CircularImport { + current: current.path, + import, + }); + } + absolute_paths.push(import.clone()); + stack.push(current.import(import, path.offset)); + } } - - } - - - - - if import.is_file() { + } else if import.is_file() { if current.file_path.contains(&import) { return Err(Error::CircularImport { current: current.path, import, }); } - //*absolute = Some(import.clone()); - *absolute_paths = vec![import.clone()]; + absolute_paths.push(import.clone()); stack.push(current.import(import, path.offset)); } else if !*optional { return Err(Error::MissingImportFile { path: *path }); @@ -312,6 +316,44 @@ recipe_b: recipe_c ); } + #[test] + fn glob_imports() { + let justfile_top = r#" +import "./subdir/*.just" + "#; + let justfile_a = r" +a: + "; + let justfile_b = r" +b: + "; + let unused_justfile = r" +x: + "; + let tmp = temptree! { + justfile: justfile_top, + subdir: { + "a.just": justfile_a, + "b.just": justfile_b, + unusued: unused_justfile, + } + }; + let loader = Loader::new(); + let justfile_path = tmp.path().join("justfile"); + let compilation = Compiler::compile(&loader, &justfile_path).unwrap(); + let imported_files: HashSet<&PathBuf> = compilation.srcs.keys().collect(); + assert_eq!( + imported_files, + [ + justfile_path, + tmp.path().join("subdir/a.just"), + tmp.path().join("subdir/b.just") + ] + .iter() + .collect() + ); + } + #[test] fn find_module_file() { #[track_caller] From 9197d454626e7ae7d96a1636c4b122811d9b756b Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Thu, 19 Sep 2024 02:22:34 -0700 Subject: [PATCH 04/16] remove unwrap --- src/compiler.rs | 21 +++++++++++++++++++-- src/error.rs | 7 ++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index d7d6f04638..7728500723 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -84,9 +84,10 @@ impl Compiler { require_literal_separator: false, require_literal_leading_dot: false, }; - let import_paths = glob::glob_with(&import_base_str, glob_options).unwrap(); + let import_paths = glob::glob_with(&import_base_str, glob_options) + .map_err(|error| Error::ImportGlob { error, path: *path })?; for import in import_paths { - let import = import.unwrap(); + let Ok(import) = import else { continue }; if import.is_file() { if current.file_path.contains(&import) { @@ -354,6 +355,22 @@ x: ); } + #[test] + fn invalid_glob_imports() { + let justfile = r#" +import "./subdir/***.just" + "#; + let tmp = temptree! { + justfile: justfile, + }; + let loader = Loader::new(); + let justfile_path = tmp.path().join("justfile"); + let error = Compiler::compile(&loader, &justfile_path).unwrap_err(); + let expected = "error: import path glob: Pattern syntax error"; + let actual = error.color_display(Color::never()).to_string(); + assert!(actual.contains(expected), "Actual: {actual}"); + } + #[test] fn find_module_file() { #[track_caller] diff --git a/src/error.rs b/src/error.rs index dd6955fe41..04ad1c9109 100644 --- a/src/error.rs +++ b/src/error.rs @@ -110,6 +110,10 @@ pub(crate) enum Error<'src> { io_error: io::Error, }, Homedir, + ImportGlob { + error: glob::PatternError, + path: Token<'src>, + }, InitExists { justfile: PathBuf, }, @@ -212,7 +216,7 @@ impl<'src> Error<'src> { Self::Backtick { token, .. } => Some(*token), Self::Compile { compile_error } => Some(compile_error.context()), Self::FunctionCall { function, .. } => Some(function.token), - Self::MissingImportFile { path } => Some(*path), + Self::MissingImportFile { path } | Self::ImportGlob { path, .. } => Some(*path), _ => None, } } @@ -395,6 +399,7 @@ impl<'src> ColorDisplay for Error<'src> { Homedir => { write!(f, "Failed to get homedir")?; } + ImportGlob { error, .. } => write!(f, "import path glob: {error}")?, InitExists { justfile } => { write!(f, "Justfile `{}` already exists", justfile.display())?; } From 7c06b6002d47d51bdb4b3e18acf91a690d4e1e22 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 25 Sep 2024 00:22:35 -0700 Subject: [PATCH 05/16] globset --- Cargo.lock | 14 ++++++++++++++ Cargo.toml | 1 + 2 files changed, 15 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index c1be4e1688..f3aeb3c853 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -460,6 +460,19 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "globset" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + [[package]] name = "heck" version = "0.5.0" @@ -543,6 +556,7 @@ dependencies = [ "edit-distance", "executable-path", "glob", + "globset", "heck", "lexiclean", "libc", diff --git a/Cargo.toml b/Cargo.toml index f6ab4f2747..78d56efe07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ dirs = "5.0.1" dotenvy = "0.15" edit-distance = "2.0.0" glob = "0.3.1" +globset = "0.4.15" heck = "0.5.0" lexiclean = "0.0.1" libc = "0.2.0" From 1d346c981f5a268fa5e08a53a5abf2111911a032 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 25 Sep 2024 02:09:26 -0700 Subject: [PATCH 06/16] WIP globset work --- src/compiler.rs | 6 ++++++ src/error.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/compiler.rs b/src/compiler.rs index 7728500723..624d157c63 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -79,6 +79,11 @@ impl Compiler { let has_glob = import_base_str.find('*').is_some(); if has_glob { + let glob = globset::Glob::new(&import_base_str).map_err(|_err| + Error::ImportGlob { error: "FIX ERR".to_string(), path: *path } + )?.compile_matcher(); + /* + let glob_options = glob::MatchOptions { case_sensitive: true, require_literal_separator: false, @@ -100,6 +105,7 @@ impl Compiler { stack.push(current.import(import, path.offset)); } } + */ } else if import.is_file() { if current.file_path.contains(&import) { return Err(Error::CircularImport { diff --git a/src/error.rs b/src/error.rs index 04ad1c9109..58e10db143 100644 --- a/src/error.rs +++ b/src/error.rs @@ -111,7 +111,7 @@ pub(crate) enum Error<'src> { }, Homedir, ImportGlob { - error: glob::PatternError, + error: String, path: Token<'src>, }, InitExists { From a7ce5b17fa1c78eb2320733663f2f402faeb8b3b Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Thu, 26 Sep 2024 11:48:36 -0700 Subject: [PATCH 07/16] globwalk crate --- Cargo.lock | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + 2 files changed, 57 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index f3aeb3c853..85fdf69101 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -473,6 +473,17 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "globwalk" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757" +dependencies = [ + "bitflags", + "ignore", + "walkdir", +] + [[package]] name = "heck" version = "0.5.0" @@ -517,6 +528,22 @@ dependencies = [ "cc", ] +[[package]] +name = "ignore" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -557,6 +584,7 @@ dependencies = [ "executable-path", "glob", "globset", + "globwalk", "heck", "lexiclean", "libc", @@ -859,6 +887,15 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "semver" version = "1.0.23" @@ -1135,6 +1172,16 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1224,6 +1271,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 78d56efe07..bd2449ffd3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ dotenvy = "0.15" edit-distance = "2.0.0" glob = "0.3.1" globset = "0.4.15" +globwalk = "0.9.1" heck = "0.5.0" lexiclean = "0.0.1" libc = "0.2.0" From 0531bb58d3d7191ecfac228f86a03082a10b171a Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Thu, 26 Sep 2024 12:00:45 -0700 Subject: [PATCH 08/16] try globwalk --- src/compiler.rs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index 624d157c63..03f99ac447 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -79,10 +79,35 @@ impl Compiler { let has_glob = import_base_str.find('*').is_some(); if has_glob { + let walker = globwalk::glob_builder(import_base_str) + .build() + .map_err(|_err| Error::ImportGlob { + error: "FIX ERR".to_string(), + path: *path, + })?; + for maybe_entry in walker { + let Ok(entry) = maybe_entry else { continue }; + let import = entry.path().to_owned(); + println!("IMPORT: {}", import.display()); + + if import.is_file() { + if current.file_path.contains(&import) { + return Err(Error::CircularImport { + current: current.path, + import, + }); + } + absolute_paths.push(import.clone()); + stack.push(current.import(import, path.offset)); + } + } + + /* let glob = globset::Glob::new(&import_base_str).map_err(|_err| Error::ImportGlob { error: "FIX ERR".to_string(), path: *path } )?.compile_matcher(); - /* + */ + /* let glob_options = glob::MatchOptions { case_sensitive: true, @@ -364,7 +389,7 @@ x: #[test] fn invalid_glob_imports() { let justfile = r#" -import "./subdir/***.just" +import "./subdir/****.just" "#; let tmp = temptree! { justfile: justfile, From 0c0305456d26a19d7f4dcaac257af265fe6a6214 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 2 Oct 2024 00:17:10 -0700 Subject: [PATCH 09/16] Work --- Cargo.lock | 70 ------------------------------------------------- Cargo.toml | 2 -- src/compiler.rs | 40 +++++----------------------- 3 files changed, 7 insertions(+), 105 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 85fdf69101..c1be4e1688 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -460,30 +460,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "globset" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" -dependencies = [ - "aho-corasick", - "bstr", - "log", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "globwalk" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757" -dependencies = [ - "bitflags", - "ignore", - "walkdir", -] - [[package]] name = "heck" version = "0.5.0" @@ -528,22 +504,6 @@ dependencies = [ "cc", ] -[[package]] -name = "ignore" -version = "0.4.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b" -dependencies = [ - "crossbeam-deque", - "globset", - "log", - "memchr", - "regex-automata", - "same-file", - "walkdir", - "winapi-util", -] - [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -583,8 +543,6 @@ dependencies = [ "edit-distance", "executable-path", "glob", - "globset", - "globwalk", "heck", "lexiclean", "libc", @@ -887,15 +845,6 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "semver" version = "1.0.23" @@ -1172,16 +1121,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "walkdir" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" -dependencies = [ - "same-file", - "winapi-util", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1271,15 +1210,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" -dependencies = [ - "windows-sys 0.59.0", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index bd2449ffd3..f6ab4f2747 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,8 +31,6 @@ dirs = "5.0.1" dotenvy = "0.15" edit-distance = "2.0.0" glob = "0.3.1" -globset = "0.4.15" -globwalk = "0.9.1" heck = "0.5.0" lexiclean = "0.0.1" libc = "0.2.0" diff --git a/src/compiler.rs b/src/compiler.rs index 03f99ac447..3ece28dd1c 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -79,43 +79,18 @@ impl Compiler { let has_glob = import_base_str.find('*').is_some(); if has_glob { - let walker = globwalk::glob_builder(import_base_str) - .build() - .map_err(|_err| Error::ImportGlob { - error: "FIX ERR".to_string(), - path: *path, - })?; - for maybe_entry in walker { - let Ok(entry) = maybe_entry else { continue }; - let import = entry.path().to_owned(); - println!("IMPORT: {}", import.display()); - - if import.is_file() { - if current.file_path.contains(&import) { - return Err(Error::CircularImport { - current: current.path, - import, - }); - } - absolute_paths.push(import.clone()); - stack.push(current.import(import, path.offset)); - } - } - - /* - let glob = globset::Glob::new(&import_base_str).map_err(|_err| - Error::ImportGlob { error: "FIX ERR".to_string(), path: *path } - )?.compile_matcher(); - */ - /* - let glob_options = glob::MatchOptions { case_sensitive: true, require_literal_separator: false, require_literal_leading_dot: false, }; - let import_paths = glob::glob_with(&import_base_str, glob_options) - .map_err(|error| Error::ImportGlob { error, path: *path })?; + let import_paths = + glob::glob_with(&import_base_str, glob_options).map_err(|error| { + Error::ImportGlob { + error: error.to_string(), + path: *path, + } + })?; for import in import_paths { let Ok(import) = import else { continue }; @@ -130,7 +105,6 @@ impl Compiler { stack.push(current.import(import, path.offset)); } } - */ } else if import.is_file() { if current.file_path.contains(&import) { return Err(Error::CircularImport { From 329c7fc3b88054cf51e6b715d80d8f78c4a26d79 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 2 Oct 2024 01:21:17 -0700 Subject: [PATCH 10/16] More work --- fuzz/Cargo.lock | 902 +++++++++++++++++++++++++++++++++++----- src/argument_parser.rs | 14 +- src/compiler.rs | 29 +- src/subcommand.rs | 2 +- src/summary.rs | 4 +- src/unstable_feature.rs | 2 + 6 files changed, 827 insertions(+), 126 deletions(-) diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index 52411ee839..2d221f8225 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -4,13 +4,28 @@ version = 3 [[package]] name = "aho-corasick" -version = "0.7.18" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "ansi_term" version = "0.12.1" @@ -20,6 +35,55 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstream" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" + +[[package]] +name = "anstyle-parse" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "arbitrary" version = "1.1.2" @@ -27,15 +91,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25e0a02cf12f1b1f48b14cb7f8217b876d09992b39c816ffb3b1ba64dd979a87" [[package]] -name = "atty" -version = "0.2.14" +name = "arrayref" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bitflags" @@ -43,6 +114,27 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "blake3" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", + "memmap2", + "rayon-core", +] + [[package]] name = "block-buffer" version = "0.10.2" @@ -60,9 +152,21 @@ checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ "lazy_static", "memchr", - "regex-automata", + "regex-automata 0.1.10", ] +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "camino" version = "1.0.9" @@ -71,9 +175,12 @@ checksum = "869119e97797867fd90f5e22af7d0bd274bd4635ebb9eb68c04f3f513ae6c412" [[package]] name = "cc" -version = "1.0.73" +version = "1.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -81,22 +188,98 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets 0.52.6", +] + [[package]] name = "clap" -version = "2.34.0" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" dependencies = [ - "ansi_term", - "atty", - "bitflags", + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", "strsim", - "term_size", - "textwrap", - "unicode-width", - "vec_map", + "terminal_size", ] +[[package]] +name = "clap_complete" +version = "4.5.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8937760c3f4c60871870b8c3ee5f9b30771f792a7045c48bcbba999d7d6b3b8e" +dependencies = [ + "clap", +] + +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "clap_lex" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + +[[package]] +name = "clap_mangen" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17415fd4dfbea46e3274fcd8d368284519b358654772afb700dc2e8d2b24eeb" +dependencies = [ + "clap", + "roff", +] + +[[package]] +name = "colorchoice" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" + +[[package]] +name = "constant_time_eq" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "cpufeatures" version = "0.2.2" @@ -106,6 +289,31 @@ dependencies = [ "libc", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + [[package]] name = "crypto-common" version = "0.1.3" @@ -134,7 +342,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.98", ] [[package]] @@ -148,16 +356,31 @@ dependencies = [ ] [[package]] -name = "doc-comment" -version = "0.3.3" +name = "dirs" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] [[package]] -name = "dotenv" -version = "0.15.0" +name = "dotenvy" +version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] name = "edit-distance" @@ -166,16 +389,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbbaaaf38131deb9ca518a274a45bfdb8771f139517b073b16c2d3d32ae5037b" [[package]] -name = "env_logger" -version = "0.9.0" +name = "errno" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", + "libc", + "windows-sys 0.52.0", ] [[package]] @@ -208,26 +428,52 @@ dependencies = [ "wasi", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "heck" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" -version = "0.1.19" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "iana-time-zone" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ - "libc", + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", ] [[package]] -name = "humantime" -version = "2.1.0" +name = "iana-time-zone-haiku" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] [[package]] name = "instant" @@ -238,33 +484,57 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itoa" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" +[[package]] +name = "js-sys" +version = "0.3.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "just" -version = "1.2.0" +version = "1.36.0" dependencies = [ "ansi_term", - "atty", + "blake3", "camino", + "chrono", "clap", + "clap_complete", + "clap_mangen", "ctrlc", "derivative", - "dotenv", + "dirs", + "dotenvy", "edit-distance", - "env_logger", - "lazy_static", + "glob", + "heck 0.5.0", "lexiclean", "libc", - "log", + "num_cpus", + "once_cell", + "percent-encoding", + "rand", "regex", + "semver", "serde", "serde_json", "sha2", + "shellexpand", "similar", "snafu", "strum", @@ -297,9 +567,9 @@ checksum = "441225017b106b9f902e97947a6d31e44ebcf274b91bdbfb51e5c477fcd468e5" [[package]] name = "libc" -version = "0.2.126" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libfuzzer-sys" @@ -312,6 +582,22 @@ dependencies = [ "once_cell", ] +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + [[package]] name = "log" version = "0.4.17" @@ -323,9 +609,18 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memmap2" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" +dependencies = [ + "libc", +] [[package]] name = "nix" @@ -333,52 +628,153 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f17df307904acd05aa8e32e97bb20f2a0df1728bbc2d771ae8f9a90463441e9" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", ] +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "once_cell" -version = "1.12.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro2" -version = "1.0.40" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.20" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "redox_syscall" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" dependencies = [ - "bitflags", + "bitflags 1.3.2", +] + +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror", ] [[package]] name = "regex" -version = "1.5.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", + "regex-automata 0.4.8", "regex-syntax", ] @@ -388,11 +784,22 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +[[package]] +name = "regex-automata" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + [[package]] name = "regex-syntax" -version = "0.6.26" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "remove_dir_all" @@ -403,6 +810,25 @@ dependencies = [ "winapi", ] +[[package]] +name = "roff" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88f8660c1ff60292143c98d08fc6e2f654d722db50410e3f3797d40baaf9d8f3" + +[[package]] +name = "rustix" +version = "0.38.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "rustversion" version = "1.0.7" @@ -415,6 +841,12 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + [[package]] name = "serde" version = "1.0.137" @@ -432,7 +864,7 @@ checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.98", ] [[package]] @@ -457,6 +889,21 @@ dependencies = [ "digest", ] +[[package]] +name = "shellexpand" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b" +dependencies = [ + "dirs", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "similar" version = "2.1.0" @@ -469,52 +916,51 @@ dependencies = [ [[package]] name = "snafu" -version = "0.7.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5177903bf45656592d9eb5c0e22f408fc023aae51dbe2088889b71633ba451f2" +checksum = "223891c85e2a29c3fe8fb900c1fae5e69c2e42415e3177752e8718475efa5019" dependencies = [ - "doc-comment", "snafu-derive", ] [[package]] name = "snafu-derive" -version = "0.7.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410b26ed97440d90ced3e2488c868d56a86e2064f5d7d6f417909b286afe25e5" +checksum = "03c3c6b7927ffe7ecaa769ee0e3994da3b8cafc8f444578982c83ecb161af917" dependencies = [ - "heck", + "heck 0.4.0", "proc-macro2", "quote", - "syn", + "syn 2.0.79", ] [[package]] name = "strsim" -version = "0.8.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" -version = "0.24.1" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" -version = "0.24.0" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", - "syn", + "syn 2.0.79", ] [[package]] @@ -528,6 +974,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "target" version = "2.0.0" @@ -549,32 +1006,33 @@ dependencies = [ ] [[package]] -name = "term_size" -version = "0.3.2" +name = "terminal_size" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" +checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef" dependencies = [ - "libc", - "winapi", + "rustix", + "windows-sys 0.59.0", ] [[package]] -name = "termcolor" -version = "1.1.3" +name = "thiserror" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ - "winapi-util", + "thiserror-impl", ] [[package]] -name = "textwrap" -version = "0.11.0" +name = "thiserror-impl" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ - "term_size", - "unicode-width", + "proc-macro2", + "quote", + "syn 2.0.79", ] [[package]] @@ -603,9 +1061,15 @@ checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" [[package]] name = "unicode-width" -version = "0.1.9" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" @@ -616,12 +1080,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.4" @@ -634,6 +1092,61 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.79", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" + [[package]] name = "winapi" version = "0.3.9" @@ -651,16 +1164,185 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] -name = "winapi-util" -version = "0.1.5" +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "winapi", + "windows-targets 0.52.6", ] [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows-sys" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] diff --git a/src/argument_parser.rs b/src/argument_parser.rs index 091ffd89b9..d94eeb7b0c 100644 --- a/src/argument_parser.rs +++ b/src/argument_parser.rs @@ -252,7 +252,7 @@ mod tests { fs::write(&path, "mod foo").unwrap(); fs::create_dir(tempdir.path().join("foo")).unwrap(); fs::write(tempdir.path().join("foo/mod.just"), "bar:").unwrap(); - let compilation = Compiler::compile(&loader, &path).unwrap(); + let compilation = Compiler::compile(&loader, &path, false).unwrap(); assert_eq!( ArgumentParser::parse_arguments(&compilation.justfile, &["foo", "bar"]).unwrap(), @@ -271,7 +271,7 @@ mod tests { fs::write(&path, "mod foo").unwrap(); fs::create_dir(tempdir.path().join("foo")).unwrap(); fs::write(tempdir.path().join("foo/mod.just"), "bar:").unwrap(); - let compilation = Compiler::compile(&loader, &path).unwrap(); + let compilation = Compiler::compile(&loader, &path, false).unwrap(); assert_matches!( ArgumentParser::parse_arguments(&compilation.justfile, &["foo", "zzz"]).unwrap_err(), @@ -289,7 +289,7 @@ mod tests { tempdir.write("foo.just", "bar:"); let loader = Loader::new(); - let compilation = Compiler::compile(&loader, &tempdir.path().join("justfile")).unwrap(); + let compilation = Compiler::compile(&loader, &tempdir.path().join("justfile"), false).unwrap(); assert_matches!( ArgumentParser::parse_arguments(&compilation.justfile, &["foo::zzz"]).unwrap_err(), @@ -307,7 +307,7 @@ mod tests { tempdir.write("foo.just", "bar:"); let loader = Loader::new(); - let compilation = Compiler::compile(&loader, &tempdir.path().join("justfile")).unwrap(); + let compilation = Compiler::compile(&loader, &tempdir.path().join("justfile"), false).unwrap(); assert_matches!( ArgumentParser::parse_arguments(&compilation.justfile, &["foo::bar::baz"]).unwrap_err(), @@ -323,7 +323,7 @@ mod tests { tempdir.write("justfile", ""); let loader = Loader::new(); - let compilation = Compiler::compile(&loader, &tempdir.path().join("justfile")).unwrap(); + let compilation = Compiler::compile(&loader, &tempdir.path().join("justfile"), false).unwrap(); assert_matches!( ArgumentParser::parse_arguments(&compilation.justfile, &[]).unwrap_err(), @@ -337,7 +337,7 @@ mod tests { tempdir.write("justfile", "foo bar:"); let loader = Loader::new(); - let compilation = Compiler::compile(&loader, &tempdir.path().join("justfile")).unwrap(); + let compilation = Compiler::compile(&loader, &tempdir.path().join("justfile"), false).unwrap(); assert_matches!( ArgumentParser::parse_arguments(&compilation.justfile, &[]).unwrap_err(), @@ -355,7 +355,7 @@ mod tests { tempdir.write("foo.just", "bar:"); let loader = Loader::new(); - let compilation = Compiler::compile(&loader, &tempdir.path().join("justfile")).unwrap(); + let compilation = Compiler::compile(&loader, &tempdir.path().join("justfile"), false).unwrap(); assert_matches!( ArgumentParser::parse_arguments(&compilation.justfile, &[]).unwrap_err(), diff --git a/src/compiler.rs b/src/compiler.rs index 3ece28dd1c..4af6ba3325 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -6,6 +6,7 @@ impl Compiler { pub(crate) fn compile<'src>( loader: &'src Loader, root: &Path, + unstable: bool, ) -> RunResult<'src, Compilation<'src>> { let mut asts = HashMap::::new(); let mut loaded = Vec::new(); @@ -31,6 +32,16 @@ impl Compiler { paths.insert(current.path.clone(), relative.into()); srcs.insert(current.path.clone(), src); + let ast_unstable = ast.items.iter().any(|item| { + matches!( + item, + Item::Set(Set { + name: _, + value: Setting::Unstable(true) + }) + ) + }); + for item in &mut ast.items { match item { Item::Module { @@ -75,10 +86,16 @@ impl Compiler { .join(Self::expand_tilde(&relative.cooked)?) .lexiclean(); - let import_base_str = import.to_string_lossy(); - let has_glob = import_base_str.find('*').is_some(); + let has_glob = import.as_os_str().as_encoded_bytes().contains(&b'*'); if has_glob { + if !(unstable || ast_unstable) { + return Err(Error::UnstableFeature { + unstable_feature: UnstableFeature::GlobImport, + }); + } + + let import_base_str = import.to_string_lossy(); let glob_options = glob::MatchOptions { case_sensitive: true, require_literal_separator: false, @@ -297,7 +314,7 @@ recipe_b: recipe_c let loader = Loader::new(); let justfile_a_path = tmp.path().join("justfile"); - let compilation = Compiler::compile(&loader, &justfile_a_path).unwrap(); + let compilation = Compiler::compile(&loader, &justfile_a_path, false).unwrap(); assert_eq!(compilation.root_src(), justfile_a); } @@ -314,7 +331,7 @@ recipe_b: recipe_c let loader = Loader::new(); let justfile_a_path = tmp.path().join("justfile"); - let loader_output = Compiler::compile(&loader, &justfile_a_path).unwrap_err(); + let loader_output = Compiler::compile(&loader, &justfile_a_path, false).unwrap_err(); assert_matches!(loader_output, Error::CircularImport { current, import } if current == tmp.path().join("subdir").join("b").lexiclean() && @@ -346,7 +363,7 @@ x: }; let loader = Loader::new(); let justfile_path = tmp.path().join("justfile"); - let compilation = Compiler::compile(&loader, &justfile_path).unwrap(); + let compilation = Compiler::compile(&loader, &justfile_path, true).unwrap(); let imported_files: HashSet<&PathBuf> = compilation.srcs.keys().collect(); assert_eq!( imported_files, @@ -370,7 +387,7 @@ import "./subdir/****.just" }; let loader = Loader::new(); let justfile_path = tmp.path().join("justfile"); - let error = Compiler::compile(&loader, &justfile_path).unwrap_err(); + let error = Compiler::compile(&loader, &justfile_path, true).unwrap_err(); let expected = "error: import path glob: Pattern syntax error"; let actual = error.color_display(Color::never()).to_string(); assert!(actual.contains(expected), "Actual: {actual}"); diff --git a/src/subcommand.rs b/src/subcommand.rs index b1f1359215..da51c28409 100644 --- a/src/subcommand.rs +++ b/src/subcommand.rs @@ -149,7 +149,7 @@ impl Subcommand { loader: &'src Loader, search: &Search, ) -> RunResult<'src, Compilation<'src>> { - let compilation = Compiler::compile(loader, &search.justfile)?; + let compilation = Compiler::compile(loader, &search.justfile, config.unstable)?; compilation.justfile.check_unstable(config)?; diff --git a/src/summary.rs b/src/summary.rs index ee3a8d1155..7e473d3284 100644 --- a/src/summary.rs +++ b/src/summary.rs @@ -25,10 +25,10 @@ mod full { }; } -pub fn summary(path: &Path) -> io::Result> { +pub fn summary(path: &Path, unstable: bool) -> io::Result> { let loader = Loader::new(); - match Compiler::compile(&loader, path) { + match Compiler::compile(&loader, path, unstable) { Ok(compilation) => Ok(Ok(Summary::new(&compilation.justfile))), Err(error) => Ok(Err(if let Error::Compile { compile_error } = error { compile_error.to_string() diff --git a/src/unstable_feature.rs b/src/unstable_feature.rs index 07d99540e5..b110419379 100644 --- a/src/unstable_feature.rs +++ b/src/unstable_feature.rs @@ -3,6 +3,7 @@ use super::*; #[derive(Copy, Clone, Debug, PartialEq, Ord, Eq, PartialOrd)] pub(crate) enum UnstableFeature { FormatSubcommand, + GlobImport, ScriptAttribute, ScriptInterpreterSetting, } @@ -11,6 +12,7 @@ impl Display for UnstableFeature { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { Self::FormatSubcommand => write!(f, "The `--fmt` command is currently unstable."), + Self::GlobImport => write!(f, "Glob imports are currently unstable"), Self::ScriptAttribute => write!(f, "The `[script]` attribute is currently unstable."), Self::ScriptInterpreterSetting => { write!(f, "The `script-interpreter` setting is currently unstable.") From c0b4023bce7b9f558d9f9861992e6aac3c68657d Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 2 Oct 2024 01:38:29 -0700 Subject: [PATCH 11/16] UTF-8 --- src/compiler.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index 4af6ba3325..13be273357 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -95,14 +95,21 @@ impl Compiler { }); } - let import_base_str = import.to_string_lossy(); + let import_base_str = + import + .as_os_str() + .to_str() + .ok_or_else(|| Error::ImportGlob { + error: "non-UTF-8 glob import".to_string(), + path: *path, + })?; let glob_options = glob::MatchOptions { case_sensitive: true, require_literal_separator: false, require_literal_leading_dot: false, }; let import_paths = - glob::glob_with(&import_base_str, glob_options).map_err(|error| { + glob::glob_with(import_base_str, glob_options).map_err(|error| { Error::ImportGlob { error: error.to_string(), path: *path, From 440ee92c0f09a6fd60cef498a9bde4d87188b98b Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 2 Oct 2024 01:48:10 -0700 Subject: [PATCH 12/16] directory error case --- src/compiler.rs | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/compiler.rs b/src/compiler.rs index 13be273357..26e10988af 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -127,6 +127,14 @@ impl Compiler { } absolute_paths.push(import.clone()); stack.push(current.import(import, path.offset)); + } else if import.is_dir() { + return Err(Error::ImportGlob { + error: format!( + "a glob import cannot match a directory; matched `{}`", + import.display() + ), + path: *path, + }); } } } else if import.is_file() { @@ -385,7 +393,7 @@ x: } #[test] - fn invalid_glob_imports() { + fn malformed_glob_imports() { let justfile = r#" import "./subdir/****.just" "#; @@ -400,6 +408,31 @@ import "./subdir/****.just" assert!(actual.contains(expected), "Actual: {actual}"); } + #[test] + fn glob_import_match_dir_errors() { + let justfile_top = r#" +import "./subdir/*" + "#; + let justfile_a = r" +a: + "; + let tmp = temptree! { + justfile: justfile_top, + subdir: { + "a.just": justfile_a, + subsubdir: { + + } + } + }; + let loader = Loader::new(); + let justfile_path = tmp.path().join("justfile"); + let error = Compiler::compile(&loader, &justfile_path, true).unwrap_err(); + let expected = "error: import path glob: a glob import cannot match a directory"; + let actual = error.color_display(Color::never()).to_string(); + assert!(actual.contains(expected), "Actual: {actual}"); + } + #[test] fn find_module_file() { #[track_caller] From 12a06c8b824079131f6e482e72b4951b1834902a Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 2 Oct 2024 19:00:03 -0700 Subject: [PATCH 13/16] some PR feedback --- src/analyzer.rs | 4 ++-- src/compiler.rs | 2 +- src/parser.rs | 2 +- src/unstable_feature.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/analyzer.rs b/src/analyzer.rs index a35a608235..474f13cbbd 100644 --- a/src/analyzer.rs +++ b/src/analyzer.rs @@ -53,8 +53,8 @@ impl<'run, 'src> Analyzer<'run, 'src> { } Item::Comment(_) => (), Item::Import { absolute_paths, .. } => { - for p in absolute_paths { - stack.push(asts.get(p).unwrap()); + for path in absolute_paths { + stack.push(asts.get(path).unwrap()); } } Item::Module { diff --git a/src/compiler.rs b/src/compiler.rs index 26e10988af..1a09f255c3 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -91,7 +91,7 @@ impl Compiler { if has_glob { if !(unstable || ast_unstable) { return Err(Error::UnstableFeature { - unstable_feature: UnstableFeature::GlobImport, + unstable_feature: UnstableFeature::ImportPathGlob, }); } diff --git a/src/parser.rs b/src/parser.rs index a82f15b241..89050369ec 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -365,7 +365,7 @@ impl<'run, 'src> Parser<'run, 'src> { let optional = self.accepted(QuestionMark)?; let (path, relative) = self.parse_string_literal_token()?; items.push(Item::Import { - absolute_paths: vec![], + absolute_paths: Vec::new(), optional, path, relative, diff --git a/src/unstable_feature.rs b/src/unstable_feature.rs index b110419379..d8860cc5cb 100644 --- a/src/unstable_feature.rs +++ b/src/unstable_feature.rs @@ -3,7 +3,7 @@ use super::*; #[derive(Copy, Clone, Debug, PartialEq, Ord, Eq, PartialOrd)] pub(crate) enum UnstableFeature { FormatSubcommand, - GlobImport, + ImportPathGlob, ScriptAttribute, ScriptInterpreterSetting, } @@ -12,7 +12,7 @@ impl Display for UnstableFeature { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { Self::FormatSubcommand => write!(f, "The `--fmt` command is currently unstable."), - Self::GlobImport => write!(f, "Glob imports are currently unstable"), + Self::ImportPathGlob => write!(f, "Globs in import paths are currently unstable"), Self::ScriptAttribute => write!(f, "The `[script]` attribute is currently unstable."), Self::ScriptInterpreterSetting => { write!(f, "The `script-interpreter` setting is currently unstable.") From fdbc5624986d6e284ac649a7d6b74711b699a939 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Fri, 4 Oct 2024 13:35:39 -0700 Subject: [PATCH 14/16] Addl work --- src/compiler.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index 1a09f255c3..6c49e4f44f 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -95,17 +95,13 @@ impl Compiler { }); } - let import_base_str = - import - .as_os_str() - .to_str() - .ok_or_else(|| Error::ImportGlob { - error: "non-UTF-8 glob import".to_string(), - path: *path, - })?; + let import_base_str = import.to_str().ok_or_else(|| Error::ImportGlob { + error: "non-UTF-8 glob import".to_string(), + path: *path, + })?; let glob_options = glob::MatchOptions { case_sensitive: true, - require_literal_separator: false, + require_literal_separator: true, require_literal_leading_dot: false, }; let import_paths = @@ -116,7 +112,10 @@ impl Compiler { } })?; for import in import_paths { - let Ok(import) = import else { continue }; + let import = import.map_err(|glob_err| Error::ImportGlob { + path: *path, + error: glob_err.path().display().to_string(), + })?; if import.is_file() { if current.file_path.contains(&import) { From c971456d3c4f2f7838ee2f5347d1fec4ec07d0f5 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Fri, 4 Oct 2024 14:25:27 -0700 Subject: [PATCH 15/16] Glob err --- src/compiler.rs | 13 +++++-------- src/error.rs | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index 6c49e4f44f..2dfba69e85 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -112,9 +112,9 @@ impl Compiler { } })?; for import in import_paths { - let import = import.map_err(|glob_err| Error::ImportGlob { + let import = import.map_err(|glob_err| Error::ImportGlobPattern { path: *path, - error: glob_err.path().display().to_string(), + glob_err, })?; if import.is_file() { @@ -127,11 +127,8 @@ impl Compiler { absolute_paths.push(import.clone()); stack.push(current.import(import, path.offset)); } else if import.is_dir() { - return Err(Error::ImportGlob { - error: format!( - "a glob import cannot match a directory; matched `{}`", - import.display() - ), + return Err(Error::ImportGlobDirectory { + import, path: *path, }); } @@ -427,7 +424,7 @@ a: let loader = Loader::new(); let justfile_path = tmp.path().join("justfile"); let error = Compiler::compile(&loader, &justfile_path, true).unwrap_err(); - let expected = "error: import path glob: a glob import cannot match a directory"; + let expected = "error: A glob import cannot match a directory"; let actual = error.color_display(Color::never()).to_string(); assert!(actual.contains(expected), "Actual: {actual}"); } diff --git a/src/error.rs b/src/error.rs index 58e10db143..1bd564ae98 100644 --- a/src/error.rs +++ b/src/error.rs @@ -114,6 +114,14 @@ pub(crate) enum Error<'src> { error: String, path: Token<'src>, }, + ImportGlobDirectory { + path: Token<'src>, + import: PathBuf, + }, + ImportGlobPattern { + path: Token<'src>, + glob_err: glob::GlobError, + }, InitExists { justfile: PathBuf, }, @@ -216,7 +224,10 @@ impl<'src> Error<'src> { Self::Backtick { token, .. } => Some(*token), Self::Compile { compile_error } => Some(compile_error.context()), Self::FunctionCall { function, .. } => Some(function.token), - Self::MissingImportFile { path } | Self::ImportGlob { path, .. } => Some(*path), + Self::MissingImportFile { path } + | Self::ImportGlob { path, .. } + | Self::ImportGlobPattern { path, .. } + | Self::ImportGlobDirectory { path, .. } => Some(*path), _ => None, } } @@ -400,6 +411,8 @@ impl<'src> ColorDisplay for Error<'src> { write!(f, "Failed to get homedir")?; } ImportGlob { error, .. } => write!(f, "import path glob: {error}")?, + ImportGlobDirectory { import, .. } => write!(f, "A glob import cannot match a directory; matched `{}`", import.display())?, + ImportGlobPattern { .. } => write!(f, "IMPORT GLOB PATTERN")?, InitExists { justfile } => { write!(f, "Justfile `{}` already exists", justfile.display())?; } From 227586e85199449ff08ea1af4223212c43599490 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Fri, 4 Oct 2024 14:39:01 -0700 Subject: [PATCH 16/16] More err --- src/compiler.rs | 17 ++++++++--------- src/error.rs | 17 +++++++++++------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index 2dfba69e85..f3944caf3a 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -95,24 +95,23 @@ impl Compiler { }); } - let import_base_str = import.to_str().ok_or_else(|| Error::ImportGlob { - error: "non-UTF-8 glob import".to_string(), - path: *path, - })?; + let import_base_str = import + .to_str() + .ok_or_else(|| Error::ImportGlobUnicode { path: *path })?; let glob_options = glob::MatchOptions { case_sensitive: true, require_literal_separator: true, require_literal_leading_dot: false, }; let import_paths = - glob::glob_with(import_base_str, glob_options).map_err(|error| { - Error::ImportGlob { - error: error.to_string(), + glob::glob_with(import_base_str, glob_options).map_err(|pattern_err| { + Error::ImportGlobPattern { + pattern_err, path: *path, } })?; for import in import_paths { - let import = import.map_err(|glob_err| Error::ImportGlobPattern { + let import = import.map_err(|glob_err| Error::ImportGlobIteration { path: *path, glob_err, })?; @@ -399,7 +398,7 @@ import "./subdir/****.just" let loader = Loader::new(); let justfile_path = tmp.path().join("justfile"); let error = Compiler::compile(&loader, &justfile_path, true).unwrap_err(); - let expected = "error: import path glob: Pattern syntax error"; + let expected = "error: Invalid glob pattern: Pattern syntax error"; let actual = error.color_display(Color::never()).to_string(); assert!(actual.contains(expected), "Actual: {actual}"); } diff --git a/src/error.rs b/src/error.rs index 1bd564ae98..831ab4f271 100644 --- a/src/error.rs +++ b/src/error.rs @@ -110,9 +110,9 @@ pub(crate) enum Error<'src> { io_error: io::Error, }, Homedir, - ImportGlob { - error: String, + ImportGlobIteration { path: Token<'src>, + glob_err: glob::GlobError, }, ImportGlobDirectory { path: Token<'src>, @@ -120,7 +120,10 @@ pub(crate) enum Error<'src> { }, ImportGlobPattern { path: Token<'src>, - glob_err: glob::GlobError, + pattern_err: glob::PatternError, + }, + ImportGlobUnicode { + path: Token<'src>, }, InitExists { justfile: PathBuf, @@ -225,7 +228,8 @@ impl<'src> Error<'src> { Self::Compile { compile_error } => Some(compile_error.context()), Self::FunctionCall { function, .. } => Some(function.token), Self::MissingImportFile { path } - | Self::ImportGlob { path, .. } + | Self::ImportGlobIteration { path, .. } + | Self::ImportGlobUnicode { path, .. } | Self::ImportGlobPattern { path, .. } | Self::ImportGlobDirectory { path, .. } => Some(*path), _ => None, @@ -410,9 +414,10 @@ impl<'src> ColorDisplay for Error<'src> { Homedir => { write!(f, "Failed to get homedir")?; } - ImportGlob { error, .. } => write!(f, "import path glob: {error}")?, + ImportGlobIteration { glob_err,.. } => write!(f, "Glob error: {glob_err}")?, ImportGlobDirectory { import, .. } => write!(f, "A glob import cannot match a directory; matched `{}`", import.display())?, - ImportGlobPattern { .. } => write!(f, "IMPORT GLOB PATTERN")?, + ImportGlobPattern { pattern_err, .. } => write!(f, "Invalid glob pattern: {pattern_err}")?, + ImportGlobUnicode { .. } => write!(f, "Non-UTF-8 glob import")?, InitExists { justfile } => { write!(f, "Justfile `{}` already exists", justfile.display())?; }