rename Memory::get methods to get_raw to indicate their unchecked nature#66043
rename Memory::get methods to get_raw to indicate their unchecked nature#66043bors merged 1 commit intorust-lang:masterfrom
Conversation
|
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
|
@bors r+ |
|
📌 Commit 0aee0dd has been approved by |
Yes, it needs |
|
@bjorn3 okay, so we should likely still allow immutable access. But we can shut down mutable access eventually. |
|
I have actually been thinking about allowing the user to mutate state (including allocations) instead of just observing it. However I havent worked on priroda anymore for 5 months according to github. |
|
Maybe renaming the functions to |
|
For now I don't think things are bad enough that we need to resort to leading underscores... |
rename Memory::get methods to get_raw to indicate their unchecked nature Some recent Miri PRs started using these methods when they should not; this should discourage their use. In fact we could make these methods private to the `interp` module as far as Miri is concerned -- with the exception of the `uninit` intrinsic which will hopefully go away soon. @bjorn3 @oli-obk does priroda need these methods? It would be great to be able to seal them away.
|
Toolstate failure in #66138 (comment), @bors rollup=never p=-1 Please revert ^-- in a bit. |
|
A Miri failure shouldn't be a problem even during the beta week...? |
|
🤷♂ -- beats me; it seems to have caused a failure tho... but I think toolstate blockage is finally over. @bors p=0 rollup=maybe |
|
Ah, clippy-driver also got broken in that rollup. Whether that was this PR or another one I don't know. I guess we'll see.^^ |
|
Looks like clippy was affected by another PR in the rollup: #66150 |
|
☔ The latest upstream changes (presumably #66175) made this pull request unmergeable. Please resolve the merge conflicts. |
0aee0dd to
15ec8f7
Compare
|
Rebased. @bors r=cramertj |
|
📌 Commit 15ec8f7 has been approved by |
|
⌛ Testing commit 15ec8f7 with merge b21093f8fcb2591907a739fd7a05cd8500727521... |
rename Memory::get methods to get_raw to indicate their unchecked nature Some recent Miri PRs started using these methods when they should not; this should discourage their use. In fact we could make these methods private to the `interp` module as far as Miri is concerned -- with the exception of the `uninit` intrinsic which will hopefully go away soon. @bjorn3 @oli-obk does priroda need these methods? It would be great to be able to seal them away.
|
@bors retry rolled up. |
rename Memory::get methods to get_raw to indicate their unchecked nature Some recent Miri PRs started using these methods when they should not; this should discourage their use. In fact we could make these methods private to the `interp` module as far as Miri is concerned -- with the exception of the `uninit` intrinsic which will hopefully go away soon. @bjorn3 @oli-obk does priroda need these methods? It would be great to be able to seal them away.
Rollup of 5 pull requests Successful merges: - #65785 (Transition future compat lints to {ERROR, DENY} - Take 2) - #66007 (Remove "here" from "expected one of X here") - #66043 (rename Memory::get methods to get_raw to indicate their unchecked nature) - #66154 (miri: Rename to_{u,i}size to to_machine_{u,i}size) - #66188 (`MethodSig` -> `FnSig` & Use it in `ItemKind::Fn`) Failed merges: r? @ghost
…n + codegen tool
Scales Phase 1's `web_mobile_demo` proof-of-concept into a zero-
migration pipeline: every example in `crates/blinc_app/examples/*.rs`
that follows a simple convention is automatically buildable for both
desktop and wasm32, no per-example registration needed. New examples
drop a single `.rs` file and are picked up on the next CI run.
The convention (documented in `docs/book/src/contributing/examples.md`
in a follow-up PR):
//! Example Title
//!
//! …description…
pub fn build_ui(ctx: &mut WindowedContext) -> impl ElementBuilder {
// the actual demo
}
#[cfg(not(target_arch = "wasm32"))]
fn main() -> Result<()> {
tracing_subscriber::fmt().init();
let config = WindowConfig { /* … */ };
blinc_app::windowed::WindowedApp::run(config, build_ui)
}
Opt-out: any `//! no-web:` line in the top doc comment makes the
codegen tool skip the file. Three examples opted out: `css_parser_demo`
(CLI diagnostic), `fuchsia_hello` (Fuchsia-only), `multi_window_demo`
(no multi-window on web).
Three landing pieces:
1. **`WebApp` runner type-erasure** (`crates/blinc_app/src/web.rs`).
`WebApp::run` / `run_with_setup` / `run_with_async_setup` /
`set_ui_builder` are now generic over `FnMut(&mut WindowedContext) -> E`
for any `E: ElementBuilder`, matching the desktop runner's
`WindowedApp::run` signature shape. A new object-safe `UiBuilderFn`
trait with two methods (`build_from_scratch`, `build_and_update`)
does the work directly so the concrete element type never has to
leave the closure. Blanket `impl<F, E> UiBuilderFn for F` covers
every valid user function.
Previously the runner stored `Box<dyn FnMut(&mut WindowedContext) -> Div>`,
which forced every example to return concrete `Div` — broke
`emoji_demo` (returns `Scroll`), `notch_demo` (returns `Stateful<T>`),
`text_widgets` (returns `Scroll`), and would have broken any future
example with a non-`Div` root.
2. **Codegen tool `tools/build-web-examples/`**. Walks
`crates/blinc_app/examples/*.rs`, parses each file with `syn`,
detects the convention via AST walk for top-level `pub fn build_ui`,
and emits one wrapper crate per match under `examples/_generated/<name>/`.
Each wrapper is a small cdylib that:
- `build.rs` pre-processes the upstream source to strip `//!`
inner doc comments and `#![…]` inner attributes (both illegal
mid-module when `include!`'d due to rust-lang/rust#66043),
preserving line numbers via blank-line replacement.
- `src/lib.rs` puts the cleaned example inside a private
`mod example { include!(…$OUT_DIR/example.rs) }`, imports the
resulting `build_ui`, and calls `WebApp::run_with_setup` from
a `#[wasm_bindgen(start)]` shim.
- `Cargo.toml` has inferred deps (the tool greps for
`blinc_cn::` / `blinc_icons::` / etc. prefixes in the source).
- `index.html` + `serve.sh` complete the shipping surface.
The tool is idempotent, prunes stale wrappers when examples are
removed, and is NOT in `default-members` — it runs explicitly via
`cargo run -p blinc-build-web-examples`.
3. **Mass migration** — **36 examples refactored to the convention**
in a single scripted pass (plus the 5 already-refactored Phase 1
examples). Every `fn build_ui(ctx: &WindowedContext) -> impl ElementBuilder`
was rewritten to `pub fn build_ui(ctx: &mut WindowedContext) -> impl ElementBuilder`,
`fn main` was cfg-gated with `#[cfg(not(target_arch = "wasm32"))]`,
and `WindowedApp::run(config, |ctx| build_ui(ctx))` became
`blinc_app::windowed::WindowedApp::run(config, build_ui)`. Zero
desktop behavior change — `cargo check -p blinc_app --examples
--features windowed` is clean.
Workspace layout additions:
- `examples/_generated/` with `.gitignore` + `.gitkeep` markers.
Everything else in the directory is gitignored — generated
wrappers live in the working tree but never in the commit.
- `Cargo.toml` workspace members gains `examples/_generated/*`
(empty-match-tolerant glob) and `tools/build-web-examples`.
Verification matrix:
- `cargo check -p blinc_app --examples --features windowed`: clean
- `cargo run -p blinc-build-web-examples`: 41/41 wrappers emitted
- `cargo check --target wasm32-unknown-unknown -p <all 41>`: clean
- `cargo clippy --target wasm32-unknown-unknown -p <all 41> -- -D warnings`: clean
- `RUSTFLAGS="-D warnings" cargo check --workspace --all-targets --all-features`: clean
- `wasm-pack build --target web --release` on 6 representative wrappers
(including previously-failing `Scroll` and `Stateful<T>` root cases): clean
Remaining work, tracked in follow-up PRs:
- Phase 4: CI workflow to invoke the codegen tool, run wasm-pack on
every wrapper, stage outputs under `target/book/examples/`, and
publish via the existing GitHub Pages deploy.
- mdBook gallery page with lazy-loaded iframes per example.
- `docs/book/src/contributing/examples.md` codifying the convention
for future example authors.
Some recent Miri PRs started using these methods when they should not; this should discourage their use.
In fact we could make these methods private to the
interpmodule as far as Miri is concerned -- with the exception of theuninitintrinsic which will hopefully go away soon. @bjorn3 @oli-obk does priroda need these methods? It would be great to be able to seal them away.