Skip to content

Use std::result::Result in derive macro to allow custom Result types#34

Merged
Kogia-sima merged 1 commit intorust-sailfish:masterfrom
Svenskunganka:master
Nov 22, 2020
Merged

Use std::result::Result in derive macro to allow custom Result types#34
Kogia-sima merged 1 commit intorust-sailfish:masterfrom
Svenskunganka:master

Conversation

@Svenskunganka
Copy link
Copy Markdown
Contributor

@Svenskunganka Svenskunganka commented Nov 21, 2020

When using a custom Result type, the TemplateOnce derive macro fails with error:

wrong number of type arguments: expected 1, found 2

A custom Result when you have a project-wide Error type:

type Result<T> = std::result::Result<T, Error>;

Allows to omit the E type from Result<T, E> in e.g function definitions: fn func() -> Result<String>

@Svenskunganka
Copy link
Copy Markdown
Contributor Author

Seems like tests fails due to using the newly released Rust 1.48.0, they pass with 1.47.0:

$ rustup override set 1.47.0
$ rm -rf ./target
$ cargo test --all-features -p sailfish -p sailfish-compiler -p integration-tests

   Compiling proc-macro2 v1.0.18
   Compiling unicode-xid v0.2.0
   Compiling syn v1.0.30
   Compiling winapi v0.3.8
   Compiling ryu v1.0.5
   Compiling version_check v0.9.2
   Compiling memchr v2.3.3
   Compiling sailfish-compiler v0.2.2 (C:\Users\tomjo\dev\rust\sailfish\sailfish-compiler)
   Compiling linked-hash-map v0.5.3
   Compiling serde v1.0.111                                                                                                                                                                                    
   Compiling itoap v0.1.0                                                                                                                                                                                      
   Compiling difference v2.0.0
   Compiling itoa v0.4.5
   Compiling glob v0.3.0
   Compiling lazy_static v1.4.0
   Compiling yaml-rust v0.4.4
   Compiling sailfish v0.2.2 (C:\Users\tomjo\dev\rust\sailfish\sailfish)
   Compiling quote v1.0.6
   Compiling home v0.5.3
   Compiling ansi_term v0.11.0
   Compiling output_vt100 v0.1.2
   Compiling winapi-util v0.1.5
   Compiling termcolor v1.1.0
   Compiling serde_derive v1.0.111
   Compiling ctor v0.1.14
   Compiling sailfish-macros v0.2.2 (C:\Users\tomjo\dev\rust\sailfish\sailfish-macros)
   Compiling integration-tests v0.2.2 (C:\Users\tomjo\dev\rust\sailfish\sailfish-tests\integration-tests)
   Compiling pretty_assertions v0.6.1
   Compiling toml v0.5.6
   Compiling serde_json v1.0.53
   Compiling trybuild v1.0.28
    Finished test [unoptimized + debuginfo] target(s) in 32.32s
     Running target\debug\deps\integration_tests-7a5969b57030e44f.exe

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target\debug\deps\compile-6e6439fd99ec780e.exe

running 1 test
   Compiling proc-macro2 v1.0.24
   Compiling winapi v0.3.9
   Compiling syn v1.0.48
   Compiling unicode-xid v0.2.1
   Compiling memchr v2.3.4
   Compiling sailfish-compiler v0.2.2 (C:\Users\tomjo\dev\rust\sailfish\sailfish-compiler)
   Compiling version_check v0.9.2
   Compiling ryu v1.0.5
   Compiling linked-hash-map v0.5.3                                                                                                                                                                            
    Checking itoap v0.1.0                                                                                                                                                                                      
    Checking difference v2.0.0                                                                                                                                                                                 
   Compiling yaml-rust v0.4.4                                                                                                                                                                                  
   Compiling sailfish v0.2.2 (C:\Users\tomjo\dev\rust\sailfish\sailfish)
    Checking quote v1.0.7
    Checking home v0.5.3
    Checking ansi_term v0.11.0
    Checking output_vt100 v0.1.2
   Compiling ctor v0.1.14
   Compiling sailfish-macros v0.2.2 (C:\Users\tomjo\dev\rust\sailfish\sailfish-macros)
    Checking pretty_assertions v0.6.1
    Checking integration-tests v0.2.2 (C:\Users\tomjo\dev\rust\sailfish\sailfish-tests\integration-tests)
    Checking integration-tests-tests v0.0.0 (C:\Users\tomjo\dev\rust\sailfish\target\tests\integration-tests)
    Finished dev [unoptimized + debuginfo] target(s) in 13.98s


test tests\fails\invalid_option_value.rs ... ok
test tests\fails\no_path.rs ... ok
test tests\fails\repeated_arguments.rs ... ok
test tests\fails\unbalanced_brace.rs ... ok
test tests\fails\unclosed_delimter.rs ... ok
test tests\fails\unexpected_token.rs ... ok
test tests\fails\unknown_option.rs ... ok


test compile_error ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target\debug\deps\config-7af08675b34b7568.exe

running 1 test
test read_config ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target\debug\deps\template_once-1064b23bd6ec3854.exe

running 12 tests
test empty ... ok
test test_comment ... ok
test test_filter ... ok
test json ... ok
test custom_delimiter ... ok
test noescape ... ok
test test_big_table ... ok
test test_formatting ... ok
test test_include ... ok
test test_rm_whitespace ... ok
test test_rust_macro ... ok
test test_teams ... ok

test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target\debug\deps\sailfish-608fc91ce2d08796.exe

running 14 tests
test runtime::buffer::tests::string_conversion ... ok
test runtime::escape::tests::escape_short ... ok
test runtime::buffer::tests::test1 ... ok
test runtime::buffer::tests::clone ... ok
test runtime::escape::tests::escape_long ... ok
test runtime::buffer::tests::test2 ... ok
test runtime::escape::tests::noescape ... ok
test runtime::filter::tests::case ... ok
test runtime::filter::tests::trim_test ... ok
test runtime::render::tests::deref_coercion ... ok
test runtime::render::tests::float ... ok
test runtime::render::tests::receiver_coercion ... ok
test runtime::escape::tests::random ... ok
test runtime::tests::render_error ... ok

test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target\debug\deps\sailfish_compiler-0044d96933111aa1.exe

running 4 tests
test parser::tests::non_ascii_delimiter ... ok
test parser::tests::comment_inside_block ... ok
test error::tests::display_error ... ok
test translator::tests::translate ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests sailfish

running 3 tests
test src\lib.rs - (line 13) ... ignored
test src\runtime\render.rs - runtime::render::Render (line 21) ... ok
test src\runtime\escape\mod.rs - runtime::escape::escape_to_string (line 88) ... ok

test result: ok. 2 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out

   Doc-tests integration-tests

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

@Kogia-sima
Copy link
Copy Markdown
Member

@Svenskunganka Thanks for the tips and all your works!

It seems CI failed because the Rustc has recently updated the error format (rust-lang/rust#73996). I've updated the tests so CI should work now.

@Kogia-sima Kogia-sima merged commit 4e94984 into rust-sailfish:master Nov 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants