diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 0b9ab3afb68..15df23446cc 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -25,7 +25,7 @@ If applicable, add screenshots to help explain your problem. **Environment:** - Yew version [e.g. v0.10, `master`] - - Rust version [e.g. 1.40.0] + - Rust version [e.g. 1.41.0] - Target if relevant [e.g. `wasm32-unknown-emscripten`] - `stdweb` / `web-sys` version [e.g. web-sys v0.3.33] - OS: [e.g. macos] diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 00000000000..d9c5a4d579a --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,2 @@ +report_todo = "Unnumbered" +report_fixme = "Unnumbered" diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e35085604d..3c5bb96852f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,29 @@ # Changelog +## ✨ **0.12** *(2020-02-16)* + +- #### ⚡️ Features + + - Improved ergonomics for `html! { for .. }`. [[@jstarry], [#875](https://github.com/yewstack/yew/pull/875)] + - Added `#[props(default = "fn_path")]` for specifying a default property value. [[@AlephAlpha], [#881](https://github.com/yewstack/yew/pull/881)] + - Exposed the macros for creating format types. [[@ctm], [#883](https://github.com/yewstack/yew/pull/883)] + - Added support for binary-only and text-only formats in `WebSocketService`. [[@ctm], [#851](https://github.com/yewstack/yew/pull/851)] + - Implemented `PartialEq` for `ChildrenRenderer` to allow `children` comparison. [[@jstarry], [#916](https://github.com/yewstack/yew/pull/916)] + - Reduced restrictions on `ComponentLink` methods to improve `Future` support. [[@jplatte], [#931](https://github.com/yewstack/yew/pull/931)] + - Added `referrer`, `referrer_policy` and `integrity` to `FetchOptions`. [[@leo-lb], [#931](https://github.com/yewstack/yew/pull/931)] + +- #### 🛠 Fixes + + - Fixed touch event listeners. [[@AlephAlpha], [#872](https://github.com/yewstack/yew/pull/872)] + - Fixed bad behavior when setting a `ref` on a `Component`. [[@jstarry], [#913](https://github.com/yewstack/yew/pull/913)] + - Fixed ResizeTask cancellation. [[@jstarry], [#915](https://github.com/yewstack/yew/pull/915)] + +- #### 🚨 Breaking changes + + - Switched from using `failure` to `anyhow` and `thiserror` for Yew errors. [[@daxpedda], [#863](https://github.com/yewstack/yew/pull/863)] + - Removed `cancel` method from `Task` trait in favor of relying on [`Drop`](https://doc.rust-lang.org/book/ch15-03-drop.html). [[@kakoc], [#899](https://github.com/yewstack/yew/pull/899)] + - Renamed `NodeRef.try_into` to `NodeRef.cast` to avoid trait conflicts. [[@jstarry], [#917](https://github.com/yewstack/yew/pull/917)] + ## ✨ **0.11** *(2020-01-06)* This release aims to lay the groundwork for Yew component libraries and clean up the API for the ever elusive 1.0 release. @@ -638,19 +662,25 @@ This release introduces the concept of an `Agent`. Agents are separate activitie ## ✨ **0.1** *(2017-12-31)* [Web Workers API]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API +[@AlephAlpha]: https://github.com/AlephAlpha [@astraw]: https://github.com/astraw [@boydjohnson]: https://github.com/boydjohnson [@carlosdp]: https://github.com/carlosdp [@charvp]: https://github.com/charvp [@ctaggart]: https://github.com/ctaggart +[@ctm]: https://github.com/ctm +[@daxpedda]: https://github.com/daxpedda [@davidkna]: https://github.com/davidkna [@DenisKolodin]: https://github.com/DenisKolodin [@dermetfan]: https://github.com/dermetfan [@dunnock]: https://github.com/dunnock [@hgzimmerman]: https://github.com/hgzimmerman [@izissise]: https://github.com/izissise +[@jplatte]: https://github.com/jplatte [@jstarry]: https://github.com/jstarry +[@kakoc]: https://github.com/kakoc [@kellytk]: https://github.com/kellytk +[@leo-lb]: https://github.com/leo-lb [@lizhaoxian]: https://github.com/lizhaoxian [@mdtusz]: https://github.com/mdtusz [@mrh0057]: https://github.com/mrh0057 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..d2ceb69b3cc --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,48 @@ +## Contribution Guide + +### Setup your local development environment + +#### Add the wasm target + +```bash +rustup target add wasm32-unknown-unknown +``` + +#### Install [cargo-web] + +This is an optional tool that simplifies running the examples: + +```bash +cargo install cargo-web +``` + +> Add `--force` option to ensure you install the latest version. + +[cargo-web]: https://github.com/koute/cargo-web + +#### Build + +```bash +cargo build --target wasm32-unknown-unknown +``` + +#### Test +For the tests to work one have to ensure that `wasm-bindgen-cli` is installed. +[Instructions](https://rustwasm.github.io/docs/wasm-bindgen/wasm-bindgen-test/usage.html#install-the-test-runner) + +Additionally a webdriver must be installed locally and configured to be on the +`PATH`. Currently supports `geckodriver`, `chromedriver`, and `safaridriver`, +although more driver support may be added! You can download these at: + +* geckodriver - https://github.com/mozilla/geckodriver/releases +* chromedriver - http://chromedriver.chromium.org/downloads +* safaridriver - should be preinstalled on OSX + +```bash +./ci/run_tests.sh +``` +or + +```bash +cargo test --target wasm32-unknown-unknown --features wasm_test +``` diff --git a/Cargo.toml b/Cargo.toml index dcbd78fc8c3..1dd60ed2ad0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yew" -version = "0.11.1" +version = "0.12.0" edition = "2018" authors = [ "Denis Kolodin ", @@ -44,7 +44,7 @@ thiserror = "1" toml = { version = "0.5", optional = true } wasm-bindgen = { version = "0.2.58", optional = true } wasm-bindgen-futures = { version = "0.4", optional = true } -yew-macro = { version = "0.11.1", path = "crates/macro" } +yew-macro = { version = "0.12.0", path = "crates/macro" } [dependencies.web-sys] version = "0.3" @@ -108,6 +108,8 @@ wasm-bindgen = "0.2.58" # Changes here must be reflected in `build.rs` [target.'cfg(all(target_arch = "wasm32", not(target_os="wasi"), not(cargo_web)))'.dev-dependencies] wasm-bindgen-test = "0.3.4" +base64 = "0.11.0" +ssri = "5.0.0" [target.'cfg(target_os = "emscripten")'.dependencies] ryu = "1.0.2" # 1.0.1 breaks emscripten diff --git a/README.md b/README.md index f5678b1ae8e..2221eef206b 100644 --- a/README.md +++ b/README.md @@ -1,543 +1,69 @@
+ - - -

