Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unpin wasm-bindgen version #185

Merged
merged 5 commits into from
Nov 6, 2024

Conversation

jheuel
Copy link
Contributor

@jheuel jheuel commented Nov 5, 2024

Unpin wasm-bingen to be compatible with leptos-0.7.0-rc1. See leptos-rs/leptos#3186.

Fixes #176

@jheuel jheuel closed this Nov 5, 2024
@maccesch
Copy link
Contributor

maccesch commented Nov 5, 2024

This looks promising, thanks! Did you close it on purpose?

@maccesch maccesch reopened this Nov 5, 2024
@jheuel
Copy link
Contributor Author

jheuel commented Nov 5, 2024

Yes, I ran the tests and was a bit overwhelmed. 😃
The warnings are easy to fix but there were some errors in headers.rs that I could not understand without more context.

@SleeplessOne1917
Copy link
Contributor

In the tests, this appearead to be the only error:

error: cannot find macro `warn` in this scope
   --> src/use_cookie.rs:538:25
    |
538 | ...   warn!("If you're using use_cookie without the feature `axum`, `actix` or `spin` enabled, you should provide the option `ssr_set_coo...
    |       ^^^^
    |
    = note: `warn` is in scope, but it is an attribute: `#[warn]`
help: consider importing this macro
    |
3   + use leptos::logging::warn;
    |

You should just need to add an import for warn alongside debug_warn and error in use_cookie.rs. All the other messages in that log are just warnings.

The CI check seems to be failing due to cargo fmt --check. I think just running cargo fmt on your code should fix the issue.

@jheuel
Copy link
Contributor Author

jheuel commented Nov 6, 2024

You should just need to add an import for warn alongside debug_warn and error in use_cookie.rs. All the other messages in that log are just warnings.

Like I said the warnings are not the problem but cargo test --all-features gives me:

error[E0428]: the name `HeaderValue` is defined multiple timesest), leptos-use                                                           
  --> src/utils/header.rs:38:5
   |
36 |     type HeaderValue = http0_2::HeaderValue;
   |     ---------------------------------------- previous definition of the type `HeaderValue` here
37 |     #[cfg(feature = "axum")]
38 |     type HeaderValue = http1::HeaderValue;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `HeaderValue` redefined here
   |
   = note: `HeaderValue` must be defined only once in the type namespace of this block

error[E0428]: the name `SET_COOKIE` is defined multiple times
   --> src/use_cookie.rs:527:21
    |
525 |                     const SET_COOKIE: http0_2::HeaderName = http0_2::header::SET_COOKIE;
    |                     -------------------------------------------------------------------- previous definition of the value `SET_COOKIE` here
526 |                     #[cfg(any(feature = "axum", feature = "spin"))]
527 |                     const SET_COOKIE: http1::HeaderName = http1::header::SET_COOKIE;
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SET_COOKIE` redefined here
    |
    = note: `SET_COOKIE` must be defined only once in the value namespace of this block

error[E0428]: the name `HeaderValue` is defined multiple times
   --> src/use_cookie.rs:532:21
    |
530 |                     type HeaderValue = http0_2::HeaderValue;
    |                     ---------------------------------------- previous definition of the type `HeaderValue` here
531 |                     #[cfg(any(feature = "axum", feature = "spin"))]
532 |                     type HeaderValue = http1::HeaderValue;
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `HeaderValue` redefined here
    |
    = note: `HeaderValue` must be defined only once in the type namespace of this block

error[E0252]: the name `HeaderName` is defined multiple times
 --> src/utils/header.rs:4:5
  |
2 | use http0_2::HeaderName;
  |     ------------------- previous import of the type `HeaderName` here
3 | #[cfg(any(feature = "axum", feature = "spin"))]
4 | use http1::HeaderName;
  |     ^^^^^^^^^^^^^^^^^ `HeaderName` reimported here
  |
  = note: `HeaderName` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
  |
4 | use http1::HeaderName as OtherHeaderName;
  |                       ++++++++++++++++++

error[E0252]: the name `ResponseOptions` is defined multiple times
   --> src/use_cookie.rs:520:25
    |
518 |                     use leptos_actix::ResponseOptions;
    |                         ----------------------------- previous import of the type `ResponseOptions` here
519 |                     #[cfg(feature = "axum")]
520 |                     use leptos_axum::ResponseOptions;
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ResponseOptions` reimported here
    |
    = note: `ResponseOptions` must be defined only once in the type namespace of this block
help: you can use `as` to change the binding name of the import
    |
520 |                     use leptos_axum::ResponseOptions as OtherResponseOptions;
    |                                                      +++++++++++++++++++++++

error[E0252]: the name `ResponseOptions` is defined multiple times
   --> src/use_cookie.rs:522:25
    |
