maciejhirsz / kobold

Easy declarative web interfaces.
https://docs.rs/kobold/
Mozilla Public License 2.0
388 stars 7 forks source link

error[E0658]: use of unstable library feature 'toowned_clone_into': recently added #23

Closed ltfschoen closed 1 year ago

ltfschoen commented 1 year ago

I tried to create a project based on the Kobold dependency kobold = "0.4.1" in this repository https://github.com/ltfschoen/kobold-test I've added the steps I took in the README file. But when I do the trunk serve step I get the following errors whether I use the latest stable or nightly nightly-2022-03-22-x86_64-apple-darwin or nightly-2021-03-10-x86_64-unknown-linux-gnu. I've tried on both macOS and Ubuntu.

nightly errors ``` luke @ ~/code/github/ltfschoen/kobold-test - [master] $ rustup default nightly-2022-03-22-x86_64-apple-darwin info: using existing install for 'nightly-2022-03-22-x86_64-apple-darwin' info: default toolchain set to 'nightly-2022-03-22-x86_64-apple-darwin' nightly-2022-03-22-x86_64-apple-darwin unchanged - rustc 1.61.0-nightly (3c17c84a3 2022-03-21) luke @ ~/code/github/ltfschoen/kobold-test - [master] $ trunk serve 2023-03-17T01:07:01.587923Z INFO 📦 starting build 2023-03-17T01:07:01.589003Z INFO spawning asset pipelines 2023-03-17T01:07:02.881202Z INFO building kobold-test Compiling proc-macro2 v1.0.52 Compiling unicode-ident v1.0.8 Compiling quote v1.0.26 Compiling syn v1.0.109 Compiling log v0.4.17 Compiling wasm-bindgen-shared v0.2.84 Compiling cfg-if v1.0.0 Compiling bumpalo v3.12.0 Compiling once_cell v1.17.1 Compiling wasm-bindgen v0.2.84 Compiling arrayvec v0.7.2 Compiling fnv v1.0.7 Compiling beef v0.5.2 Compiling itoa v1.0.6 Compiling ryu v1.0.13 Compiling kobold_macros v0.4.1 Compiling wasm-bindgen-backend v0.2.84 Compiling wasm-bindgen-macro-support v0.2.84 Compiling wasm-bindgen-macro v0.2.84 Compiling js-sys v0.3.61 Compiling console_error_panic_hook v0.1.7 Compiling web-sys v0.3.61 Compiling kobold v0.4.1 Compiling kobold-test v0.1.0 (/Users/luke/code/github/ltfschoen/kobold-test) error[E0432]: unresolved import `kobold::prelude::component` --> src/main.rs:1:23 | 1 | use kobold::prelude::{component, html, Html}; | ^^^^^^^^^ no `component` in `prelude` error: cannot determine resolution for the attribute macro `wasm_bindgen::prelude::wasm_bindgen` --> src/main.rs:5:5 | 5 | / html! { 6 | |

"Hello "{ name }"!"

7 | | } | |_____^ | = note: import resolution is stuck, try simplifying macro imports = note: this error originates in the macro `html` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot determine resolution for the attribute macro `component` --> src/main.rs:3:3 | 3 | #[component] | ^^^^^^^^^ | = note: import resolution is stuck, try simplifying macro imports error[E0574]: expected struct, variant or union type, found function `Hello` --> src/main.rs:12:10 | 12 | | ^^^^^ not a struct, variant or union type error[E0759]: `name` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> src/main.rs:6:23 | 4 | fn Hello(name: &str) -> impl Html + '_ { | ---- this data with an anonymous lifetime `'_`... 5 | html! { 6 |

"Hello "{ name }"!"

| ^^^^ ...is used here... | note: ...and is required to live as long as `'static` here --> src/main.rs:4:25 | 4 | fn Hello(name: &str) -> impl Html + '_ { | ^^^^^^^^^^^^^^ Some errors have detailed explanations: E0432, E0574, E0759. For more information about an error, try `rustc --explain E0432`. error: could not compile `kobold-test` due to 5 previous errors 2023-03-17T01:07:50.267241Z ERROR ❌ error error from HTML pipeline Caused by: 0: error from asset pipeline 1: error during cargo build execution 2: cargo call returned a bad status 2023-03-17T01:07:50.268910Z INFO 📡 serving static assets at -> / 2023-03-17T01:07:50.269144Z INFO 📡 server listening at http://127.0.0.1:8080 ```

I think that's because the code I'm using is directly from the latest 'master' branch at https://github.com/maciejhirsz/kobold, which is version kobold = "0.5.0", so it's not compatible with the older version 0.4.0.

But I actually want to develop based on the latest commit in https://github.com/maciejhirsz/kobold.

So I tried switching to nightly and installing the latest commit in the 'master' branch of https://github.com/maciejhirsz/kobold

rustup default nightly-2022-03-22
cargo install --bins --examples --git=https://github.com/maciejhirsz/kobold --branch=master --rev=7fd98d2aec28c06b031efcae2e31405ca0683c9e

But even though i specified --bins to install all binaries, it still gave error:

