feat: while, break/continue/return, and preamble statements in html!#4124
Merged
Madoshakalaka merged 9 commits intomasterfrom Apr 25, 2026
Merged
feat: while, break/continue/return, and preamble statements in html!#4124Madoshakalaka merged 9 commits intomasterfrom
Madoshakalaka merged 9 commits intomasterfrom
Conversation
|
Visit the preview URL for this PR (updated for commit b9fe62a): https://yew-rs--pr4124-break-continue-4gv5tjtr.web.app (expires Sat, 02 May 2026 09:37:09 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Size ComparisonDetails
✅ None of the examples has changed their size significantly. |
Benchmark - SSRYew MasterDetails
Pull RequestDetails
|
a6d0182 to
ee86510
Compare
# Conflicts: # packages/yew-macro/tests/html_macro/for-fail.stderr
Benchmark - coreYew MasterPull Request |
Our MSRV is 1.85+ but users might stay on edition 2021 for various reasons This change wraps break/continue in Into::into(...) triggered the never-type fallback in editions before 2024, where unconstrained ! falls back to (), producing "(): Into<VNode> is not satisfied" on edition 2021 users. Emit the keyword directly as a statement instead so the generated code is edition-agnostic.
WorldSEnder
reviewed
Apr 21, 2026
As a consequence, labeled `break 'outer` and `continue 'outer` work for targeting loops defined in the surrounding Rust code, crossing the macro boundary. `stmts_have_divergent` detects top-level `break`/`continue`/`return` and emits `#![allow(unreachable_code)]` on an inner expression block (stable Rust rejects inner attributes directly in if-branch and match-arm positions). Docs: extended the `for`/`while` sections in lists.mdx to cover the broader statement support, labeled break/continue, match-arm break/continue, and the `<Type>::method(...)` qualified-path workaround.
b8bc9c6 to
f509aed
Compare
… arm and `__yew_v` hygiene
Madoshakalaka
commented
Apr 25, 2026
Member
Author
Madoshakalaka
left a comment
There was a problem hiding this comment.
I've done some external validation on two codebases, one small, one big.
Improvements on the smaller csr only codebase (a 5-user internal web app, Axum + Yew):
| before | after | delta | |
|---|---|---|---|
| frontend total LoC | 4447 | 4382 | -65 (-1.4%) |
html! macro invocations |
69 | 42 | -27 (-39%) |
files changed: 10 of 18
Improvements on the bigger SSR codebase (also Axum + Yew):
| before | after | delta | |
|---|---|---|---|
total LoC across changed .rs files |
16,151 | 16,047 | -104 (-0.6%) |
html! macro invocations |
196 | 150 | -46 (-23%) |
files changed: 16 of 39
Neither app showed any functional regression.
The only rough edge discovered: "imperative preamble loops" are not supported. Patched in b9fe62a. A better support can land in a separate PR.
This was referenced Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
a spiritual followup of #4118
Checklist