518 |                     use leptos_actix::ResponseOptions;
    |                         ----------------------------- previous import of the type `ResponseOptions` here
...
522 |                     use leptos_spin::ResponseOptions;
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ResponseOptions` reimported here
    |
    = note: `ResponseOptions` must be defined only once in the type namespace of this block
help: you can use `as` to change the binding name of the import
    |
522 |                     use leptos_spin::ResponseOptions as OtherResponseOptions;
    |                                                      +++++++++++++++++++++++

error: You can only enable one of features "actix" and "axum" at the same time
  --> src/utils/header.rs:27:5
   |
27 |     compile_error!("You can only enable one of features \"actix\" and \"axum\" at the same time");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: You can only enable one of features "actix" and "spin" at the same time
  --> src/utils/header.rs:30:5
   |
30 |     compile_error!("You can only enable one of features \"actix\" and \"spin\" at the same time");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: You can only enable one of features "axum" and "spin" at the same time
  --> src/utils/header.rs:33:5
   |
33 |     compile_error!("You can only enable one of features \"axum\" and \"spin\" at the same time");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0252]: the name `HeaderName` is defined multiple times
   --> src/utils/header_macro.rs:30:25
    |
27  |               use http0_2::{HeaderName, header::*};
    |                             ---------- previous import of the type `HeaderName` here
...
30  |               use http1::{HeaderName, header::*};
    |                           ^^^^^^^^^^ `HeaderName` reimported here
    |
   ::: src/use_color_mode.rs:528:17
    |
528 | /                 get_header!(
529 | |                     HeaderName::from_static("sec-ch-prefers-color-scheme"),
530 | |                     use_locale,
531 | |                     ssr_color_header_getter
532 | |                 )
    | |_________________- in this macro invocation
    |
    = note: `HeaderName` must be defined only once in the type namespace of this block
    = note: this error originates in the macro `get_header` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you can use `as` to change the binding name of the import
    |
30  |             use http1::{HeaderName as OtherHeaderName, header::*};
    |                                    ++++++++++++++++++

error[E0252]: the name `HeaderName` is defined multiple times
   --> src/utils/header_macro.rs:30:25
    |
27  |             use http0_2::{HeaderName, header::*};
    |                           ---------- previous import of the type `HeaderName` here
...
30  |             use http1::{HeaderName, header::*};
    |                         ^^^^^^^^^^ `HeaderName` reimported here
    |
   ::: src/use_cookie.rs:512:17
    |
512 |                 get_header!(COOKIE, use_cookie, ssr_cookies_header_getter)
    |                 ---------------------------------------------------------- in this macro invocation
    |
    = note: `HeaderName` must be defined only once in the type namespace of this block
    = note: this error originates in the macro `get_header` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you can use `as` to change the binding name of the import
    |
30  |             use http1::{HeaderName as OtherHeaderName, header::*};
    |                                    ++++++++++++++++++

error[E0252]: the name `HeaderName` is defined multiple times
   --> src/utils/header_macro.rs:30:25
    |
27  |             use http0_2::{HeaderName, header::*};
    |                           ---------- previous import of the type `HeaderName` here
...
30  |             use http1::{HeaderName, header::*};
    |                         ^^^^^^^^^^ `HeaderName` reimported here
    |
   ::: src/use_locales.rs:111:17
    |
111 |                 get_header!(ACCEPT_LANGUAGE, use_locale, ssr_lang_header_getter)
    |                 ---------------------------------------------------------------- in this macro invocation
    |
    = note: `HeaderName` must be defined only once in the type namespace of this block
    = note: this error originates in the macro `get_header` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you can use `as` to change the binding name of the import
    |
30  |             use http1::{HeaderName as OtherHeaderName, header::*};
    |                                    ++++++++++++++++++

error[E0252]: the name `HeaderName` is defined multiple times
  --> src/utils/header_macro.rs:30:25
   |
27 |               use http0_2::{HeaderName, header::*};
   |                             ---------- previous import of the type `HeaderName` here
...
30 |               use http1::{HeaderName, header::*};
   |                           ^^^^^^^^^^ `HeaderName` reimported here
   |
  ::: src/use_preferred_dark.rs:80:17
   |
80 | /                 get_header!(
81 | |                     HeaderName::from_static("sec-ch-prefers-color-scheme"),
82 | |                     use_locale,
83 | |                     ssr_color_header_getter
84 | |                 )
   | |_________________- in this macro invocation
   |
   = note: `HeaderName` must be defined only once in the type namespace of this block
   = note: this error originates in the macro `get_header` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you can use `as` to change the binding name of the import
   |
30 |             use http1::{HeaderName as OtherHeaderName, header::*};
   |                                    ++++++++++++++++++

error[E0252]: the name `HeaderName` is defined multiple times
  --> src/utils/header_macro.rs:30:25
   |
27 |               use http0_2::{HeaderName, header::*};
   |                             ---------- previous import of the type `HeaderName` here
...
30 |               use http1::{HeaderName, header::*};
   |                           ^^^^^^^^^^ `HeaderName` reimported here
   |
  ::: src/use_prefers_reduced_motion.rs:95:17
   |
95 | /                 get_header!(
96 | |                     HeaderName::from_static("sec-ch-prefers-reduced-motion"),
97 | |                     use_locale,
98 | |                     ssr_motion_header_getter
99 | |                 )
   | |_________________- in this macro invocation
   |
   = note: `HeaderName` must be defined only once in the type namespace of this block
   = note: this error originates in the macro `get_header` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you can use `as` to change the binding name of the import
   |
30 |             use http1::{HeaderName as OtherHeaderName, header::*};
   |                                    ++++++++++++++++++

error[E0659]: `COOKIE` is ambiguous
   --> src/use_cookie.rs:512:29
    |
512 |                 get_header!(COOKIE, use_cookie, ssr_cookies_header_getter)
    |                             ^^^^^^ ambiguous name
    |
    = note: ambiguous because of multiple glob imports of a name in the same module
note: `COOKIE` could refer to the constant imported here
   --> src/utils/header_macro.rs:27:39
    |
27  |             use http0_2::{HeaderName, header::*};
    |                                       ^^^^^^^^^
    |
   ::: src/use_cookie.rs:512:17
    |
512 |                 get_header!(COOKIE, use_cookie, ssr_cookies_header_getter)
    |                 ---------------------------------------------------------- in this macro invocation
    = help: consider adding an explicit import of `COOKIE` to disambiguate
note: `COOKIE` could also refer to the constant imported here
   --> src/utils/header_macro.rs:30:37
    |
30  |             use http1::{HeaderName, header::*};
    |                                     ^^^^^^^^^
    |
   ::: src/use_cookie.rs:512:17
    |
512 |                 get_header!(COOKIE, use_cookie, ssr_cookies_header_getter)
    |                 ---------------------------------------------------------- in this macro invocation
    = help: consider adding an explicit import of `COOKIE` to disambiguate
    = note: this error originates in the macro `get_header` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0659]: `ACCEPT_LANGUAGE` is ambiguous
   --> src/use_locales.rs:111:29
    |
111 |                 get_header!(ACCEPT_LANGUAGE, use_locale, ssr_lang_header_getter)
    |                             ^^^^^^^^^^^^^^^ ambiguous name
    |
    = note: ambiguous because of multiple glob imports of a name in the same module
note: `ACCEPT_LANGUAGE` could refer to the constant imported here
   --> src/utils/header_macro.rs:27:39
    |
27  |             use http0_2::{HeaderName, header::*};
    |                                       ^^^^^^^^^
    |
   ::: src/use_locales.rs:111:17
    |
111 |                 get_header!(ACCEPT_LANGUAGE, use_locale, ssr_lang_header_getter)
    |                 ---------------------------------------------------------------- in this macro invocation
    = help: consider adding an explicit import of `ACCEPT_LANGUAGE` to disambiguate
note: `ACCEPT_LANGUAGE` could also refer to the constant imported here
   --> src/utils/header_macro.rs:30:37
    |
30  |             use http1::{HeaderName, header::*};
    |                                     ^^^^^^^^^
    |
   ::: src/use_locales.rs:111:17
    |
111 |                 get_header!(ACCEPT_LANGUAGE, use_locale, ssr_lang_header_getter)
    |                 ---------------------------------------------------------------- in this macro invocation
    = help: consider adding an explicit import of `ACCEPT_LANGUAGE` to disambiguate
    = note: this error originates in the macro `get_header` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
  --> src/utils/header.rs:49:19
   |
41 |     let headers;
   |         ------- expected due to the type of this binding
...
49 |         headers = use_context::<http1::request::Parts>().map(|parts| parts.headers);
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `HeaderMap`, found `http::HeaderMap`
   |
   = note: `http::HeaderMap` and `HeaderMap` have similar names, but are actually distinct types
note: `http::HeaderMap` is defined in crate `http`
  --> /home/jheuel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/http-1.1.0/src/header/map.rs:45:1
   |
45 | pub struct HeaderMap<T = HeaderValue> {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `HeaderMap` is defined in crate `actix_http`
  --> /home/jheuel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-http-3.9.0/src/header/map.rs:49:1
   |
49 | pub struct HeaderMap {
   | ^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
  --> src/utils/header.rs:53:19
   |
41 |     let headers;
   |         ------- expected due to the type of this binding
...
53 |         headers = use_context::<leptos_spin::RequestParts>().map(|parts| parts.headers().clone());
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<HeaderMap>`, found `Option<Vec<(String, Vec<u8>)>>`
   |
   = note: expected enum `std::option::Option<leptos::server_fn::actix_web::http::header::HeaderMap>`
              found enum `std::option::Option<Vec<(std::string::String, Vec<u8>)>>`

