From 26149da0337f9fc4e50e949c7a85375004403616 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 9 Jan 2025 10:42:13 -0800 Subject: [PATCH] Update to the Rust 2024 edition This is a test to see what breaks in CI when updating to the 2024 edition. The edition won't actually be released until February of this year and we won't be able to use it until two releases after that. This is just a test in the meantime to smooth the future transition. --- .github/actions/install-rust/action.yml | 6 +- Cargo.lock | 217 +++++++----------- Cargo.toml | 14 +- crates/test-programs/src/bin/api_reactor.rs | 5 - .../runtime/component/bindgen_examples/mod.rs | 4 +- crates/wasmtime/src/runtime/memory.rs | 40 ++-- 6 files changed, 123 insertions(+), 163 deletions(-) diff --git a/.github/actions/install-rust/action.yml b/.github/actions/install-rust/action.yml index 759cf6e1c891..1812d9ee152c 100644 --- a/.github/actions/install-rust/action.yml +++ b/.github/actions/install-rust/action.yml @@ -24,9 +24,11 @@ runs: range=${{ inputs.msrv_range }} if [ "${{ inputs.toolchain }}" = "default" ]; then - echo "version=1.$((msrv+range)).0" >> "$GITHUB_OUTPUT" + #echo "version=1.$((msrv+range)).0" >> "$GITHUB_OUTPUT" + echo "version=beta" >> "$GITHUB_OUTPUT" elif [ "${{ inputs.toolchain }}" = "msrv" ]; then - echo "version=1.$msrv.0" >> "$GITHUB_OUTPUT" + #echo "version=1.$msrv.0" >> "$GITHUB_OUTPUT" + echo "version=beta" >> "$GITHUB_OUTPUT" elif [ "${{ inputs.toolchain }}" = "wasmtime-ci-pinned-nightly" ]; then echo "version=nightly-2025-01-09" >> "$GITHUB_OUTPUT" else diff --git a/Cargo.lock b/Cargo.lock index 6291e5c5b124..913a02ac0c6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -1406,12 +1406,13 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.27" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", + "futures-executor", "futures-io", "futures-sink", "futures-task", @@ -1420,9 +1421,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.27" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1434,11 +1435,33 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] [[package]] name = "futures-sink" @@ -1458,11 +1481,16 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ + "futures-channel", "futures-core", + "futures-io", + "futures-macro", "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -3209,7 +3237,7 @@ dependencies = [ "cargo_metadata", "heck 0.5.0", "wasmtime", - "wit-component 0.223.0", + "wit-component", ] [[package]] @@ -3618,7 +3646,7 @@ name = "verify-component-adapter" version = "30.0.0" dependencies = [ "anyhow", - "wasmparser 0.223.0", + "wasmparser", "wat", ] @@ -3710,7 +3738,7 @@ dependencies = [ "byte-array-literals", "object", "wasi", - "wasm-encoder 0.223.0", + "wasm-encoder", "wit-bindgen-rust-macro", ] @@ -3769,16 +3797,6 @@ version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" -[[package]] -name = "wasm-encoder" -version = "0.220.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebf48234b389415b226a4daef6562933d38c7b28a8b8f64c5c4130dad1561ab7" -dependencies = [ - "leb128", - "wasmparser 0.220.0", -] - [[package]] name = "wasm-encoder" version = "0.223.0" @@ -3786,23 +3804,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e636076193fa68103e937ac951b5f2f587624097017d764b8984d9c0f149464" dependencies = [ "leb128", - "wasmparser 0.223.0", -] - -[[package]] -name = "wasm-metadata" -version = "0.220.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f3e5f5920c5abfc45573c89b07b38efdaae1515ef86f83dad12d60e50ecd62b" -dependencies = [ - "anyhow", - "indexmap 2.7.0", - "serde", - "serde_derive", - "serde_json", - "spdx", - "wasm-encoder 0.220.0", - "wasmparser 0.220.0", + "wasmparser", ] [[package]] @@ -3818,8 +3820,8 @@ dependencies = [ "serde_json", "spdx", "url", - "wasm-encoder 0.223.0", - "wasmparser 0.223.0", + "wasm-encoder", + "wasmparser", ] [[package]] @@ -3832,8 +3834,8 @@ dependencies = [ "log", "rand", "thiserror", - "wasm-encoder 0.223.0", - "wasmparser 0.223.0", + "wasm-encoder", + "wasmparser", ] [[package]] @@ -3847,7 +3849,7 @@ dependencies = [ "flagset", "indexmap 2.7.0", "leb128", - "wasm-encoder 0.223.0", + "wasm-encoder", ] [[package]] @@ -3867,7 +3869,7 @@ dependencies = [ "indexmap 2.7.0", "logos", "thiserror", - "wit-parser 0.223.0", + "wit-parser", ] [[package]] @@ -3914,19 +3916,6 @@ dependencies = [ "wasmi_core", ] -[[package]] -name = "wasmparser" -version = "0.220.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e246c2772ce3ebc83f89a2d4487ac5794cad6c309b2071818a88c7db7c36d87b" -dependencies = [ - "ahash", - "bitflags 2.6.0", - "hashbrown 0.14.3", - "indexmap 2.7.0", - "semver", -] - [[package]] name = "wasmparser" version = "0.223.0" @@ -3957,7 +3946,7 @@ checksum = "9235722b8cdb6c1c6daa537d4be4e230e76ce3ce0e4ba991956a1c6aed50305a" dependencies = [ "anyhow", "termcolor", - "wasmparser 0.223.0", + "wasmparser", ] [[package]] @@ -4002,9 +3991,9 @@ dependencies = [ "tempfile", "trait-variant", "wasi-common", - "wasm-encoder 0.223.0", + "wasm-encoder", "wasm-wave", - "wasmparser 0.223.0", + "wasmparser", "wasmtime-asm-macros", "wasmtime-cache", "wasmtime-component-macro", @@ -4147,8 +4136,8 @@ dependencies = [ "trait-variant", "walkdir", "wasi-common", - "wasm-encoder 0.223.0", - "wasmparser 0.223.0", + "wasm-encoder", + "wasmparser", "wasmtime", "wasmtime-cache", "wasmtime-cli-flags", @@ -4168,7 +4157,7 @@ dependencies = [ "wast 223.0.0", "wat", "windows-sys 0.59.0", - "wit-component 0.223.0", + "wit-component", ] [[package]] @@ -4201,7 +4190,7 @@ dependencies = [ "wasmtime", "wasmtime-component-util", "wasmtime-wit-bindgen", - "wit-parser 0.223.0", + "wit-parser", ] [[package]] @@ -4227,7 +4216,7 @@ dependencies = [ "smallvec", "target-lexicon", "thiserror", - "wasmparser 0.223.0", + "wasmparser", "wasmtime-environ", "wasmtime-versioned-export-macros", ] @@ -4253,8 +4242,8 @@ dependencies = [ "serde_derive", "smallvec", "target-lexicon", - "wasm-encoder 0.223.0", - "wasmparser 0.223.0", + "wasm-encoder", + "wasmparser", "wasmprinter", "wasmtime-component-util", "wat", @@ -4268,7 +4257,7 @@ dependencies = [ "component-fuzz-util", "env_logger 0.11.5", "libfuzzer-sys", - "wasmparser 0.223.0", + "wasmparser", "wasmprinter", "wasmtime-environ", "wat", @@ -4327,7 +4316,7 @@ dependencies = [ "rand", "smallvec", "target-lexicon", - "wasmparser 0.223.0", + "wasmparser", "wasmtime", "wasmtime-fuzzing", ] @@ -4348,12 +4337,12 @@ dependencies = [ "target-lexicon", "tempfile", "v8", - "wasm-encoder 0.223.0", + "wasm-encoder", "wasm-mutate", "wasm-smith", "wasm-spec-interpreter", "wasmi", - "wasmparser 0.223.0", + "wasmparser", "wasmprinter", "wasmtime", "wasmtime-wast", @@ -4555,7 +4544,7 @@ dependencies = [ "gimli", "object", "target-lexicon", - "wasmparser 0.223.0", + "wasmparser", "wasmtime-cranelift", "wasmtime-environ", "winch-codegen", @@ -4568,7 +4557,7 @@ dependencies = [ "anyhow", "heck 0.5.0", "indexmap 2.7.0", - "wit-parser 0.223.0", + "wit-parser", ] [[package]] @@ -4594,7 +4583,7 @@ dependencies = [ "leb128", "memchr", "unicode-width 0.2.0", - "wasm-encoder 0.223.0", + "wasm-encoder", ] [[package]] @@ -4745,7 +4734,7 @@ dependencies = [ "smallvec", "target-lexicon", "thiserror", - "wasmparser 0.223.0", + "wasmparser", "wasmtime-cranelift", "wasmtime-environ", ] @@ -4968,9 +4957,8 @@ dependencies = [ [[package]] name = "wit-bindgen" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c966692b6d8c4bb3c1aee3313e0930f44457a5763cfffb666f814506124e4691" +version = "0.36.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen#51e1ef5573ca3e00be63ec404d5a19d064bec6d6" dependencies = [ "wit-bindgen-rt", "wit-bindgen-rust-macro", @@ -4978,45 +4966,43 @@ dependencies = [ [[package]] name = "wit-bindgen-core" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19857cff2a480fece56ea43f9199322ee5014688a3539ebf8d29ae62d75a3a1f" +version = "0.36.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen#51e1ef5573ca3e00be63ec404d5a19d064bec6d6" dependencies = [ "anyhow", "heck 0.5.0", - "wit-parser 0.220.0", + "wit-parser", ] [[package]] name = "wit-bindgen-rt" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "605d5562e971a823cf5a550a9d69cb7144e9b4969a810043127175517a4e1865" +version = "0.36.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen#51e1ef5573ca3e00be63ec404d5a19d064bec6d6" dependencies = [ "bitflags 2.6.0", + "futures", + "once_cell", ] [[package]] name = "wit-bindgen-rust" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d894e599c161d71acb6a78e8ec8a609a09c2bb227de50829f5afbd03b844a69" +version = "0.36.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen#51e1ef5573ca3e00be63ec404d5a19d064bec6d6" dependencies = [ "anyhow", "heck 0.5.0", "indexmap 2.7.0", "prettyplease", "syn 2.0.90", - "wasm-metadata 0.220.0", + "wasm-metadata", "wit-bindgen-core", - "wit-component 0.220.0", + "wit-component", ] [[package]] name = "wit-bindgen-rust-macro" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a723cf943bba3bf34f437eb101e5a78180971e25dfb0085d80dbe4e73afb2854" +version = "0.36.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen#51e1ef5573ca3e00be63ec404d5a19d064bec6d6" dependencies = [ "anyhow", "prettyplease", @@ -5027,25 +5013,6 @@ dependencies = [ "wit-bindgen-rust", ] -[[package]] -name = "wit-component" -version = "0.220.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73ccedf54cc65f287da268d64d2bf4f7530d2cfb2296ffbe3ad5f65567e4cf53" -dependencies = [ - "anyhow", - "bitflags 2.6.0", - "indexmap 2.7.0", - "log", - "serde", - "serde_derive", - "serde_json", - "wasm-encoder 0.220.0", - "wasm-metadata 0.220.0", - "wasmparser 0.220.0", - "wit-parser 0.220.0", -] - [[package]] name = "wit-component" version = "0.223.0" @@ -5059,28 +5026,10 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "wasm-encoder 0.223.0", - "wasm-metadata 0.223.0", - "wasmparser 0.223.0", - "wit-parser 0.223.0", -] - -[[package]] -name = "wit-parser" -version = "0.220.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b7117ce3adc0b4354b46dc1cf3190b00b333e65243d244c613ffcc58bdec84d" -dependencies = [ - "anyhow", - "id-arena", - "indexmap 2.7.0", - "log", - "semver", - "serde", - "serde_derive", - "serde_json", - "unicode-xid", - "wasmparser 0.220.0", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", ] [[package]] @@ -5098,7 +5047,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.223.0", + "wasmparser", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 16cfce9cbffb..627b83f08b22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -165,10 +165,10 @@ exclude = [ [workspace.package] version = "30.0.0" authors = ["The Wasmtime Project Developers"] -edition = "2021" +edition = "2024" # Wasmtime's current policy is that this number can be no larger than the # current stable release of Rust minus 2. -rust-version = "1.82.0" +rust-version = "1.85.0" [workspace.lints.rust] # Turn on some lints which are otherwise allow-by-default in rustc. @@ -191,6 +191,8 @@ rust-2024-incompatible-pat = 'warn' missing-unsafe-on-extern = 'warn' impl-trait-overcaptures = 'warn' +unsafe-op-in-unsafe-fn = 'allow' + # Don't warn about unknown cfgs for pulley [workspace.lints.rust.unexpected_cfgs] level = "warn" @@ -293,8 +295,8 @@ io-lifetimes = { version = "2.0.3", default-features = false } io-extras = "0.18.1" rustix = "0.38.43" # wit-bindgen: -wit-bindgen = { version = "0.35.0", default-features = false } -wit-bindgen-rust-macro = { version = "0.35.0", default-features = false } +wit-bindgen = { version = "0.36.0", default-features = false } +wit-bindgen-rust-macro = { version = "0.36.0", default-features = false } # wasm-tools family: wasmparser = { version = "0.223.0", default-features = false, features = ['simd'] } @@ -563,3 +565,7 @@ opt-level = 's' inherits = "release" codegen-units = 1 lto = true + +[patch.crates-io] +wit-bindgen = { git = 'https://github.com/bytecodealliance/wit-bindgen' } +wit-bindgen-rust-macro = { git = 'https://github.com/bytecodealliance/wit-bindgen' } diff --git a/crates/test-programs/src/bin/api_reactor.rs b/crates/test-programs/src/bin/api_reactor.rs index f232743a80db..360c96fab61b 100644 --- a/crates/test-programs/src/bin/api_reactor.rs +++ b/crates/test-programs/src/bin/api_reactor.rs @@ -1,8 +1,3 @@ -#![expect( - unsafe_attr_outside_unsafe, - reason = "needs fixes in upstream wit-bindgen to satisfy this lint" -)] - use std::sync::{Mutex, MutexGuard}; wit_bindgen::generate!({ diff --git a/crates/wasmtime/src/runtime/component/bindgen_examples/mod.rs b/crates/wasmtime/src/runtime/component/bindgen_examples/mod.rs index c8a756cd3de8..d61c9e7c964c 100644 --- a/crates/wasmtime/src/runtime/component/bindgen_examples/mod.rs +++ b/crates/wasmtime/src/runtime/component/bindgen_examples/mod.rs @@ -205,11 +205,11 @@ pub mod _1_world_imports; /// // ... /// } /// -/// # mod rand { pub fn thread_rng() -> G { G } pub struct G; impl G { pub fn gen(&self) -> u32 { 0 } } } +/// # mod rand { pub fn thread_rng() -> G { G } pub struct G; impl G { pub fn r#gen(&self) -> u32 { 0 } } } /// // Note that the trait here is per-interface and within a submodule now. /// impl my::project::host::Host for MyState { /// fn gen_random_integer(&mut self) -> u32 { -/// rand::thread_rng().gen() +/// rand::thread_rng().r#gen() /// } /// /// fn sha256(&mut self, bytes: Vec) -> String { diff --git a/crates/wasmtime/src/runtime/memory.rs b/crates/wasmtime/src/runtime/memory.rs index 57f6c2a01f35..8ef0b1a51a11 100644 --- a/crates/wasmtime/src/runtime/memory.rs +++ b/crates/wasmtime/src/runtime/memory.rs @@ -116,35 +116,43 @@ impl std::error::Error for MemoryAccessError {} /// // First and foremost, any borrow can be invalidated at any time via the /// // `Memory::grow` function. This can relocate memory which causes any /// // previous pointer to be possibly invalid now. -/// let pointer: &u8 = &*mem.data_ptr(&store); -/// mem.grow(&mut *store, 1)?; // invalidates `pointer`! -/// // println!("{}", *pointer); // FATAL: use-after-free +/// unsafe { +/// let pointer: &u8 = &*mem.data_ptr(&store); +/// mem.grow(&mut *store, 1)?; // invalidates `pointer`! +/// // println!("{}", *pointer); // FATAL: use-after-free +/// } /// /// // Note that the use-after-free also applies to slices, whether they're /// // slices of bytes or strings. -/// let mem_slice = std::slice::from_raw_parts( -/// mem.data_ptr(&store), -/// mem.data_size(&store), -/// ); -/// let slice: &[u8] = &mem_slice[0x100..0x102]; -/// mem.grow(&mut *store, 1)?; // invalidates `slice`! -/// // println!("{:?}", slice); // FATAL: use-after-free +/// unsafe { +/// let mem_slice = std::slice::from_raw_parts( +/// mem.data_ptr(&store), +/// mem.data_size(&store), +/// ); +/// let slice: &[u8] = &mem_slice[0x100..0x102]; +/// mem.grow(&mut *store, 1)?; // invalidates `slice`! +/// // println!("{:?}", slice); // FATAL: use-after-free +/// } /// /// // The `Memory` type may be stored in other locations, so if you hand /// // off access to the `Store` then those locations may also call /// // `Memory::grow` or similar, so it's not enough to just audit code for /// // calls to `Memory::grow`. -/// let pointer: &u8 = &*mem.data_ptr(&store); -/// some_other_function(store); // may invalidate `pointer` through use of `store` -/// // println!("{:?}", pointer); // FATAL: maybe a use-after-free +/// unsafe { +/// let pointer: &u8 = &*mem.data_ptr(&store); +/// some_other_function(store); // may invalidate `pointer` through use of `store` +/// // println!("{:?}", pointer); // FATAL: maybe a use-after-free +/// } /// /// // An especially subtle aspect of accessing a wasm instance's memory is /// // that you need to be extremely careful about aliasing. Anyone at any /// // time can call `data_unchecked()` or `data_unchecked_mut()`, which /// // means you can easily have aliasing mutable references: -/// let ref1: &u8 = &*mem.data_ptr(&store).add(0x100); -/// let ref2: &mut u8 = &mut *mem.data_ptr(&store).add(0x100); -/// // *ref2 = *ref1; // FATAL: violates Rust's aliasing rules +/// unsafe { +/// let ref1: &u8 = &*mem.data_ptr(&store).add(0x100); +/// let ref2: &mut u8 = &mut *mem.data_ptr(&store).add(0x100); +/// // *ref2 = *ref1; // FATAL: violates Rust's aliasing rules +/// } /// /// Ok(()) /// }