From e38114b82530a952ff7e7d2940e42f0f91f0a9cc Mon Sep 17 00:00:00 2001 From: IWANABETHATGUY Date: Mon, 9 Sep 2024 17:57:20 +0800 Subject: [PATCH] fix(ast_tools): fix ast-tool panic (#5641) `just ast` panic due to https://github.com/oxc-project/oxc/commit/553262842c055fbe63089fd15a7678d9831c7c9e, change the filename to makesure `ast_tool` still working 1. crates/oxc_span/src/source_type/types.rs is removed in 553262842c055fbe63089fd15a7678d9831c7c9e --- .github/.generated_ast_watch_list.yml | 2 +- tasks/ast_tools/src/main.rs | 2 +- tasks/ast_tools/src/rust_ast.rs | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/.generated_ast_watch_list.yml b/.github/.generated_ast_watch_list.yml index 6dfc7e926c7d1..818c9ee29d83c 100644 --- a/.github/.generated_ast_watch_list.yml +++ b/.github/.generated_ast_watch_list.yml @@ -9,7 +9,7 @@ src: - 'crates/oxc_syntax/src/number.rs' - 'crates/oxc_syntax/src/operator.rs' - 'crates/oxc_span/src/span/types.rs' - - 'crates/oxc_span/src/source_type/types.rs' + - 'crates/oxc_span/src/source_type/mod.rs' - 'crates/oxc_regular_expression/src/ast.rs' - 'crates/oxc_ast/src/generated/derive_clone_in.rs' - 'crates/oxc_regular_expression/src/generated/derive_clone_in.rs' diff --git a/tasks/ast_tools/src/main.rs b/tasks/ast_tools/src/main.rs index d76a43b0bebc7..2bbc84f2e0b77 100644 --- a/tasks/ast_tools/src/main.rs +++ b/tasks/ast_tools/src/main.rs @@ -33,7 +33,7 @@ static SOURCE_PATHS: &[&str] = &[ "crates/oxc_syntax/src/number.rs", "crates/oxc_syntax/src/operator.rs", "crates/oxc_span/src/span/types.rs", - "crates/oxc_span/src/source_type/types.rs", + "crates/oxc_span/src/source_type/mod.rs", "crates/oxc_regular_expression/src/ast.rs", ]; diff --git a/tasks/ast_tools/src/rust_ast.rs b/tasks/ast_tools/src/rust_ast.rs index d2c9271ee81fa..36c007d3ee56d 100644 --- a/tasks/ast_tools/src/rust_ast.rs +++ b/tasks/ast_tools/src/rust_ast.rs @@ -303,8 +303,9 @@ impl Module { pub fn load(mut self) -> Result { assert!(!self.loaded, "can't load twice!"); - - let mut file = std::fs::File::open(&self.file).normalize()?; + let mut file = std::fs::File::open(&self.file).normalize().map_err(|err| { + format!("Error reading file: {}, reason: {}", &self.file.to_string_lossy(), err) + })?; let mut content = String::new(); file.read_to_string(&mut content).normalize()?; let file = parse_file(content.as_str()).normalize()?;