error[E0308]: mismatched types
  --> src/utils/header.rs:58:9
   |
58 | /         headers.map(|headers| {
59 | |             headers
60 | |                 .get(name)
61 | |                 .cloned()
...  |
65 | |                 .to_owned()
66 | |         })
   | |__________^ expected `()`, found `Option<String>`
   |
   = note: expected unit type `()`
                   found enum `std::option::Option<std::string::String>`
help: consider using a semicolon here
   |
66 |         });
   |           +
help: you might have meant to return this value
   |
58 ~         return headers.map(|headers| {
59 |             headers
...
65 |                 .to_owned()
66 ~         });
   |

error[E0599]: no method named `to_vec` found for reference `&http::HeaderValue` in the current scope
  --> src/utils/header.rs:74:64
   |
74 |                 .and_then(|(_, value)| String::from_utf8(value.to_vec()).ok())
   |                                                                ^^^^^^ method not found in `&HeaderValue`

error[E0308]: arguments to this method are incorrect
   --> src/use_cookie.rs:558:46
    |
558 | ...                   response_options.append_header(SET_COOKIE.as_str(), &header_value);
    |                                        ^^^^^^^^^^^^^ ------------------- expected `HeaderName`, found `&str`
    |
note: expected `HeaderValue`, found `&Vec<u8>`
   --> src/use_cookie.rs:558:81
    |
