seed-rs / seed

A Rust framework for creating web apps
MIT License
3.81k stars 155 forks source link

Cannot run examples with v0.8.0 #554

Closed matsbror closed 4 years ago

matsbror commented 4 years ago

I tried to run examples and the quickstart but gets build errors, all of the kind:

error[E0658]:matchis not allowed in aconst fn`

$ rustc -V rustc 1.45.0 (5c1f21c3b 2020-07-13) $ cargo make -V cargo-make 0.32.7

EDIT: Removing the const in the functions concerned resolves the issue. There seems to be work going on allowing const for function containing matches, but as far as I can see it's not released yet: https://github.com/rust-lang/rust/issues/49146

Also building examples from the seed repository doesn't work.

cargo make start counter

[cargo-make] INFO - cargo make 0.32.7 [cargo-make] INFO - Project: seed [cargo-make] INFO - Build File: Makefile.toml [cargo-make] INFO - Task: start [cargo-make] INFO - Profile: development [cargo-make] INFO - Execute Command: "cargo" "make" "--cwd" "./examples/counter" "start" [cargo-make][1] INFO - Project: counter [cargo-make][1] INFO - Build File: Makefile.toml [cargo-make][1] INFO - Task: start [cargo-make][1] INFO - Profile: development [cargo-make][1] INFO - Execute Command: "wasm-pack" "build" "--target" "web" "--out-name" "package" "--dev" [INFO]: Checking for the Wasm target... [INFO]: Compiling to Wasm... Compiling seed v0.8.0 (/home/mats/embe/seed) error[E0658]: match is not allowed in a const fn --> src/browser/fetch/method.rs:19:9 19 / match self { 20 Method::Get => "GET", 21 Method::Head => "HEAD", 22 Method::Post => "POST", ... 28 Method::Patch => "PATCH", 29 } _____^

= note: see issue #49146 https://github.com/rust-lang/rust/issues/49146 for more information

error[E0658]: match is not allowed in a const fn --> src/browser/fetch/status.rs:34:9 34 / matches!( 35 self.category, 36 StatusCategory::ClientError StatusCategory::ServerError 37 ) _____^

= note: see issue #49146 https://github.com/rust-lang/rust/issues/49146 for more information = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0658]: or-pattern is not allowed in a const fn --> src/browser/fetch/status.rs:34:9 34 / matches!( 35 self.category, 36 StatusCategory::ClientError StatusCategory::ServerError 37 ) _____^

= note: see issue #49146 https://github.com/rust-lang/rust/issues/49146 for more information = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0658]: match is not allowed in a const fn --> src/browser/service/fetch.rs:182:9 182 / matches!( 183 self.category, 184 StatusCategory::ClientError StatusCategory::ServerError 185 ) _____^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: or-pattern is not allowed in a const fn --> src/browser/service/fetch.rs:182:9 182 / matches!( 183 self.category, 184 StatusCategory::ClientError StatusCategory::ServerError 185 ) _____^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: match is not allowed in a const fn --> src/browser/service/fetch.rs:267:9 267 / match *self { 268 Method::Get => "GET", 269 Method::Head => "HEAD", 270 Method::Post => "POST", ... 276 Method::Patch => "PATCH", 277 } _____^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
error[E0658]: match is not allowed in a const fn --> src/virtual_dom/node.rs:147:9 147 matches!(self, Node::Text(_)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: match is not allowed in a const fn --> src/virtual_dom/node.rs:150:9 150 matches!(self, Node::Element(_)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: match is not allowed in a const fn --> src/virtual_dom/node.rs:153:9 153 matches!(self, Node::Empty) ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: if is not allowed in a const fn --> src/virtual_dom/node.rs:157:9 157 / if let Node::Text(t) = self { 158 Some(t) 159 } else { 160 None 161 } _____^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
error[E0658]: if is not allowed in a const fn --> src/virtual_dom/node.rs:164:9 164 / if let Node::Element(e) = self { 165 Some(e) 166 } else { 167 None 168 } _____^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
error[E0658]: match is not allowed in a const fn --> src/virtual_dom/node/el.rs:307:9 307 matches!(self.tag, Tag::Custom(_)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 12 previous errors

For more information about this error, try rustc --explain E0658. error: could not compile seed.

To learn more, run the command again with --verbose. Error: Compiling your crate to WebAssembly failed Caused by: failed to execute cargo build: exited with exit code: 101 full command: "cargo" "build" "--lib" "--target" "wasm32-unknown-unknown" [cargo-make][1] ERROR - Error while executing command, exit code: 1 [cargo-make][1] WARN - Build Failed. [cargo-make] ERROR - Error while executing command, exit code: 1 [cargo-make] WARN - Build Failed.

mats@DESKTOP-SET4FKI ~/embe/seed (master) $ less errors.log

mats@DESKTOP-SET4FKI ~/embe/seed (master) $ emacs errors.log

mats@DESKTOP-SET4FKI ~/embe/seed (master) $ cat

mats@DESKTOP-SET4FKI ~/embe/seed (master) $ cat errors.log [cargo-make] INFO - cargo make 0.32.7 [cargo-make] INFO - Project: seed [cargo-make] INFO - Build File: Makefile.toml [cargo-make] INFO - Task: start [cargo-make] INFO - Profile: development [cargo-make] INFO - Execute Command: "cargo" "make" "--cwd" "./examples/counter" "start" [cargo-make][1] INFO - Project: counter [cargo-make][1] INFO - Build File: Makefile.toml [cargo-make][1] INFO - Task: start [cargo-make][1] INFO - Profile: development [cargo-make][1] INFO - Execute Command: "wasm-pack" "build" "--target" "web" "--out-name" "package" "--dev" [INFO]: Checking for the Wasm target... [INFO]: Compiling to Wasm... Compiling seed v0.8.0 (/home/mats/embe/seed) error[E0658]: match is not allowed in a const fn --> src/browser/fetch/method.rs:19:9 19 / match self { 20 Method::Get => "GET", 21 Method::Head => "HEAD", 22 Method::Post => "POST", ... 28 Method::Patch => "PATCH", 29 } _____^

= note: see issue #49146 https://github.com/rust-lang/rust/issues/49146 for more information

error[E0658]: match is not allowed in a const fn --> src/browser/fetch/status.rs:34:9 34 / matches!( 35 self.category, 36 StatusCategory::ClientError StatusCategory::ServerError 37 ) _____^

= note: see issue #49146 https://github.com/rust-lang/rust/issues/49146 for more information = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0658]: or-pattern is not allowed in a const fn --> src/browser/fetch/status.rs:34:9 34 / matches!( 35 self.category, 36 StatusCategory::ClientError StatusCategory::ServerError 37 ) _____^

= note: see issue #49146 https://github.com/rust-lang/rust/issues/49146 for more information = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0658]: match is not allowed in a const fn --> src/browser/service/fetch.rs:182:9 182 / matches!( 183 self.category, 184 StatusCategory::ClientError StatusCategory::ServerError 185 ) _____^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: or-pattern is not allowed in a const fn --> src/browser/service/fetch.rs:182:9 182 / matches!( 183 self.category, 184 StatusCategory::ClientError StatusCategory::ServerError 185 ) _____^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: match is not allowed in a const fn --> src/browser/service/fetch.rs:267:9 267 / match *self { 268 Method::Get => "GET", 269 Method::Head => "HEAD", 270 Method::Post => "POST", ... 276 Method::Patch => "PATCH", 277 } _____^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
error[E0658]: match is not allowed in a const fn --> src/virtual_dom/node.rs:147:9 147 matches!(self, Node::Text(_)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: match is not allowed in a const fn --> src/virtual_dom/node.rs:150:9 150 matches!(self, Node::Element(_)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: match is not allowed in a const fn --> src/virtual_dom/node.rs:153:9 153 matches!(self, Node::Empty) ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: if is not allowed in a const fn --> src/virtual_dom/node.rs:157:9 157 / if let Node::Text(t) = self { 158 Some(t) 159 } else { 160 None 161 } _____^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
error[E0658]: if is not allowed in a const fn --> src/virtual_dom/node.rs:164:9 164 / if let Node::Element(e) = self { 165 Some(e) 166 } else { 167 None 168 } _____^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
error[E0658]: match is not allowed in a const fn --> src/virtual_dom/node/el.rs:307:9 307 matches!(self.tag, Tag::Custom(_)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 12 previous errors

For more information about this error, try rustc --explain E0658. error: could not compile seed.

To learn more, run the command again with --verbose. Error: Compiling your crate to WebAssembly failed Caused by: failed to execute cargo build: exited with exit code: 101 full command: "cargo" "build" "--lib" "--target" "wasm32-unknown-unknown" [cargo-make][1] ERROR - Error while executing command, exit code: 1 [cargo-make][1] WARN - Build Failed. [cargo-make] ERROR - Error while executing command, exit code: 1 [cargo-make] WARN - Build Failed.

MartinKavik commented 4 years ago

hi @matsbror, thanks for the issue/question.

It looks like you have old Rust version, the newer one has been recently released (https://blog.rust-lang.org/2020/10/08/Rust-1.47.html). Please run rustup update, try again and eventually close the issue. I can't reproduce it and it wouldn't pass through CI tests with compilation errors.

matsbror commented 4 years ago

Great , that was indeed the issue.