- Yew   - Build Status -

+

Yew

Rust / Wasm client web app framework

- Build Status + Crate Info + API Docs Gitter Chat Rustc Version 1.39+

- Website - | - API Docs + Documentation | - Examples + Examples | Changelog | Roadmap | - Code of Conduct + 中文的聊天室 + | + 简体中文文档

-## Overview - -**Yew** is a modern Rust framework inspired by Elm and React for -creating multi-threaded frontend apps with WebAssembly. - -The framework supports ***multi-threading & concurrency*** out of the box. -It uses [Web Workers API] to spawn actors (agents) in separate threads -and uses a local scheduler attached to a thread for concurrent tasks. - -[Web Workers API]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API - -[Become a sponsor on Patreon](https://www.patreon.com/deniskolodin) - -[Check out a live demo](https://yew-todomvc.netlify.com/) powered by [`yew-wasm-pack-template`](https://github.com/yewstack/yew-wasm-pack-template) - -## Cutting Edge technologies - -### Rust to WASM compilation - -This framework is designed to be compiled into modern browsers' runtimes: wasm, asm.js, emscripten. - -### Architecture inspired by Elm and Redux - -Yew implements strict application state management based on message passing and updates: - -`src/main.rs` - -```rust -use yew::{html, Component, ComponentLink, Html, ShouldRender}; - -struct Model { - link: ComponentLink, -} - -enum Msg { - DoIt, -} - -impl Component for Model { - // Some details omitted. Explore the examples to see more. - - type Message = Msg; - type Properties = (); - - fn create(_: Self::Properties, link: ComponentLink) -> Self { - Model { link } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::DoIt => { - // Update your model on events - true - } - } - } - - fn view(&self) -> Html { - let onclick = self.link.callback(|_| Msg::DoIt); - html! { - // Render your model here - - } - } -} - -fn main() { - yew::start_app::(); -} -``` - -Predictable mutability and lifetimes (thanks Rust!) make it possible to reuse a single instance of the model -without a need to create a fresh one on every update. It also helps to reduce memory allocations. - -### JSX-like templates with `html!` macro - -Feel free to put pure Rust code into HTML tags with all the compiler and borrow checker's benefits. - -```rust -html! { -
-
-