558 | ...                   response_options.append_header(SET_COOKIE.as_str(), &header_value);
    |                                                                           ^^^^^^^^^^^^^
    = note: expected struct `http::HeaderValue`
            found reference `&Vec<u8>`
note: method defined here
   --> /home/jheuel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_actix-0.7.0-rc1/src/lib.rs:139:12
    |
139 |     pub fn append_header(
    |            ^^^^^^^^^^^^^
help: try removing the method call
    |
558 -                             response_options.append_header(SET_COOKIE.as_str(), &header_value);
558 +                             response_options.append_header(SET_COOKIE, &header_value);
    |

Is that failing because it enables exclusive features together? Like axum and actix?

@SleeplessOne1917
Copy link
Contributor

Like I said the warnings are not the problem but cargo test --all-features gives me:

Fortunately, none of the tests run as part of CI use all features. Reproducing lines here:

      - name: Run tests (general)
        run: cargo test --features math,docs,ssr

      - name: Run tests (axum) use_cookie
        run: cargo test --features math,docs,ssr,axum --doc use_cookie

      - name: Run tests (axum) use_locale
        run: cargo test --features math,docs,ssr,axum --doc use_locale

      - name: Run tests (actix) use_cookie
        run: cargo test --features math,docs,ssr,actix --doc use_cookie

      - name: Run tests (actix) use_locale
        run: cargo test --features math,docs,ssr,actix --doc use_locale

Is that failing because it enables exclusive features together? Like axum and actix?

That's my guess. The CI tests those both separately, so I think it only really needs to pass for the cargo test calls run as steps to get the build working. That and running cargo fmt on the rust files modified as part of this PR.

@maccesch
Copy link
Contributor

maccesch commented Nov 6, 2024

@SleeplessOne1917 Is correct. It can't work with all features enabled because that would run client and server code at the same time.

@@ -12,7 +12,7 @@ macro_rules! use_derive_signal {
pub fn $name<V $(, $( $type_param ),* )? >(value: V) -> Signal<$return_type>
where
$inner_signal_type $(< $( $inner_type_param ),+ >)?: Send + Sync,
V: Into<Signal<$inner_signal_type $(< $( $inner_type_param ),+ >)?>> $(, $( $type_param $( : $first_bound $(+ $rest_bound)* )? ),+ )?
V: Into<ReadSignal<$inner_signal_type $(< $( $inner_type_param ),+ >)?>> $(, $( $type_param $( : $first_bound $(+ $rest_bound)* )? ),+ )?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this one. Is this type constraint too tight? Should not be allowed to write to signals in derives, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this should definitely stay Signal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I'll add type annotations in the example.

@jheuel
Copy link
Contributor Author

jheuel commented Nov 6, 2024

The remaining warnings are the deprecation hints that #187 fixes.

@jheuel jheuel force-pushed the unpin_wasm-bindgen_version branch from 5665a17 to 1bcda56 Compare November 6, 2024 18:04
@maccesch maccesch merged commit 5d76e4f into Synphonyte:main Nov 6, 2024
2 of 4 checks passed
@maccesch
Copy link
Contributor

maccesch commented Nov 6, 2024

Thanks!

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.

wasm-bindgen version conflict...
3 participants