From 884723831bb677e5c28bdce74ddd54036363096e Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Tue, 28 Jun 2022 09:48:19 -0500 Subject: [PATCH 1/3] fix path seperator --- packages/rsx_interpreter/src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/rsx_interpreter/src/lib.rs b/packages/rsx_interpreter/src/lib.rs index 8f74ce29b..cfda4c2ed 100644 --- a/packages/rsx_interpreter/src/lib.rs +++ b/packages/rsx_interpreter/src/lib.rs @@ -24,7 +24,8 @@ lazy_static! { // the location of the code relative to the current crate based on [std::panic::Location] #[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)] pub struct CodeLocation { - pub file: String, + pub crate_path: String, + pub file_path: String, pub line: u32, pub column: u32, } @@ -83,14 +84,12 @@ macro_rules! get_line_num { () => {{ let line = line!(); let column = column!(); - let file = file!(); + let file_path = file!().to_string(); + let mut crate_path = env!("CARGO_MANIFEST_DIR").to_string(); - #[cfg(windows)] - let file = env!("CARGO_MANIFEST_DIR").to_string() + "\\" + file!(); - #[cfg(unix)] - let file = env!("CARGO_MANIFEST_DIR").to_string() + "/" + file!(); CodeLocation { - file: file.to_string(), + crate_path, + file_path, line: line, column: column, } From 8c3c75cab6b913982af1642b1bb3a57b2cd84f28 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Tue, 28 Jun 2022 10:02:50 -0500 Subject: [PATCH 2/3] update tests --- packages/rsx_interpreter/tests/render.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/rsx_interpreter/tests/render.rs b/packages/rsx_interpreter/tests/render.rs index ed139aec1..5d2d2bf8c 100644 --- a/packages/rsx_interpreter/tests/render.rs +++ b/packages/rsx_interpreter/tests/render.rs @@ -16,7 +16,8 @@ fn render_basic() { let dom = VirtualDom::new(Base); let static_vnodes = rsx!(div{"hello world"}); let location = CodeLocation { - file: String::new(), + file_path: String::new(), + crate_path: String::new(), line: 0, column: 0, }; @@ -61,7 +62,8 @@ fn render_nested() { } }; let location = CodeLocation { - file: String::new(), + file_path: String::new(), + crate_path: String::new(), line: 1, column: 0, }; @@ -112,7 +114,8 @@ fn render_component() { } }; let location = CodeLocation { - file: String::new(), + file_path: String::new(), + crate_path: String::new(), line: 2, column: 0, }; @@ -163,7 +166,8 @@ fn render_iterator() { } }; let location = CodeLocation { - file: String::new(), + file_path: String::new(), + crate_path: String::new(), line: 3, column: 0, }; @@ -216,7 +220,8 @@ fn render_captured_variable() { } }; let location = CodeLocation { - file: String::new(), + file_path: String::new(), + crate_path: String::new(), line: 4, column: 0, }; @@ -267,7 +272,8 @@ fn render_listener() { } }; let location = CodeLocation { - file: String::new(), + file_path: String::new(), + crate_path: String::new(), line: 5, column: 0, }; From cf2f504d776365fd695547b8d7da3710138e7488 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Tue, 28 Jun 2022 12:48:38 -0500 Subject: [PATCH 3/3] fix unnessisary mut --- packages/rsx_interpreter/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rsx_interpreter/src/lib.rs b/packages/rsx_interpreter/src/lib.rs index cfda4c2ed..ff50dcdb2 100644 --- a/packages/rsx_interpreter/src/lib.rs +++ b/packages/rsx_interpreter/src/lib.rs @@ -85,7 +85,7 @@ macro_rules! get_line_num { let line = line!(); let column = column!(); let file_path = file!().to_string(); - let mut crate_path = env!("CARGO_MANIFEST_DIR").to_string(); + let crate_path = env!("CARGO_MANIFEST_DIR").to_string(); CodeLocation { crate_path,