cargo install --bins --examples --git=https://github.com/maciejhirsz/kobold --branch=master --rev=7fd98d2aec28c06b031efcae2e31405ca0683c9e
info: syncing channel updates for 'nightly-2022-03-22-x86_64-apple-darwin'
info: latest update on 2022-03-22, rust version 1.61.0-nightly (3c17c84a3 2022-03-21)
...
    Updating git repository `https://github.com/maciejhirsz/kobold`
error: multiple packages with binaries found: kobold_counter_example, kobold_csv_editor_example, kobold_hello_world_example, kobold_interval_example, kobold_list_example, kobold_qrcode_example, kobold_stateful_example, kobold_todomvc_example. When installing a git repository, cargo will always search the entire repo for any Cargo.toml. Please specify which to install.

So I removed Cargo.lock, and removed the kobold = 0.4.1 dependency from Cargo.toml, and updated cargo cargo update, then I tried specifying all the packages at the end of the command so it wouldn't error:

cargo install --bins --examples --git=https://github.com/maciejhirsz/kobold --branch=master --rev=7fd98d2aec28c06b031efcae2e31405ca0683c9e kobold_counter_example kobold_csv_editor_example kobold_hello_world_example kobold_interval_example kobold_list_example kobold_qrcode_example kobold_stateful_example kobold_todomvc_example --verbose

But that output the following for each of the packages:

error[E0658]: use of unstable library feature 'toowned_clone_into': recently added
   --> crates/kobold/src/value.rs:191:18
    |
191 |             self.clone_into(&mut p.value);
    |                  ^^^^^^^^^^
    |
    = note: see issue #41263 <https://github.com/rust-lang/rust/issues/41263> for more information
    = help: add `#![feature(toowned_clone_into)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'toowned_clone_into': recently added
   --> crates/kobold/src/value.rs:218:18
    |
218 |             self.clone_into(state);
    |                  ^^^^^^^^^^
    |
    = note: see issue #41263 <https://github.com/rust-lang/rust/issues/41263> for more information
    = help: add `#![feature(toowned_clone_into)]` to the crate attributes to enable

For more information about this error, try `rustc --explain E0658`.
error: could not compile `kobold` due to 2 previous errors

So I switched to stable rustup default stable, and tried again:

cargo install --bins --examples --git=https://github.com/maciejhirsz/kobold --branch=master --rev=7fd98d2aec28c06b031efcae2e31405ca0683c9e kobold_counter_example kobold_csv_editor_example kobold_hello_world_example kobold_interval_example kobold_list_example kobold_qrcode_example kobold_stateful_example kobold_todomvc_example --verbose

but that gave the same errors. So I made those changes (adding #![feature(toowned_clone_into)] above every clone_into in the codebase) in my fork https://github.com/ltfschoen/kobold 'master' branch commit '2617dc3e4cff227d68e8a7ae883d8aa7cec6de6f', and then ran:

cargo install --bins --examples --git=https://github.com/ltfschoen/kobold --branch=master --rev=2617dc3e4cff227d68e8a7ae883d8aa7cec6de6f kobold_counter_example kobold_csv_editor_example kobold_hello_world_example kobold_interval_example kobold_list_example kobold_qrcode_example kobold_stateful_example kobold_todomvc_example --verbose

And that finally compiled successfully.

But when I ran trunk serve it still gave errors

       error: failed to select a version for the requirement `kobold_macros = "^0.5.0"`
       candidate versions found which didn't match: 0.4.1, 0.4.0, 0.3.0, ...
       location searched: crates.io index
       required by package `kobold v0.5.0 (https://github.com/ltfschoen/kobold.git?rev=7fd98d2aec28c06b031efcae2e31405ca0683c9e#7fd98d2a)`

Then it occurred to me after reading https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#multiple-locations, that the dependencies weren't right in the Cargo.toml files, as they were referring to crates.io when version 0.5.0 hadn't been published yet, but those docs say that you can specify the path so you can still use the Github repo for local development if it isn't publlished yet at crates.io for the version you specify.

So I updated all the Cargo.toml files in this commit https://github.com/ltfschoen/kobold.git, d56e8f69d7678040c63d57e93f78d4c3aa35656d

and also updated the Cargo.toml file for my project at https://github.com/ltfschoen/kobold-test so it uses the changes in my fork:

[dependencies]
kobold = { version = "0.5.0", git = "https://github.com/ltfschoen/kobold.git", rev = "d56e8f69d7678040c63d57e93f78d4c3aa35656d" }
kobold_macros = { version = "0.5.0", git = "https://github.com/ltfschoen/kobold.git", rev = "d56e8f69d7678040c63d57e93f78d4c3aa35656d" }
kobold_qr = { version = "0.5.0", git = "https://github.com/ltfschoen/kobold.git", rev = "d56e8f69d7678040c63d57e93f78d4c3aa35656d" }

And finally it worked without errors when i ran trunk serve

maciejhirsz commented 1 year ago

For posterity's sake since the code comment in the PR is hidden: this is a stable feature since Rust 1.63.