diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f385bc00975..c3d8f8159862 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -199,7 +199,7 @@ jobs: runs-on: ubuntu-latest env: CARGO_MDBOOK_VERSION: 0.4.21 - RUSTDOCFLAGS: -Dbroken_intra_doc_links --cfg nightlydoc + RUSTDOCFLAGS: -Dbroken_intra_doc_links --cfg docsrs OPENVINO_SKIP_LINKING: 1 steps: - uses: actions/checkout@v4 diff --git a/crates/runtime/src/sys/unix/machports.rs b/crates/runtime/src/sys/unix/machports.rs index 677579676d96..7ab1276fcd41 100644 --- a/crates/runtime/src/sys/unix/machports.rs +++ b/crates/runtime/src/sys/unix/machports.rs @@ -44,6 +44,7 @@ use mach::port::*; use mach::thread_act::*; use mach::traps::*; use std::mem; +use std::ptr::addr_of_mut; use std::thread; /// Other `mach` declarations awaiting @@ -180,7 +181,7 @@ pub unsafe fn platform_init() { // Allocate our WASMTIME_PORT and make sure that it can be sent to so we // can receive exceptions. let me = mach_task_self(); - let kret = mach_port_allocate(me, MACH_PORT_RIGHT_RECEIVE, &mut WASMTIME_PORT); + let kret = mach_port_allocate(me, MACH_PORT_RIGHT_RECEIVE, addr_of_mut!(WASMTIME_PORT)); assert_eq!(kret, KERN_SUCCESS, "failed to allocate port"); let kret = mach_port_insert_right(me, WASMTIME_PORT, WASMTIME_PORT, MACH_MSG_TYPE_MAKE_SEND); assert_eq!(kret, KERN_SUCCESS, "failed to insert right"); diff --git a/crates/wasi-common/cap-std-sync/src/lib.rs b/crates/wasi-common/cap-std-sync/src/lib.rs index 832c77cfa496..3b247c4cc89c 100644 --- a/crates/wasi-common/cap-std-sync/src/lib.rs +++ b/crates/wasi-common/cap-std-sync/src/lib.rs @@ -31,8 +31,6 @@ //! deps, so we will retain a sync implementation so that wasi-common users //! have an option of not pulling in an async runtime. -#![cfg_attr(io_lifetimes_use_std, feature(io_safety))] - pub mod clocks; pub mod dir; pub mod file; diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.toml index 748030977fbd..284547f3f8ee 100644 --- a/crates/wasmtime/Cargo.toml +++ b/crates/wasmtime/Cargo.toml @@ -14,7 +14,6 @@ rust-version.workspace = true workspace = true [package.metadata.docs.rs] -rustdoc-args = ["--cfg", "nightlydoc"] # Docs.rs will use the `component-model` feature for documentation; # so this feature also passed in to the `cargo doc` invocation in CI. # See .github/workflows/main.yml diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs index ff98cc3c4167..5f0275ad6c89 100644 --- a/crates/wasmtime/src/config.rs +++ b/crates/wasmtime/src/config.rs @@ -280,7 +280,7 @@ impl Config { /// /// This method will error if the given target triple is not supported. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn target(&mut self, target: &str) -> Result<&mut Self> { self.compiler_config.target = Some(target_lexicon::Triple::from_str(target).map_err(|e| anyhow::anyhow!(e))?); @@ -391,7 +391,7 @@ impl Config { /// it. If Wasmtime doesn't support exactly what you'd like just yet, please /// feel free to open an issue! #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn async_support(&mut self, enable: bool) -> &mut Self { self.async_support = enable; self @@ -668,7 +668,7 @@ impl Config { /// The `Engine::new` method will fail if the value for this option is /// smaller than the [`Config::max_wasm_stack`] option. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn async_stack_size(&mut self, size: usize) -> &mut Self { self.async_stack_size = size; self @@ -906,7 +906,7 @@ impl Config { /// /// The default value for this is `Strategy::Auto`. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn strategy(&mut self, strategy: Strategy) -> &mut Self { self.compiler_config.strategy = strategy; self @@ -940,7 +940,7 @@ impl Config { /// /// The default value for this is `false` #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn cranelift_debug_verifier(&mut self, enable: bool) -> &mut Self { let val = if enable { "true" } else { "false" }; self.compiler_config @@ -957,7 +957,7 @@ impl Config { /// /// The default value for this is `OptLevel::None`. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn cranelift_opt_level(&mut self, level: OptLevel) -> &mut Self { let val = match level { OptLevel::None => "none", @@ -979,7 +979,7 @@ impl Config { /// /// The default value for this is `false` #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn cranelift_nan_canonicalization(&mut self, enable: bool) -> &mut Self { let val = if enable { "true" } else { "false" }; self.compiler_config @@ -1002,7 +1002,7 @@ impl Config { /// over a trail of "breadcrumbs" or facts at each intermediate /// value. Thus, it is appropriate to enable in production. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn cranelift_pcc(&mut self, enable: bool) -> &mut Self { let val = if enable { "true" } else { "false" }; self.compiler_config @@ -1028,7 +1028,7 @@ impl Config { /// cause `Engine::new` fail if the flag's name does not exist, or the value is not appropriate /// for the flag type. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub unsafe fn cranelift_flag_enable(&mut self, flag: &str) -> &mut Self { self.compiler_config.flags.insert(flag.to_string()); self @@ -1054,7 +1054,7 @@ impl Config { /// For example, feature `wasm_backtrace` will set `unwind_info` to `true`, but if it's /// manually set to false then it will fail. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub unsafe fn cranelift_flag_set(&mut self, name: &str, value: &str) -> &mut Self { self.compiler_config .settings @@ -1081,7 +1081,7 @@ impl Config { /// /// [docs]: https://bytecodealliance.github.io/wasmtime/cli-cache.html #[cfg(feature = "cache")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "cache")))] + #[cfg_attr(docsrs, doc(cfg(feature = "cache")))] pub fn cache_config_load(&mut self, path: impl AsRef) -> Result<&mut Self> { self.cache_config = CacheConfig::from_file(Some(path.as_ref()))?; Ok(self) @@ -1098,7 +1098,7 @@ impl Config { /// This method is only available when the `cache` feature of this crate is /// enabled. #[cfg(feature = "cache")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "cache")))] + #[cfg_attr(docsrs, doc(cfg(feature = "cache")))] pub fn disable_cache(&mut self) -> &mut Self { self.cache_config = CacheConfig::new_cache_disabled(); self @@ -1126,7 +1126,7 @@ impl Config { /// /// [docs]: https://bytecodealliance.github.io/wasmtime/cli-cache.html #[cfg(feature = "cache")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "cache")))] + #[cfg_attr(docsrs, doc(cfg(feature = "cache")))] pub fn cache_config_load_default(&mut self) -> Result<&mut Self> { self.cache_config = CacheConfig::from_file(None)?; Ok(self) @@ -1147,7 +1147,7 @@ impl Config { /// Custom memory creators are used when creating creating async instance stacks for /// the on-demand instance allocation strategy. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn with_host_stack(&mut self, stack_creator: Arc) -> &mut Self { self.stack_creator = Some(Arc::new(StackCreatorProxy(stack_creator))); self @@ -1459,7 +1459,7 @@ impl Config { /// /// By default parallel compilation is enabled. #[cfg(feature = "parallel-compilation")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "parallel-compilation")))] + #[cfg_attr(docsrs, doc(cfg(feature = "parallel-compilation")))] pub fn parallel_compilation(&mut self, parallel: bool) -> &mut Self { self.parallel_compilation = parallel; self @@ -1553,7 +1553,7 @@ impl Config { /// /// This option is disabled by default. #[cfg(feature = "coredump")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "coredump")))] + #[cfg_attr(docsrs, doc(cfg(feature = "coredump")))] pub fn coredump_on_trap(&mut self, enable: bool) -> &mut Self { self.coredump_on_trap = enable; self @@ -2117,7 +2117,7 @@ impl PoolingAllocationConfig { /// /// [`call_async`]: crate::TypedFunc::call_async #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn async_stack_zeroing(&mut self, enable: bool) -> &mut Self { self.config.async_stack_zeroing = enable; self @@ -2135,7 +2135,7 @@ impl PoolingAllocationConfig { /// Note that when using this option the memory with async stacks will /// never be decommitted. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn async_stack_keep_resident(&mut self, size: usize) -> &mut Self { let size = round_up_to_pages(size as u64) as usize; self.config.async_stack_keep_resident = size; diff --git a/crates/wasmtime/src/engine.rs b/crates/wasmtime/src/engine.rs index 2a6aba471d1e..07140b9926f8 100644 --- a/crates/wasmtime/src/engine.rs +++ b/crates/wasmtime/src/engine.rs @@ -481,7 +481,7 @@ impl Engine { } #[cfg(any(feature = "cranelift", feature = "winch"))] -#[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] +#[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] impl Engine { pub(crate) fn compiler(&self) -> &dyn wasmtime_environ::Compiler { &*self.inner.compiler @@ -519,7 +519,7 @@ impl Engine { /// Same as [`Engine::precompile_module`] except for a /// [`Component`](crate::component::Component) #[cfg(feature = "component-model")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "component-model")))] + #[cfg_attr(docsrs, doc(cfg(feature = "component-model")))] pub fn precompile_component(&self, bytes: &[u8]) -> Result> { #[cfg(feature = "wat")] let bytes = wat::parse_bytes(&bytes)?; @@ -562,7 +562,7 @@ pub enum Precompiled { } #[cfg(feature = "runtime")] -#[cfg_attr(nightlydoc, doc(cfg(feature = "runtime")))] +#[cfg_attr(docsrs, doc(cfg(feature = "runtime")))] impl Engine { /// Eagerly initialize thread-local functionality shared by all [`Engine`]s. /// @@ -650,7 +650,7 @@ impl Engine { /// compatible [`Config`]s. If this Hash matches between two [`Engine`]s then binaries /// from one are guaranteed to deserialize in the other. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(feature = "cranelift")))] // see build.rs + #[cfg_attr(docsrs, doc(cfg(feature = "cranelift")))] // see build.rs pub fn precompile_compatibility_hash(&self) -> impl std::hash::Hash + '_ { crate::module::HashedEngineCompileEnv(self) } diff --git a/crates/wasmtime/src/lib.rs b/crates/wasmtime/src/lib.rs index 5f30104777cb..da007574f517 100644 --- a/crates/wasmtime/src/lib.rs +++ b/crates/wasmtime/src/lib.rs @@ -254,7 +254,7 @@ #![deny(missing_docs)] #![doc(test(attr(deny(warnings))))] #![doc(test(attr(allow(dead_code, unused_variables, unused_mut))))] -#![cfg_attr(nightlydoc, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(not(feature = "default"), allow(dead_code, unused_imports))] // Allow broken links when the default features is disabled because most of our // documentation is written for the "one build" of the `main` branch which has diff --git a/crates/wasmtime/src/profiling_agent.rs b/crates/wasmtime/src/profiling_agent.rs index 316f243627ad..dece223d3e1a 100644 --- a/crates/wasmtime/src/profiling_agent.rs +++ b/crates/wasmtime/src/profiling_agent.rs @@ -7,7 +7,7 @@ cfg_if::cfg_if! { pub use jitdump::new as new_jitdump; } else { pub fn new_jitdump() -> Result> { - if cfg!(feature = "jitdump") { + if cfg!(feature = "profiling") { bail!("jitdump is not supported on this platform"); } else { bail!("jitdump support disabled at compile time"); @@ -35,7 +35,7 @@ cfg_if::cfg_if! { pub use vtune::new as new_vtune; } else { pub fn new_vtune() -> Result> { - if cfg!(feature = "vtune") { + if cfg!(feature = "profiling") { bail!("VTune is not supported on this platform."); } else { bail!("VTune support disabled at compile time."); diff --git a/crates/wasmtime/src/runtime.rs b/crates/wasmtime/src/runtime.rs index fa7893f226c9..aeab6ca5146e 100644 --- a/crates/wasmtime/src/runtime.rs +++ b/crates/wasmtime/src/runtime.rs @@ -1,4 +1,4 @@ -#![cfg_attr(nightlydoc, doc(cfg(feature = "runtime")))] +#![cfg_attr(docsrs, doc(cfg(feature = "runtime")))] #[macro_use] pub(crate) mod func; diff --git a/crates/wasmtime/src/runtime/component/component.rs b/crates/wasmtime/src/runtime/component/component.rs index 9b03c8cc2da1..97ca94164afc 100644 --- a/crates/wasmtime/src/runtime/component/component.rs +++ b/crates/wasmtime/src/runtime/component/component.rs @@ -140,7 +140,7 @@ impl Component { /// # Ok(()) /// # } #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn new(engine: &Engine, bytes: impl AsRef<[u8]>) -> Result { let bytes = bytes.as_ref(); #[cfg(feature = "wat")] @@ -154,7 +154,7 @@ impl Component { /// This is a convenience function for reading the contents of `file` on /// disk and then calling [`Component::new`]. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn from_file(engine: &Engine, file: impl AsRef) -> Result { match Self::new( engine, @@ -185,7 +185,7 @@ impl Component { /// /// For more information on semantics and errors see [`Component::new`]. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn from_binary(engine: &Engine, binary: &[u8]) -> Result { use crate::compile::build_component_artifacts; use crate::module::HashedEngineCompileEnv; diff --git a/crates/wasmtime/src/runtime/component/func.rs b/crates/wasmtime/src/runtime/component/func.rs index 3088dec87221..4775f3b8d074 100644 --- a/crates/wasmtime/src/runtime/component/func.rs +++ b/crates/wasmtime/src/runtime/component/func.rs @@ -349,7 +349,7 @@ impl Func { /// only works with functions defined within an asynchronous store. Also /// panics if `store` does not own this function. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub async fn call_async( &self, mut store: impl AsContextMut, @@ -614,7 +614,7 @@ impl Func { /// Panics if this is called on a function in a synchronous store. This /// only works with functions defined within an asynchronous store. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub async fn post_return_async( &self, mut store: impl AsContextMut, diff --git a/crates/wasmtime/src/runtime/component/func/typed.rs b/crates/wasmtime/src/runtime/component/func/typed.rs index ba728f685aee..60bbcaeb4e79 100644 --- a/crates/wasmtime/src/runtime/component/func/typed.rs +++ b/crates/wasmtime/src/runtime/component/func/typed.rs @@ -170,7 +170,7 @@ where /// only works with functions defined within an asynchronous store. Also /// panics if `store` does not own this function. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub async fn call_async( &self, mut store: impl AsContextMut, @@ -336,7 +336,7 @@ where /// See [`Func::post_return_async`] #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub async fn post_return_async( &self, store: impl AsContextMut, diff --git a/crates/wasmtime/src/runtime/component/instance.rs b/crates/wasmtime/src/runtime/component/instance.rs index b90aee0bb6d4..1284c155624b 100644 --- a/crates/wasmtime/src/runtime/component/instance.rs +++ b/crates/wasmtime/src/runtime/component/instance.rs @@ -598,7 +598,7 @@ impl InstancePre { // // TODO: needs more docs #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub async fn instantiate_async( &self, mut store: impl AsContextMut, diff --git a/crates/wasmtime/src/runtime/component/linker.rs b/crates/wasmtime/src/runtime/component/linker.rs index 5f2eae185864..c994adc2e9d1 100644 --- a/crates/wasmtime/src/runtime/component/linker.rs +++ b/crates/wasmtime/src/runtime/component/linker.rs @@ -311,7 +311,7 @@ impl Linker { /// can return an error if something goes wrong during instantiation such as /// a runtime trap or a runtime limit being exceeded. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub async fn instantiate_async( &self, store: impl AsContextMut, @@ -377,7 +377,7 @@ impl LinkerInstance<'_, T> { /// This is exactly like [`Self::func_wrap`] except it takes an async /// host function. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn func_wrap_async(&mut self, name: &str, f: F) -> Result<()> where F: for<'a> Fn( @@ -456,7 +456,7 @@ impl LinkerInstance<'_, T> { /// This is exactly like [`Self::func_new`] except it takes an async /// host function. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn func_new_async(&mut self, component: &Component, name: &str, f: F) -> Result<()> where F: for<'a> Fn( diff --git a/crates/wasmtime/src/runtime/component/mod.rs b/crates/wasmtime/src/runtime/component/mod.rs index 821ef62590f9..187a3337d6b4 100644 --- a/crates/wasmtime/src/runtime/component/mod.rs +++ b/crates/wasmtime/src/runtime/component/mod.rs @@ -39,7 +39,7 @@ //! Model][Component Model] to get an overview about how to build components //! from various languages. -#![cfg_attr(nightlydoc, doc(cfg(feature = "component-model")))] +#![cfg_attr(docsrs, doc(cfg(feature = "component-model")))] mod component; mod func; diff --git a/crates/wasmtime/src/runtime/component/resources.rs b/crates/wasmtime/src/runtime/component/resources.rs index 624514d1ffe7..7de8a65cf2dc 100644 --- a/crates/wasmtime/src/runtime/component/resources.rs +++ b/crates/wasmtime/src/runtime/component/resources.rs @@ -636,7 +636,7 @@ impl ResourceAny { /// Same as [`ResourceAny::resource_drop`] except for use with async stores /// to execute the destructor asynchronously. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub async fn resource_drop_async(self, mut store: impl AsContextMut) -> Result<()> where T: Send, diff --git a/crates/wasmtime/src/runtime/externals/table.rs b/crates/wasmtime/src/runtime/externals/table.rs index f83c37f1c07e..b741beefd845 100644 --- a/crates/wasmtime/src/runtime/externals/table.rs +++ b/crates/wasmtime/src/runtime/externals/table.rs @@ -73,7 +73,7 @@ impl Table { Table::_new(store.as_context_mut().0, ty, init) } - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] /// Async variant of [`Table::new`]. You must use this variant with /// [`Store`](`crate::Store`)s which have a /// [`ResourceLimiterAsync`](`crate::ResourceLimiterAsync`). @@ -239,7 +239,7 @@ impl Table { } } - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] /// Async variant of [`Table::grow`]. Required when using a /// [`ResourceLimiterAsync`](`crate::ResourceLimiterAsync`). /// diff --git a/crates/wasmtime/src/runtime/func.rs b/crates/wasmtime/src/runtime/func.rs index 599fdc0d1ecb..b404e5fb9ba6 100644 --- a/crates/wasmtime/src/runtime/func.rs +++ b/crates/wasmtime/src/runtime/func.rs @@ -285,7 +285,7 @@ macro_rules! generate_wrap_async_func { /// This function will panic if called with a non-asynchronous store. #[allow(non_snake_case)] #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn []( store: impl AsContextMut, func: impl for<'a> Fn(Caller<'a, T>, $($args),*) -> Box + Send + 'a> + Send + Sync + 'static, @@ -357,7 +357,7 @@ impl Func { /// /// [`Trap`]: crate::Trap #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn new( store: impl AsContextMut, ty: FuncType, @@ -395,7 +395,7 @@ impl Func { /// the `func` provided correctly interprets the argument types provided to /// it, or that the results it produces will be of the correct type. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub unsafe fn new_unchecked( mut store: impl AsContextMut, ty: FuncType, @@ -476,7 +476,7 @@ impl Func { /// # } /// ``` #[cfg(all(feature = "async", feature = "cranelift"))] - #[cfg_attr(nightlydoc, doc(cfg(all(feature = "async", feature = "cranelift"))))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "async", feature = "cranelift"))))] pub fn new_async(store: impl AsContextMut, ty: FuncType, func: F) -> Func where F: for<'a> Fn( @@ -972,7 +972,7 @@ impl Func { /// only works with functions defined within an asynchronous store. Also /// panics if `store` does not own this function. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub async fn call_async( &self, mut store: impl AsContextMut, diff --git a/crates/wasmtime/src/runtime/func/typed.rs b/crates/wasmtime/src/runtime/func/typed.rs index 06ba1b87523e..df03653333e6 100644 --- a/crates/wasmtime/src/runtime/func/typed.rs +++ b/crates/wasmtime/src/runtime/func/typed.rs @@ -106,7 +106,7 @@ where /// /// [`Trap`]: crate::Trap #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub async fn call_async( &self, mut store: impl AsContextMut, diff --git a/crates/wasmtime/src/runtime/instance.rs b/crates/wasmtime/src/runtime/instance.rs index e23f79d708dd..914dba8b0e81 100644 --- a/crates/wasmtime/src/runtime/instance.rs +++ b/crates/wasmtime/src/runtime/instance.rs @@ -144,7 +144,7 @@ impl Instance { /// This function will also panic, like [`Instance::new`], if any [`Extern`] /// specified does not belong to `store`. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub async fn new_async( mut store: impl AsContextMut, module: &Module, @@ -880,7 +880,7 @@ impl InstancePre { /// Panics if any import closed over by this [`InstancePre`] isn't owned by /// `store`, or if `store` does not have async support enabled. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub async fn instantiate_async( &self, mut store: impl AsContextMut, diff --git a/crates/wasmtime/src/runtime/linker.rs b/crates/wasmtime/src/runtime/linker.rs index 45f9db687171..f8d457855722 100644 --- a/crates/wasmtime/src/runtime/linker.rs +++ b/crates/wasmtime/src/runtime/linker.rs @@ -140,7 +140,7 @@ macro_rules! generate_wrap_async_func { /// [`Func::wrapN_async`](crate::Func::wrap1_async). #[allow(non_snake_case)] #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn []<$($args,)* R>( &mut self, module: &str, @@ -275,7 +275,7 @@ impl Linker { /// # } /// ``` #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn define_unknown_imports_as_traps(&mut self, module: &Module) -> anyhow::Result<()> { for import in module.imports() { if let Err(import_err) = self._get_by_import(&import) { @@ -311,7 +311,7 @@ impl Linker { /// # } /// ``` #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn define_unknown_imports_as_default_values( &mut self, module: &Module, @@ -416,7 +416,7 @@ impl Linker { /// /// For more information see [`Linker::func_wrap`]. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn func_new( &mut self, module: &str, @@ -434,7 +434,7 @@ impl Linker { /// /// For more information see [`Linker::func_wrap`]. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub unsafe fn func_new_unchecked( &mut self, module: &str, @@ -452,7 +452,7 @@ impl Linker { /// /// For more information see [`Linker::func_wrap`]. #[cfg(all(feature = "async", feature = "cranelift"))] - #[cfg_attr(nightlydoc, doc(cfg(all(feature = "async", feature = "cranelift"))))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "async", feature = "cranelift"))))] pub fn func_new_async( &mut self, module: &str, @@ -754,7 +754,7 @@ impl Linker { /// # } /// ``` #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn module( &mut self, mut store: impl AsContextMut, @@ -825,7 +825,7 @@ impl Linker { /// /// This is the same as [`Linker::module`], except for async `Store`s. #[cfg(all(feature = "async", feature = "cranelift"))] - #[cfg_attr(nightlydoc, doc(cfg(all(feature = "async", feature = "cranelift"))))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "async", feature = "cranelift"))))] pub async fn module_async( &mut self, mut store: impl AsContextMut, @@ -1098,7 +1098,7 @@ impl Linker { /// Attempts to instantiate the `module` provided. This is the same as /// [`Linker::instantiate`], except for async `Store`s. #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub async fn instantiate_async( &self, mut store: impl AsContextMut, diff --git a/crates/wasmtime/src/runtime/memory.rs b/crates/wasmtime/src/runtime/memory.rs index 0a625ee2129b..ae81055ee1e9 100644 --- a/crates/wasmtime/src/runtime/memory.rs +++ b/crates/wasmtime/src/runtime/memory.rs @@ -238,7 +238,7 @@ impl Memory { Self::_new(store.as_context_mut().0, ty) } - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] /// Async variant of [`Memory::new`]. You must use this variant with /// [`Store`](`crate::Store`)s which have a /// [`ResourceLimiterAsync`](`crate::ResourceLimiterAsync`). @@ -520,7 +520,7 @@ impl Memory { } } - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] /// Async variant of [`Memory::grow`]. Required when using a /// [`ResourceLimiterAsync`](`crate::ResourceLimiterAsync`). /// diff --git a/crates/wasmtime/src/runtime/module.rs b/crates/wasmtime/src/runtime/module.rs index 79c0914f205f..70301e8074ca 100644 --- a/crates/wasmtime/src/runtime/module.rs +++ b/crates/wasmtime/src/runtime/module.rs @@ -237,7 +237,7 @@ impl Module { /// # } /// ``` #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn new(engine: &Engine, bytes: impl AsRef<[u8]>) -> Result { let bytes = bytes.as_ref(); #[cfg(feature = "wat")] @@ -274,7 +274,7 @@ impl Module { /// # } /// ``` #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn from_file(engine: &Engine, file: impl AsRef) -> Result { let file = file.as_ref(); match Self::new( @@ -329,7 +329,7 @@ impl Module { /// # } /// ``` #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn from_binary(engine: &Engine, binary: &[u8]) -> Result { use crate::{compile::build_artifacts, instantiate::MmapVecWrapper}; @@ -403,7 +403,7 @@ impl Module { /// reflect the current state of the file, not necessarily the original /// state of the file. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub unsafe fn from_trusted_file(engine: &Engine, file: impl AsRef) -> Result { let mmap = MmapVec::from_file(file.as_ref())?; if &mmap[0..4] == b"\x7fELF" { @@ -611,7 +611,7 @@ impl Module { /// this method can be useful to get the serialized version without /// compiling twice. #[cfg(any(feature = "cranelift", feature = "winch"))] - #[cfg_attr(nightlydoc, doc(cfg(any(feature = "cranelift", feature = "winch"))))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))] pub fn serialize(&self) -> Result> { // The current representation of compiled modules within a compiled // component means that it cannot be serialized. The mmap returned here diff --git a/crates/wasmtime/src/runtime/store.rs b/crates/wasmtime/src/runtime/store.rs index 513474f8b012..5de37b33cf51 100644 --- a/crates/wasmtime/src/runtime/store.rs +++ b/crates/wasmtime/src/runtime/store.rs @@ -712,7 +712,7 @@ impl Store { /// [`Store`] configured via /// [`Config::async_support`](crate::Config::async_support). #[cfg(feature = "async")] - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn limiter_async( &mut self, mut limiter: impl FnMut(&mut T) -> &mut (dyn crate::ResourceLimiterAsync) @@ -736,7 +736,7 @@ impl Store { inner.limiter = Some(ResourceLimiterInner::Async(Box::new(limiter))); } - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] /// Configures an async function that runs on calls and returns between /// WebAssembly and host code. For the non-async equivalent of this method, /// see [`Store::call_hook`]. @@ -952,7 +952,7 @@ impl Store { self.inner.epoch_deadline_callback(Box::new(callback)); } - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] /// Configures epoch-deadline expiration to yield to the async /// caller and the update the deadline. /// @@ -1069,7 +1069,7 @@ impl<'a, T> StoreContextMut<'a, T> { self.0.epoch_deadline_trap(); } - #[cfg_attr(nightlydoc, doc(cfg(feature = "async")))] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] /// Configures epoch-deadline expiration to yield to the async /// caller and the update the deadline. /// diff --git a/crates/wit-bindgen/src/rust.rs b/crates/wit-bindgen/src/rust.rs index 009bebffbbe8..94226dea2a6a 100644 --- a/crates/wit-bindgen/src/rust.rs +++ b/crates/wit-bindgen/src/rust.rs @@ -286,75 +286,6 @@ pub trait RustGenerator<'a> { result } - /// Writes the camel-cased 'name' of the passed type to `out`, as used to name union variants. - fn write_name(&self, ty: &Type, out: &mut String) { - match ty { - Type::Bool => out.push_str("Bool"), - Type::U8 => out.push_str("U8"), - Type::U16 => out.push_str("U16"), - Type::U32 => out.push_str("U32"), - Type::U64 => out.push_str("U64"), - Type::S8 => out.push_str("I8"), - Type::S16 => out.push_str("I16"), - Type::S32 => out.push_str("I32"), - Type::S64 => out.push_str("I64"), - Type::Float32 => out.push_str("F32"), - Type::Float64 => out.push_str("F64"), - Type::Char => out.push_str("Char"), - Type::String => out.push_str("String"), - Type::Id(id) => { - let ty = &self.resolve().types[*id]; - match &ty.name { - Some(name) => out.push_str(&name.to_upper_camel_case()), - None => match &ty.kind { - TypeDefKind::Option(ty) => { - out.push_str("Optional"); - self.write_name(ty, out); - } - TypeDefKind::Result(_) => out.push_str("Result"), - TypeDefKind::Tuple(_) => out.push_str("Tuple"), - TypeDefKind::List(ty) => { - self.write_name(ty, out); - out.push_str("List") - } - TypeDefKind::Future(ty) => { - self.write_optional_name(ty.as_ref(), out); - out.push_str("Future"); - } - TypeDefKind::Stream(s) => { - self.write_optional_name(s.element.as_ref(), out); - self.write_optional_name(s.end.as_ref(), out); - out.push_str("Stream"); - } - - TypeDefKind::Type(ty) => self.write_name(ty, out), - TypeDefKind::Record(_) => out.push_str("Record"), - TypeDefKind::Flags(_) => out.push_str("Flags"), - TypeDefKind::Variant(_) => out.push_str("Variant"), - TypeDefKind::Enum(_) => out.push_str("Enum"), - TypeDefKind::Handle(Handle::Borrow(id)) => { - out.push_str("Borrow"); - self.write_name(&Type::Id(*id), out); - } - TypeDefKind::Handle(Handle::Own(id)) => { - out.push_str("Own"); - self.write_name(&Type::Id(*id), out); - } - TypeDefKind::Resource => unreachable!(), - TypeDefKind::Unknown => unreachable!(), - }, - } - } - } - } - - fn write_optional_name(&self, ty: Option<&Type>, out: &mut String) { - match ty { - Some(ty) => self.write_name(ty, out), - None => out.push_str("()"), - } - } - fn param_name(&self, ty: TypeId) -> String { let info = self.info(ty); let name = self.resolve().types[ty]