From 7c555d6905e55f9c202adadd9fe360cdddf5115d Mon Sep 17 00:00:00 2001 From: Kogia-sima Date: Tue, 6 Apr 2021 20:42:35 +0900 Subject: [PATCH 1/7] Bump proc-macro2 (1.0.24 => 1.0.26) --- Cargo.lock | 8 ++++---- sailfish-compiler/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a921cc3..6cdccca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,9 +135,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.18" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ "unicode-xid", ] @@ -233,9 +233,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.30" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93a56fabc59dce20fe48b6c832cc249c713e7ed88fa28b0ee0a3bfcaae5fe4e2" +checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87" dependencies = [ "proc-macro2", "quote", diff --git a/sailfish-compiler/Cargo.toml b/sailfish-compiler/Cargo.toml index 24b1f72..8c05f8d 100644 --- a/sailfish-compiler/Cargo.toml +++ b/sailfish-compiler/Cargo.toml @@ -34,7 +34,7 @@ default-features = false features = ["parsing", "full", "visit-mut", "printing"] [dependencies.proc-macro2] -version = ">=1.0.11, <=1.0.24" +version = ">=1.0.11, <=1.0.26" default-features = false features = ["span-locations"] From 62b13b1b8df97ae50a0a820d3450f73313917d03 Mon Sep 17 00:00:00 2001 From: Kogia-sima Date: Tue, 6 Apr 2021 20:46:46 +0900 Subject: [PATCH 2/7] Fix package description --- sailfish-compiler/Cargo.toml | 2 +- sailfish-macros/Cargo.toml | 2 +- sailfish/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sailfish-compiler/Cargo.toml b/sailfish-compiler/Cargo.toml index 8c05f8d..03db908 100644 --- a/sailfish-compiler/Cargo.toml +++ b/sailfish-compiler/Cargo.toml @@ -2,7 +2,7 @@ name = "sailfish-compiler" version = "0.3.2" authors = ["Ryohei Machida "] -description = "Really fast, intuitive template engine for Rust" +description = "Simple, small, and extremely fast template engine for Rust" homepage = "https://github.com/Kogia-sima/sailfish" repository = "https://github.com/Kogia-sima/sailfish" readme = "../README.md" diff --git a/sailfish-macros/Cargo.toml b/sailfish-macros/Cargo.toml index 3fa1f91..f20f526 100644 --- a/sailfish-macros/Cargo.toml +++ b/sailfish-macros/Cargo.toml @@ -2,7 +2,7 @@ name = "sailfish-macros" version = "0.3.2" authors = ["Ryohei Machida "] -description = "Really fast, intuitive template engine for Rust" +description = "Simple, small, and extremely fast template engine for Rust" homepage = "https://github.com/Kogia-sima/sailfish" repository = "https://github.com/Kogia-sima/sailfish" readme = "../README.md" diff --git a/sailfish/Cargo.toml b/sailfish/Cargo.toml index efc4bcb..5dcd8ad 100644 --- a/sailfish/Cargo.toml +++ b/sailfish/Cargo.toml @@ -2,7 +2,7 @@ name = "sailfish" version = "0.3.2" authors = ["Ryohei Machida "] -description = "Really fast, intuitive template engine for Rust" +description = "Simple, small, and extremely fast template engine for Rust" homepage = "https://github.com/Kogia-sima/sailfish" repository = "https://github.com/Kogia-sima/sailfish" readme = "../README.md" From f0ef8e409a5492d2e1a866e6725e81d64439e928 Mon Sep 17 00:00:00 2001 From: Kogia-sima Date: Tue, 6 Apr 2021 21:48:46 +0900 Subject: [PATCH 3/7] Update compile error test --- .../integration-tests/tests/fails/unbalanced_brace.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sailfish-tests/integration-tests/tests/fails/unbalanced_brace.stderr b/sailfish-tests/integration-tests/tests/fails/unbalanced_brace.stderr index 8946b65..ca181b7 100644 --- a/sailfish-tests/integration-tests/tests/fails/unbalanced_brace.stderr +++ b/sailfish-tests/integration-tests/tests/fails/unbalanced_brace.stderr @@ -1,5 +1,5 @@ error: Failed to compile template. -caused by: Rust Syntax Error (LexError) +caused by: Rust Syntax Error (lex error) file: unbalanced_brace.stpl From 9bf409046846908b2d5327fe32e8196cc4e1ea5f Mon Sep 17 00:00:00 2001 From: Kogia-sima Date: Tue, 6 Apr 2021 21:49:05 +0900 Subject: [PATCH 4/7] Better error reporting for missing semicolon in code clock cc #33 #53 --- sailfish-compiler/src/translator.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sailfish-compiler/src/translator.rs b/sailfish-compiler/src/translator.rs index e4ada46..527a1da 100644 --- a/sailfish-compiler/src/translator.rs +++ b/sailfish-compiler/src/translator.rs @@ -116,6 +116,14 @@ impl SourceBuilder { fn write_text<'a>(&mut self, token: &Token<'a>) -> Result<(), Error> { use std::fmt::Write; + // if error has occured at the first byte of `render_text!` macro, it + // will be mapped to the first byte of text + self.source_map.entries.push(SourceMapEntry { + original: token.offset(), + new: self.source.len(), + length: 1, + }); + self.source.push_str("__sf_rt::render_text!(__sf_buf, "); // write text token with Debug::fmt write!(self.source, "{:?}", token.as_str()).unwrap(); From 8832b7e2c672a17ad80853e1c8c1afab17140afe Mon Sep 17 00:00:00 2001 From: Kogia-sima Date: Tue, 6 Apr 2021 21:50:40 +0900 Subject: [PATCH 5/7] test: Tests for missing semicolon in code block (9bf4090) --- .../tests/fails/missing_semicolon.rs | 10 +++++ .../tests/fails/missing_semicolon.stderr | 37 +++++++++++++++++++ .../fails/templates/missing_semicolon.stpl | 1 + 3 files changed, 48 insertions(+) create mode 100644 sailfish-tests/integration-tests/tests/fails/missing_semicolon.rs create mode 100644 sailfish-tests/integration-tests/tests/fails/missing_semicolon.stderr create mode 100644 sailfish-tests/integration-tests/tests/fails/templates/missing_semicolon.stpl diff --git a/sailfish-tests/integration-tests/tests/fails/missing_semicolon.rs b/sailfish-tests/integration-tests/tests/fails/missing_semicolon.rs new file mode 100644 index 0000000..8d68d31 --- /dev/null +++ b/sailfish-tests/integration-tests/tests/fails/missing_semicolon.rs @@ -0,0 +1,10 @@ +use sailfish::TemplateOnce; +use sailfish_macros::TemplateOnce; + +#[derive(TemplateOnce)] +#[template(path = "missing_semicolon.stpl")] +struct MissingSemicolon {} + +fn main() { + println!("{}", (MissingSemicolon {}).render_once().unwrap()); +} diff --git a/sailfish-tests/integration-tests/tests/fails/missing_semicolon.stderr b/sailfish-tests/integration-tests/tests/fails/missing_semicolon.stderr new file mode 100644 index 0000000..0f9bc79 --- /dev/null +++ b/sailfish-tests/integration-tests/tests/fails/missing_semicolon.stderr @@ -0,0 +1,37 @@ +error: Failed to compile template. +caused by: Rust Syntax Error (unexpected token) + +file: missing_semicolon.stpl +position: line 1, column 17 + + | +1 |
<% "foo" %>
+ | ^ + + --> $DIR/missing_semicolon.rs:4:10 + | +4 | #[derive(TemplateOnce)] + | ^^^^^^^^^^^^ + | + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0599]: no method named `render_once` found for struct `MissingSemicolon` in the current scope + --> $DIR/missing_semicolon.rs:9:42 + | +6 | struct MissingSemicolon {} + | ----------------------- method `render_once` not found for this +... +9 | println!("{}", (MissingSemicolon {}).render_once().unwrap()); + | ^^^^^^^^^^^ method not found in `MissingSemicolon` + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `render_once`, perhaps you need to implement it: + candidate #1: `TemplateOnce` + +warning: unused import: `sailfish::TemplateOnce` + --> $DIR/missing_semicolon.rs:1:5 + | +1 | use sailfish::TemplateOnce; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` on by default diff --git a/sailfish-tests/integration-tests/tests/fails/templates/missing_semicolon.stpl b/sailfish-tests/integration-tests/tests/fails/templates/missing_semicolon.stpl new file mode 100644 index 0000000..0895829 --- /dev/null +++ b/sailfish-tests/integration-tests/tests/fails/templates/missing_semicolon.stpl @@ -0,0 +1 @@ +
<% "foo" %>
From 8fc70c39fa0734a4074c8e2b35c1f8a42c8d14d5 Mon Sep 17 00:00:00 2001 From: Kogia-sima Date: Tue, 6 Apr 2021 21:52:20 +0900 Subject: [PATCH 6/7] Bump version (0.3.2 => 0.3.3) --- Cargo.lock | 8 ++++---- README.md | 2 +- docs/en/docs/installation.md | 2 +- examples/Cargo.toml | 2 +- sailfish-compiler/Cargo.toml | 2 +- sailfish-macros/Cargo.toml | 4 ++-- sailfish-tests/fuzzing-tests/Cargo.toml | 2 +- sailfish-tests/integration-tests/Cargo.toml | 2 +- sailfish/Cargo.toml | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6cdccca..8831237 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,7 @@ dependencies = [ [[package]] name = "integration-tests" -version = "0.3.2" +version = "0.3.3" dependencies = [ "pretty_assertions", "sailfish", @@ -168,7 +168,7 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "sailfish" -version = "0.3.2" +version = "0.3.3" dependencies = [ "itoap", "ryu", @@ -180,7 +180,7 @@ dependencies = [ [[package]] name = "sailfish-compiler" -version = "0.3.2" +version = "0.3.3" dependencies = [ "filetime", "home", @@ -194,7 +194,7 @@ dependencies = [ [[package]] name = "sailfish-macros" -version = "0.3.2" +version = "0.3.3" dependencies = [ "proc-macro2", "sailfish-compiler", diff --git a/README.md b/README.md index fc061c5..f0995f7 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Dependencies: ```toml [dependencies] -sailfish = "0.3.2" +sailfish = "0.3.3" ``` Template file (templates/hello.stpl): diff --git a/docs/en/docs/installation.md b/docs/en/docs/installation.md index 06be926..387b877 100644 --- a/docs/en/docs/installation.md +++ b/docs/en/docs/installation.md @@ -4,7 +4,7 @@ In order to use sailfish templates, you have add two dependencies in your `Cargo ``` toml [dependencies] -sailfish = "0.3.2" +sailfish = "0.3.3" ``` ## Feature Flags diff --git a/examples/Cargo.toml b/examples/Cargo.toml index cf42a43..65a18ed 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sailfish-examples" -version = "0.3.2" +version = "0.3.3" authors = ["Ryohei Machida "] edition = "2018" publish = false diff --git a/sailfish-compiler/Cargo.toml b/sailfish-compiler/Cargo.toml index 03db908..c36a792 100644 --- a/sailfish-compiler/Cargo.toml +++ b/sailfish-compiler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sailfish-compiler" -version = "0.3.2" +version = "0.3.3" authors = ["Ryohei Machida "] description = "Simple, small, and extremely fast template engine for Rust" homepage = "https://github.com/Kogia-sima/sailfish" diff --git a/sailfish-macros/Cargo.toml b/sailfish-macros/Cargo.toml index f20f526..74cdb00 100644 --- a/sailfish-macros/Cargo.toml +++ b/sailfish-macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sailfish-macros" -version = "0.3.2" +version = "0.3.3" authors = ["Ryohei Machida "] description = "Simple, small, and extremely fast template engine for Rust" homepage = "https://github.com/Kogia-sima/sailfish" @@ -30,6 +30,6 @@ proc-macro2 = "1.0.11" [dependencies.sailfish-compiler] path = "../sailfish-compiler" -version = "0.3.2" +version = "0.3.3" default-features = false features = ["procmacro"] diff --git a/sailfish-tests/fuzzing-tests/Cargo.toml b/sailfish-tests/fuzzing-tests/Cargo.toml index 9a7e83f..2ee0185 100644 --- a/sailfish-tests/fuzzing-tests/Cargo.toml +++ b/sailfish-tests/fuzzing-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fuzzing-tests" -version = "0.3.2" +version = "0.3.3" authors = ["Ryohei Machida "] edition = "2018" publish = false diff --git a/sailfish-tests/integration-tests/Cargo.toml b/sailfish-tests/integration-tests/Cargo.toml index 8c414b9..dec0ca7 100644 --- a/sailfish-tests/integration-tests/Cargo.toml +++ b/sailfish-tests/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "integration-tests" -version = "0.3.2" +version = "0.3.3" authors = ["Kogia-sima "] edition = "2018" publish = false diff --git a/sailfish/Cargo.toml b/sailfish/Cargo.toml index 5dcd8ad..772ee79 100644 --- a/sailfish/Cargo.toml +++ b/sailfish/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sailfish" -version = "0.3.2" +version = "0.3.3" authors = ["Ryohei Machida "] description = "Simple, small, and extremely fast template engine for Rust" homepage = "https://github.com/Kogia-sima/sailfish" @@ -29,7 +29,7 @@ serde_json = { version = "1.0.53", optional = true } [dependencies.sailfish-macros] path = "../sailfish-macros" -version = "0.3.2" +version = "0.3.3" optional = true [build-dependencies] From 6ea0ae2fad1d961b9495b3d50d1d0e1b0b30a219 Mon Sep 17 00:00:00 2001 From: Kogia-sima Date: Tue, 6 Apr 2021 21:53:58 +0900 Subject: [PATCH 7/7] Update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57bc6d8..7e93ae4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ + +## [v0.3.3](https://github.com/Kogia-sima/sailfish/compare/v0.3.2...v0.3.3) (2021-04-06) + +## Fix + +* Improve error message for missing semicolon in code blocks + ## [v0.3.2](https://github.com/Kogia-sima/sailfish/compare/v0.3.1...v0.3.2) (2021-03-29)