{ "todos" }

- { view_input(&model) } -
-
- - { view_entries(&model) } -
-
-} -``` - -### Agents - actor model inspired by Erlang and Actix - -Every `Component` can spawn an agent and attach to it. -Agents can coordinate global state, spawn long-running tasks, and offload tasks to a web worker. -They run independently of components, but hook nicely into their update mechanism. - -```rust -use yew::worker::*; - -struct Worker { - link: AgentLink, -} - -#[derive(Serialize, Deserialize, Debug)] -pub enum Request { - Question(String), -} - -#[derive(Serialize, Deserialize, Debug)] -pub enum Response { - Answer(String), -} - -impl Agent for Worker { - // Available: - // - `Job` (one per bridge on the main thread) - // - `Context` (shared in the main thread) - // - `Private` (one per bridge in a separate thread) - // - `Public` (shared in a separate thread) - type Reach = Context; // Spawn only one instance on the main thread (all components can share this agent) - type Message = Msg; - type Input = Request; - type Output = Response; - - // Create an instance with a link to the agent. - fn create(link: AgentLink) -> Self { - Worker { link } - } - - // Handle inner messages (from callbacks) - fn update(&mut self, msg: Self::Message) { /* ... */ } - - // Handle incoming messages from components of other agents. - fn handle_input(&mut self, msg: Self::Input, who: HandlerId) { - match msg { - Request::Question(_) => { - self.link.respond(who, Response::Answer("That's cool!".into())); - }, - } - } -} -``` - -Build the bridge to an instance of this agent. -It spawns a worker automatically or reuses an existing one, depending on the type of the agent: - -```rust -struct Model { - context: Box>, -} - -enum Msg { - ContextMsg(context::Response), -} - -impl Component for Model { - type Message = Msg; - type Properties = (); - - fn create(_: Self::Properties, link: ComponentLink) -> Self { - let callback = link.callback(|message| Msg::ContextMsg(message)); - // `Worker::bridge` spawns an instance if no one is available - let context = context::Worker::bridge(callback); // Connected! :tada: - Model { context } - } -} -``` - -You can use as many agents as you want. For example you could separate all interactions -with a server to a separate thread (a real OS thread because Web Workers map to the native threads). - -> **REMEMBER!** Not every API is available for every environment. For example you can't use -`StorageService` from a separate thread. It won't work with `Public` or `Private` agents, -only with `Job` and `Context` ones. - -### Components - -Yew supports components! You could create a new one by implementing a `Component` trait -and including it directly into the `html!` template: - -```rust -html! { - -} -``` - -### Scopes - -Components live in an Angular-like scopes with **parent-to-child** *(properties)* and -**child-to-parent** *(events)* interaction. - -Properties are also pure Rust types with strict type-checking during the compilation. - -```rust -// my_button.rs - -#[derive(Clone, Properties, PartialEq)] -pub struct Properties { - pub hidden: bool, - #[props(required)] - pub color: Color, - #[props(required)] - pub onclick: Callback<()>, -} - -``` - -```rust -// confirm_dialog.rs - -html! { -
-
-} -``` - -### Fragments - -Yew supports fragments: elements without a parent which can be attached to one somewhere else. - -```rust -html! { - <> - { "Row" } - { "Row" } - { "Row" } - -} -``` - -### Virtual DOM - -Yew uses its own **virtual-dom** implementation. It updates the browser's DOM with tiny patches when properties of elements have changed. Every component can be interacted with using its (`Scope`) to pass messages and trigger updates. - -The `ShouldRender` returns the value which informs the loop when the component should be re-rendered: - -```rust -fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::UpdateValue(value) => { - self.value = value; - true - } - Msg::Ignore => { - false - } - } -} -``` - -Using `ShouldRender` is more effective than comparing the model after every update because not every change to the model -causes an update to the view. It allows the framework to only compare parts of the model essential to rendering the view. - -### Rust/JS/C-style comments in templates - -Use single-line or multi-line Rust comments inside html-templates. - -```rust -html! { -
- /* Write some ideas - * in multiline comments - */ -

{ "and tags can be placed between comments!" }

- //
  • { "or single-line comments" }
  • -
    -} -``` - -### Third-party crates and pure Rust expressions inside - -Use external crates and put values from them into the template: - -```rust -extern crate chrono; -use chrono::prelude::*; - -impl Renderable for Model { - fn render(&self) -> Html { - html! { -

    { Local::now() }

    - } - } -} -``` - -> Some crates don't support the `wasm32-unknown-unknown` target yet. - -### Services - -Yew has implemented pluggable services that allow you to call external APIs, such as: -JavaScript alerts, timeout, storage, fetches and websockets. -It's a handy alternative to subscriptions. - -Implemented: -* `IntervalService` -* `RenderService` -* `ResizeService` -* `TimeoutService` -* `StorageService` -* `DialogService` -* `ConsoleService` -* `FetchService` -* `WebSocketService` -* `KeyboardService` - -```rust -use yew::services::{ConsoleService, TimeoutService}; - -struct Model { - link: ComponentLink, - console: ConsoleService, - timeout: TimeoutService, -} - -impl Component for Model { - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Fire => { - let timeout = self.link.callback(|_| Msg::Timeout); - self.timeout.spawn(Duration::from_secs(5), timeout); - } - Msg::Timeout => { - self.console.log("Timeout!"); - } - } - } -} -``` - -Can't find an essential service? Want to use a library from `npm`? -You can wrap `JavaScript` libraries using `stdweb` and create -your own service implementation. Here's an example below of how to wrap the -[ccxt](https://www.npmjs.com/package/ccxt) library: - -```rust -pub struct CcxtService(Option); - -impl CcxtService { - pub fn new() -> Self { - let lib = js! { - return ccxt; - }; - CcxtService(Some(lib)) - } - - pub fn exchanges(&mut self) -> Vec { - let lib = self.0.as_ref().expect("ccxt library object lost"); - let v: Value = js! { - var ccxt = @{lib}; - console.log(ccxt.exchanges); - return ccxt.exchanges; - }; - let v: Vec = v.try_into().expect("can't extract exchanges"); - v - } - - // Wrap more methods here! -} -``` - -### Easy-to-use data conversion and destructuring - -Yew allows for serialization (store/send and restore/receive) formats. - -Implemented: `JSON`, `TOML`, `YAML`, `MSGPACK`, `CBOR`. - -In development: `BSON`, `XML`. - -```rust -use yew::format::Json; - -#[derive(Serialize, Deserialize)] -struct Client { - first_name: String, - last_name: String, -} - -struct Model { - local_storage: StorageService, - clients: Vec, -} - -impl Component for Model { - fn update(&mut self, msg: Self::Message) -> ShouldRender { - Msg::Store => { - // Stores it, but in JSON format/layout - self.local_storage.store(KEY, Json(&model.clients)); - } - Msg::Restore => { - // Tries to read and destructure it as JSON formatted data - if let Json(Ok(clients)) = self.local_storage.restore(KEY) { - model.clients = clients; - } - } - } -} -``` - -Only `JSON` is available by default but you can activate the rest through features in -your project's `Cargo.toml`: - -```toml -[dependencies] -yew = { git = "https://github.com/yewstack/yew", features = ["toml", "yaml", "msgpack", "cbor"] } -``` - -## Development setup - -Clone or download this repository. - -### Install [cargo-web] - -This is an optional tool that simplifies deploying web applications: - -```bash -cargo install cargo-web -``` - -> Add `--force` option to ensure you install the latest version. - -### Build - -```bash -cargo web build - -# without cargo-web, only the wasm32-unknown-unknown target is supported -cargo build --target wasm32-unknown-unknown -``` - -### Running Tests -For the tests to work one have to ensure that `wasm-bindgen-cli` is installed. -[Instructions](https://rustwasm.github.io/docs/wasm-bindgen/wasm-bindgen-test/usage.html#install-the-test-runner) - -Additionally a webdriver must be installed locally and configured to be on the -`PATH`. Currently supports `geckodriver`, `chromedriver`, and `safaridriver`, -although more driver support may be added! You can download these at: +## About -* geckodriver - https://github.com/mozilla/geckodriver/releases -* chromedriver - http://chromedriver.chromium.org/downloads -* safaridriver - should be preinstalled on OSX +**Yew** is a modern Rust framework for creating multi-threaded front-end web apps with WebAssembly. -```bash -./ci/run_tests.sh -``` +* Features a macro for declaring interactive HTML with Rust expressions. Developers who have experience using JSX in React should feel quite at home when using Yew. +* Achieves high performance by minimizing DOM API calls for each page render and by making it easy to offload processing to background web workers. +* Supports JavaScript interoperability, allowing developers to leverage NPM packages and integrate with existing JavaScript applications. -### Running the examples +*Note: Yew is not (yet) production ready but is great for side projects and internal tools* -There are many examples that show how the framework works: -[counter], [crm], [custom_components], [dashboard], [fragments], -[game_of_life], [mount_point], [npm_and_rest], [timer], [todomvc], [two_apps]. +## Contributing -To start an example enter its directory and start it with [cargo-web]: +Yew is a community effort and we welcome all kinds of contributions, big or small, from developers of all backgrounds. We want the Yew community to be a fun and friendly place, so please review our [Code of Conduct](CODE_OF_CONDUCT.md) to learn what behavior will not be tolerated. -```bash -cargo web start -``` +#### 🤓 New to Yew? -To run an optimised build instead of a debug build use: +Start learning about the framework by helping us improve our [Documentation](https://github.com/yewstack/docs). Pull requests which improve test coverage are also very welcome. -```bash -cargo web start --release -``` +#### 🤔 Confused about something? -This will use the `wasm32-unknown-unknown` target by default, which is Rust's native WebAssembly target. -The Emscripten-based `wasm32-unknown-emscripten` and `asmjs-unknown-emscripten` targets are also supported -if you tell the `cargo-web` to build for them using the `--target` parameter. +Feel free to drop into our [Gitter chatroom](https://gitter.im/yewframework/Lobby) or open a [new "Question" issue](https://github.com/yewstack/yew/issues/new/choose) to get help from contributors. Oftentimes questions lead to improvements to the ergonomics of the framework, better documentation, and even new features! -[counter]: examples/counter -[crm]: examples/crm -[custom_components]: examples/custom_components -[dashboard]: examples/dashboard -[fragments]: examples/fragments -[game_of_life]: examples/game_of_life -[mount_point]: examples/mount_point -[npm_and_rest]: examples/npm_and_rest -[timer]: examples/timer -[todomvc]: examples/todomvc -[two_apps]: examples/two_apps -[cargo-web]: https://github.com/koute/cargo-web +#### 🙂 Ready to dive into the code? +After reviewing the [Contribution Guide](CONTRIBUTING.md), check out the ["Good First Issues"](https://github.com/yewstack/yew/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) (they are eager for attention!). Once you find one that interests you, feel free to assign yourself to an issue and don't hesitate to reach out for guidance, the issues vary in complexity. -## Project templates +#### 😱 Found a bug? -* [`yew-wasm-pack-template`](https://github.com/yewstack/yew-wasm-pack-template) -* [`yew-wasm-pack-minimal`](https://github.com/yewstack/yew-wasm-pack-minimal) +Please [report all bugs!](https://github.com/yewstack/yew/issues/new/choose) We are happy to help support developers fix the bugs they find if they are interested and have the time. ## Contributors ### Code Contributors -This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. +This project exists thanks to all the people who contribute. ### Financial Contributors diff --git a/bors.toml b/bors.toml deleted file mode 100644 index 88bce9d0986..00000000000 --- a/bors.toml +++ /dev/null @@ -1,4 +0,0 @@ -status = [ - "continuous-integration/travis-ci/push", -] -timeout_sec = 14400 diff --git a/crates/macro/Cargo.toml b/crates/macro/Cargo.toml index d5b5e81d6b7..3594e9672ec 100644 --- a/crates/macro/Cargo.toml +++ b/crates/macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yew-macro" -version = "0.11.1" +version = "0.12.0" edition = "2018" authors = ["Justin Starry "] repository = "https://github.com/yewstack/yew" diff --git a/crates/macro/tests/derive_props/fail.stderr b/crates/macro/tests/derive_props/fail.stderr index e2279330777..045339312bf 100644 --- a/crates/macro/tests/derive_props/fail.stderr +++ b/crates/macro/tests/derive_props/fail.stderr @@ -47,7 +47,7 @@ error[E0599]: no method named `build` found for type `t3::PropsBuilder $DIR/fail.rs:35:26 | 28 | #[derive(Clone, Properties)] - | - method `build` not found for this + | ---------- method `build` not found for this ... 35 | Props::builder().build(); | ^^^^^ method not found in `t3::PropsBuilder` @@ -60,7 +60,7 @@ error[E0599]: no method named `b` found for type `t4::PropsBuilder $DIR/fail.rs:49:26 | 41 | #[derive(Clone, Properties)] - | - method `b` not found for this + | ---------- method `b` not found for this ... 49 | Props::builder().b(1).a(2).build(); | ^ help: there is a method with a similar name: `a` @@ -80,9 +80,7 @@ error[E0308]: match arms have incompatible types 112 | #[props(default = "foo")] | ^^^^^ | | - | expected struct `std::string::String`, found i32 + | expected struct `std::string::String`, found `i32` | `match` arms have incompatible types | this is found to be of type `std::string::String` - | - = note: expected type `std::string::String` - found type `i32` + | help: try using a conversion method: `"foo".to_string()` diff --git a/crates/macro/tests/derive_props_test.rs b/crates/macro/tests/derive_props_test.rs index c72dce3f4a9..2f0ceb341aa 100644 --- a/crates/macro/tests/derive_props_test.rs +++ b/crates/macro/tests/derive_props_test.rs @@ -1,5 +1,5 @@ #[allow(dead_code)] -#[rustversion::attr(stable(1.40.0), test)] +#[rustversion::attr(stable(1.41.0), test)] fn tests() { let t = trybuild::TestCases::new(); t.pass("tests/derive_props/pass.rs"); diff --git a/crates/macro/tests/macro/html-component-fail.stderr b/crates/macro/tests/macro/html-component-fail.stderr index 5af9f4b8b06..aff68bf6ffc 100644 --- a/crates/macro/tests/macro/html-component-fail.stderr +++ b/crates/macro/tests/macro/html-component-fail.stderr @@ -122,7 +122,7 @@ error[E0599]: no method named `unknown` found for type `ChildPropertiesBuilder $DIR/html-component-fail.rs:64:20 | 6 | #[derive(Clone, Properties, PartialEq)] - | - method `unknown` not found for this + | ---------- method `unknown` not found for this ... 64 | html! { }; | ^^^^^^^ method not found in `ChildPropertiesBuilder` @@ -173,10 +173,7 @@ error[E0308]: mismatched types --> $DIR/html-component-fail.rs:69:30 | 69 | html! { }; - | ^^ expected struct `yew::html::NodeRef`, found () - | - = note: expected type `yew::html::NodeRef` - found type `()` + | ^^ expected struct `yew::html::NodeRef`, found `()` error[E0277]: the trait bound `yew::virtual_dom::vcomp::VComp: yew::virtual_dom::Transformer` is not satisfied --> $DIR/html-component-fail.rs:71:24 @@ -196,7 +193,7 @@ error[E0599]: no method named `string` found for type `ChildPropertiesBuilder $DIR/html-component-fail.rs:72:20 | 6 | #[derive(Clone, Properties, PartialEq)] - | - method `string` not found for this + | ---------- method `string` not found for this ... 72 | html! { }; | ^^^^^^ method not found in `ChildPropertiesBuilder` @@ -209,7 +206,7 @@ error[E0599]: no method named `children` found for type `ChildPropertiesBuilder< --> $DIR/html-component-fail.rs:76:5 | 6 | #[derive(Clone, Properties, PartialEq)] - | - method `children` not found for this + | ---------- method `children` not found for this ... 76 | html! { { "Not allowed" } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `ChildPropertiesBuilder` @@ -220,7 +217,7 @@ error[E0599]: no method named `build` found for type `ChildContainerPropertiesBu --> $DIR/html-component-fail.rs:78:5 | 23 | #[derive(Clone, Properties)] - | - method `build` not found for this + | ---------- method `build` not found for this ... 78 | html! { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `ChildContainerPropertiesBuilder` @@ -234,7 +231,7 @@ error[E0599]: no method named `build` found for type `ChildContainerPropertiesBu --> $DIR/html-component-fail.rs:79:5 | 23 | #[derive(Clone, Properties)] - | - method `build` not found for this + | ---------- method `build` not found for this ... 79 | html! { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `ChildContainerPropertiesBuilder` diff --git a/crates/macro/tests/macro/html-tag-fail.stderr b/crates/macro/tests/macro/html-tag-fail.stderr index 9258e21f025..c736d40206e 100644 --- a/crates/macro/tests/macro/html-tag-fail.stderr +++ b/crates/macro/tests/macro/html-tag-fail.stderr @@ -110,28 +110,19 @@ error[E0308]: mismatched types --> $DIR/html-tag-fail.rs:25:28 | 25 | html! { }; - | ^ expected bool, found integer - | - = note: expected type `bool` - found type `{integer}` + | ^ expected `bool`, found integer error[E0308]: mismatched types --> $DIR/html-tag-fail.rs:26:29 | 26 | html! { }; - | ^ expected bool, found integer - | - = note: expected type `bool` - found type `{integer}` + | ^ expected `bool`, found integer error[E0308]: mismatched types --> $DIR/html-tag-fail.rs:27:30 | 27 | html! {