Browse Source

Use rustdoc's `doc_auto_cfg` feature instead of `doc_cfg` (#8532)

This commit removes all our `#[cfg_attr(..., doc(cfg(...)))]`
annotations throughout Wasmtime and `wasmtime-wasi`. These are all
replaced with `feature(doc_auto_cfg)` which automatically infers the
attribute to show rather than requiring us to duplicate it.
Spot-checking the docs this looks just-as-readable while being much
easier to maintain over time.
pull/8542/head
Alex Crichton 6 months ago
committed by GitHub
parent
commit
964f8986ff
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      crates/wasi/src/ctx.rs
  2. 2
      crates/wasi/src/lib.rs
  3. 2
      crates/wasi/src/preview0.rs
  4. 2
      crates/wasi/src/preview1.rs
  5. 1
      crates/wasmtime/src/compile/code_builder.rs
  6. 5
      crates/wasmtime/src/compile/runtime.rs
  7. 23
      crates/wasmtime/src/config.rs
  8. 4
      crates/wasmtime/src/engine.rs
  9. 2
      crates/wasmtime/src/lib.rs
  10. 2
      crates/wasmtime/src/runtime.rs
  11. 3
      crates/wasmtime/src/runtime/component/component.rs
  12. 2
      crates/wasmtime/src/runtime/component/func.rs
  13. 2
      crates/wasmtime/src/runtime/component/func/typed.rs
  14. 1
      crates/wasmtime/src/runtime/component/instance.rs
  15. 3
      crates/wasmtime/src/runtime/component/linker.rs
  16. 1
      crates/wasmtime/src/runtime/component/mod.rs
  17. 1
      crates/wasmtime/src/runtime/component/resources.rs
  18. 2
      crates/wasmtime/src/runtime/externals/table.rs
  19. 7
      crates/wasmtime/src/runtime/func.rs
  20. 1
      crates/wasmtime/src/runtime/func/typed.rs
  21. 2
      crates/wasmtime/src/runtime/instance.rs
  22. 9
      crates/wasmtime/src/runtime/linker.rs
  23. 3
      crates/wasmtime/src/runtime/memory.rs
  24. 5
      crates/wasmtime/src/runtime/module.rs
  25. 4
      crates/wasmtime/src/runtime/store.rs

1
crates/wasi/src/ctx.rs

@ -515,7 +515,6 @@ impl WasiCtxBuilder {
/// usage of this method is not allowed and should use a second builder
/// instead.
#[cfg(feature = "preview1")]
#[cfg_attr(docsrs, doc(cfg(feature = "preview1")))]
pub fn build_p1(&mut self) -> crate::preview1::WasiP1Ctx {
let wasi = self.build();
crate::preview1::WasiP1Ctx::new(wasi)

2
crates/wasi/src/lib.rs

@ -178,7 +178,7 @@
//! [`wasi:sockets/udp`]: bindings::sockets::udp::Host
//! [async]: https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.async_support
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
use wasmtime::component::Linker;

2
crates/wasi/src/preview0.rs

@ -3,8 +3,6 @@
//! This module is purely here for backwards compatibility in the Wasmtime CLI.
//! You probably want to use [`preview1`](crate::preview1) instead.
#![cfg_attr(docsrs, doc(cfg(feature = "preview1")))]
use crate::preview0::types::Error;
use crate::preview1::types as snapshot1_types;
use crate::preview1::wasi_snapshot_preview1::WasiSnapshotPreview1 as Snapshot1;

2
crates/wasi/src/preview1.rs

@ -63,8 +63,6 @@
//! }
//! ```
#![cfg_attr(docsrs, doc(cfg(feature = "preview1")))]
use crate::bindings::{
cli::{
stderr, stdin, stdout, terminal_input, terminal_output, terminal_stderr, terminal_stdin,

1
crates/wasmtime/src/compile/code_builder.rs

@ -239,7 +239,6 @@ impl<'a> CodeBuilder<'a> {
/// compiles a serialized [`Component`](crate::component::Component)
/// instead of a module.
#[cfg(feature = "component-model")]
#[cfg_attr(docsrs, doc(cfg(feature = "component-model")))]
pub fn compile_component_serialized(&self) -> Result<Vec<u8>> {
let bytes = self.wasm_binary()?;
let (v, _) = super::build_component_artifacts(self.engine, &bytes, None)?;

5
crates/wasmtime/src/compile/runtime.rs

@ -78,7 +78,6 @@ impl<'a> CodeBuilder<'a> {
///
/// Note that this method will cache compilations if the `cache` feature is
/// enabled and turned on in [`Config`](crate::Config).
#[cfg_attr(docsrs, doc(cfg(feature = "runtime")))]
pub fn compile_module(&self) -> Result<Module> {
let (code, info_and_types) = self.compile_cached(super::build_artifacts)?;
Module::from_parts(self.engine, code, info_and_types)
@ -87,10 +86,6 @@ impl<'a> CodeBuilder<'a> {
/// Same as [`CodeBuilder::compile_module`] except that it compiles a
/// [`Component`] instead of a module.
#[cfg(feature = "component-model")]
#[cfg_attr(
docsrs,
doc(cfg(all(feature = "runtime", feature = "component-model")))
)]
pub fn compile_component(&self) -> Result<Component> {
let (code, artifacts) = self.compile_cached(super::build_component_artifacts)?;
Component::from_parts(self.engine, code, artifacts)

23
crates/wasmtime/src/config.rs

@ -303,7 +303,6 @@ impl Config {
///
/// This method will error if the given target triple is not supported.
#[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))?);
@ -414,7 +413,6 @@ 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(docsrs, doc(cfg(feature = "async")))]
pub fn async_support(&mut self, enable: bool) -> &mut Self {
self.async_support = enable;
self
@ -691,7 +689,6 @@ 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(docsrs, doc(cfg(feature = "async")))]
pub fn async_stack_size(&mut self, size: usize) -> &mut Self {
self.async_stack_size = size;
self
@ -732,7 +729,6 @@ impl Config {
/// [threads]: https://github.com/webassembly/threads
/// [wasi-threads]: https://github.com/webassembly/wasi-threads
#[cfg(feature = "threads")]
#[cfg_attr(docsrs, doc(cfg(feature = "threads")))]
pub fn wasm_threads(&mut self, enable: bool) -> &mut Self {
self.features.set(WasmFeatures::THREADS, enable);
self
@ -755,7 +751,6 @@ impl Config {
///
/// [proposal]: https://github.com/webassembly/reference-types
#[cfg(feature = "gc")]
#[cfg_attr(docsrs, doc(cfg(feature = "gc")))]
pub fn wasm_reference_types(&mut self, enable: bool) -> &mut Self {
self.features.set(WasmFeatures::REFERENCE_TYPES, enable);
self
@ -775,7 +770,6 @@ impl Config {
///
/// [proposal]: https://github.com/WebAssembly/function-references
#[cfg(feature = "gc")]
#[cfg_attr(docsrs, doc(cfg(feature = "gc")))]
pub fn wasm_function_references(&mut self, enable: bool) -> &mut Self {
self.features.set(WasmFeatures::FUNCTION_REFERENCES, enable);
self
@ -797,7 +791,6 @@ impl Config {
///
/// [proposal]: https://github.com/WebAssembly/gc
#[cfg(feature = "gc")]
#[cfg_attr(docsrs, doc(cfg(feature = "gc")))]
pub fn wasm_gc(&mut self, enable: bool) -> &mut Self {
self.features.set(WasmFeatures::GC, enable);
self
@ -1010,7 +1003,6 @@ impl Config {
///
/// The default value for this is `Strategy::Auto`.
#[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
@ -1044,7 +1036,6 @@ impl Config {
///
/// The default value for this is `false`
#[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
@ -1061,7 +1052,6 @@ impl Config {
///
/// The default value for this is `OptLevel::None`.
#[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",
@ -1088,7 +1078,6 @@ impl Config {
///
/// The default value for this is `false`
#[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
@ -1111,7 +1100,6 @@ 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(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
@ -1137,7 +1125,6 @@ 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(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
@ -1163,7 +1150,6 @@ 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(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
@ -1190,7 +1176,6 @@ impl Config {
///
/// [docs]: https://bytecodealliance.github.io/wasmtime/cli-cache.html
#[cfg(feature = "cache")]
#[cfg_attr(docsrs, doc(cfg(feature = "cache")))]
pub fn cache_config_load(&mut self, path: impl AsRef<Path>) -> Result<&mut Self> {
self.cache_config = CacheConfig::from_file(Some(path.as_ref()))?;
Ok(self)
@ -1207,7 +1192,6 @@ impl Config {
/// This method is only available when the `cache` feature of this crate is
/// enabled.
#[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
@ -1235,7 +1219,6 @@ impl Config {
///
/// [docs]: https://bytecodealliance.github.io/wasmtime/cli-cache.html
#[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)
@ -1256,7 +1239,6 @@ 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(docsrs, doc(cfg(feature = "async")))]
pub fn with_host_stack(&mut self, stack_creator: Arc<dyn StackCreator>) -> &mut Self {
self.stack_creator = Some(Arc::new(StackCreatorProxy(stack_creator)));
self
@ -1568,7 +1550,6 @@ impl Config {
///
/// By default parallel compilation is enabled.
#[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
@ -1672,7 +1653,6 @@ impl Config {
///
/// This option is disabled by default.
#[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
@ -2372,7 +2352,6 @@ impl PoolingAllocationConfig {
///
/// [`call_async`]: crate::TypedFunc::call_async
#[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
@ -2390,7 +2369,6 @@ impl PoolingAllocationConfig {
/// Note that when using this option the memory with async stacks will
/// never be decommitted.
#[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;
@ -2770,7 +2748,6 @@ impl PoolingAllocationConfig {
/// entry in the pool contains the space needed for each GC heap used by a
/// store.
#[cfg(feature = "gc")]
#[cfg_attr(docsrs, doc(cfg(feature = "gc")))]
pub fn total_gc_heaps(&mut self, count: u32) -> &mut Self {
self.config.limits.total_gc_heaps = count;
self

4
crates/wasmtime/src/engine.rs

@ -496,7 +496,6 @@ impl Engine {
}
#[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
@ -533,7 +532,6 @@ impl Engine {
/// Same as [`Engine::precompile_module`] except for a
/// [`Component`](crate::component::Component)
#[cfg(feature = "component-model")]
#[cfg_attr(docsrs, doc(cfg(feature = "component-model")))]
pub fn precompile_component(&self, bytes: &[u8]) -> Result<Vec<u8>> {
crate::CodeBuilder::new(self)
.wasm(bytes, None)?
@ -575,7 +573,6 @@ pub enum Precompiled {
}
#[cfg(feature = "runtime")]
#[cfg_attr(docsrs, doc(cfg(feature = "runtime")))]
impl Engine {
/// Eagerly initialize thread-local functionality shared by all [`Engine`]s.
///
@ -667,7 +664,6 @@ 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(docsrs, doc(cfg(feature = "cranelift")))] // see build.rs
pub fn precompile_compatibility_hash(&self) -> impl std::hash::Hash + '_ {
crate::compile::HashedEngineCompileEnv(self)
}

2
crates/wasmtime/src/lib.rs

@ -262,7 +262,7 @@
#![deny(missing_docs)]
#![doc(test(attr(deny(warnings))))]
#![doc(test(attr(allow(dead_code, unused_variables, unused_mut))))]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_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

2
crates/wasmtime/src/runtime.rs

@ -1,5 +1,3 @@
#![cfg_attr(docsrs, doc(cfg(feature = "runtime")))]
#[macro_use]
pub(crate) mod func;

3
crates/wasmtime/src/runtime/component/component.rs

@ -147,7 +147,6 @@ impl Component {
/// # Ok(())
/// # }
#[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<Component> {
crate::CodeBuilder::new(engine)
.wasm(bytes.as_ref(), None)?
@ -160,7 +159,6 @@ 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(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))]
pub fn from_file(engine: &Engine, file: impl AsRef<Path>) -> Result<Component> {
crate::CodeBuilder::new(engine)
.wasm_file(file.as_ref())?
@ -177,7 +175,6 @@ impl Component {
///
/// For more information on semantics and errors see [`Component::new`].
#[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<Component> {
crate::CodeBuilder::new(engine)
.wasm(binary, None)?

2
crates/wasmtime/src/runtime/component/func.rs

@ -349,7 +349,6 @@ 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(docsrs, doc(cfg(feature = "async")))]
pub async fn call_async<T>(
&self,
mut store: impl AsContextMut<Data = T>,
@ -609,7 +608,6 @@ 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(docsrs, doc(cfg(feature = "async")))]
pub async fn post_return_async<T: Send>(
&self,
mut store: impl AsContextMut<Data = T>,

2
crates/wasmtime/src/runtime/component/func/typed.rs

@ -170,7 +170,6 @@ where
/// only works with functions defined within an asynchronous store. Also
/// panics if `store` does not own this function.
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub async fn call_async<T>(
&self,
mut store: impl AsContextMut<Data = T>,
@ -336,7 +335,6 @@ where
/// See [`Func::post_return_async`]
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub async fn post_return_async<T: Send>(
&self,
store: impl AsContextMut<Data = T>,

1
crates/wasmtime/src/runtime/component/instance.rs

@ -591,7 +591,6 @@ impl<T> InstancePre<T> {
//
// TODO: needs more docs
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub async fn instantiate_async(
&self,
mut store: impl AsContextMut<Data = T>,

3
crates/wasmtime/src/runtime/component/linker.rs

@ -319,7 +319,6 @@ impl<T> Linker<T> {
/// 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(docsrs, doc(cfg(feature = "async")))]
pub async fn instantiate_async(
&self,
store: impl AsContextMut<Data = T>,
@ -384,7 +383,6 @@ impl<T> LinkerInstance<'_, T> {
/// This is exactly like [`Self::func_wrap`] except it takes an async
/// host function.
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub fn func_wrap_async<Params, Return, F>(&mut self, name: &str, f: F) -> Result<()>
where
F: for<'a> Fn(
@ -522,7 +520,6 @@ impl<T> LinkerInstance<'_, T> {
/// This is exactly like [`Self::func_new`] except it takes an async
/// host function.
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub fn func_new_async<F>(&mut self, name: &str, f: F) -> Result<()>
where
F: for<'a> Fn(

1
crates/wasmtime/src/runtime/component/mod.rs

@ -97,7 +97,6 @@
//!
//! See the docs for [`bindgen!`] for more information on how to use it.
#![cfg_attr(docsrs, doc(cfg(feature = "component-model")))]
// rustdoc appears to lie about a warning above, so squelch it for now.
#![allow(rustdoc::redundant_explicit_links)]

1
crates/wasmtime/src/runtime/component/resources.rs

@ -978,7 +978,6 @@ impl ResourceAny {
/// Same as [`ResourceAny::resource_drop`] except for use with async stores
/// to execute the destructor asynchronously.
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub async fn resource_drop_async<T>(self, mut store: impl AsContextMut<Data = T>) -> Result<()>
where
T: Send,

2
crates/wasmtime/src/runtime/externals/table.rs

@ -77,7 +77,6 @@ impl Table {
Table::_new(store.as_context_mut().0, ty, init)
}
#[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`).
@ -265,7 +264,6 @@ impl Table {
}
}
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
/// Async variant of [`Table::grow`]. Required when using a
/// [`ResourceLimiterAsync`](`crate::ResourceLimiterAsync`).
///

7
crates/wasmtime/src/runtime/func.rs

@ -368,7 +368,6 @@ 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(docsrs, doc(cfg(feature = "async")))]
pub fn [<wrap $num _async>]<T, $($args,)* R>(
store: impl AsContextMut<Data = T>,
func: impl for<'a> Fn(Caller<'a, T>, $($args),*) -> Box<dyn Future<Output = R> + Send + 'a> + Send + Sync + 'static,
@ -445,7 +444,6 @@ impl Func {
/// Panics if the given function type is not associated with this store's
/// engine.
#[cfg(any(feature = "cranelift", feature = "winch"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))]
pub fn new<T>(
store: impl AsContextMut<Data = T>,
ty: FuncType,
@ -489,7 +487,6 @@ impl Func {
/// Panics if the given function type is not associated with this store's
/// engine.
#[cfg(any(feature = "cranelift", feature = "winch"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))]
pub unsafe fn new_unchecked<T>(
mut store: impl AsContextMut<Data = T>,
ty: FuncType,
@ -574,7 +571,6 @@ impl Func {
/// # }
/// ```
#[cfg(all(feature = "async", feature = "cranelift"))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "async", feature = "cranelift"))))]
pub fn new_async<T, F>(store: impl AsContextMut<Data = T>, ty: FuncType, func: F) -> Func
where
F: for<'a> Fn(
@ -1113,7 +1109,6 @@ 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(docsrs, doc(cfg(feature = "async")))]
pub async fn call_async<T>(
&self,
mut store: impl AsContextMut<Data = T>,
@ -2080,7 +2075,6 @@ impl<T> Caller<'_, T> {
///
/// Same as [`Store::gc`](crate::Store::gc).
#[cfg(feature = "gc")]
#[cfg_attr(docsrs, doc(cfg(feature = "gc")))]
pub fn gc(&mut self) {
self.store.gc()
}
@ -2089,7 +2083,6 @@ impl<T> Caller<'_, T> {
///
/// Same as [`Store::gc_async`](crate::Store::gc_async).
#[cfg(all(feature = "async", feature = "gc"))]
#[cfg_attr(docsrs, doc(cfg(feature = "gc")))]
pub async fn gc_async(&mut self)
where
T: Send,

1
crates/wasmtime/src/runtime/func/typed.rs

@ -125,7 +125,6 @@ where
///
/// [`Trap`]: crate::Trap
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub async fn call_async<T>(
&self,
mut store: impl AsContextMut<Data = T>,

2
crates/wasmtime/src/runtime/instance.rs

@ -145,7 +145,6 @@ impl Instance {
/// This function will also panic, like [`Instance::new`], if any [`Extern`]
/// specified does not belong to `store`.
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub async fn new_async<T>(
mut store: impl AsContextMut<Data = T>,
module: &Module,
@ -888,7 +887,6 @@ impl<T> InstancePre<T> {
/// 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(docsrs, doc(cfg(feature = "async")))]
pub async fn instantiate_async(
&self,
mut store: impl AsContextMut<Data = T>,

9
crates/wasmtime/src/runtime/linker.rs

@ -140,7 +140,6 @@ macro_rules! generate_wrap_async_func {
/// [`Func::wrapN_async`](crate::Func::wrap1_async).
#[allow(non_snake_case)]
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub fn [<func_wrap $num _async>]<$($args,)* R>(
&mut self,
module: &str,
@ -275,7 +274,6 @@ impl<T> Linker<T> {
/// # }
/// ```
#[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 +309,6 @@ impl<T> Linker<T> {
/// # }
/// ```
#[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,
@ -430,7 +427,6 @@ impl<T> Linker<T> {
/// Panics if the given function type is not associated with the same engine
/// as this linker.
#[cfg(any(feature = "cranelift", feature = "winch"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))]
pub fn func_new(
&mut self,
module: &str,
@ -454,7 +450,6 @@ impl<T> Linker<T> {
/// Panics if the given function type is not associated with the same engine
/// as this linker.
#[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,
@ -483,7 +478,6 @@ impl<T> Linker<T> {
/// * If the given function type is not associated with the same engine as
/// this linker.
#[cfg(all(feature = "async", feature = "cranelift"))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "async", feature = "cranelift"))))]
pub fn func_new_async<F>(
&mut self,
module: &str,
@ -786,7 +780,6 @@ impl<T> Linker<T> {
/// # }
/// ```
#[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<Data = T>,
@ -857,7 +850,6 @@ impl<T> Linker<T> {
///
/// This is the same as [`Linker::module`], except for async `Store`s.
#[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<Data = T>,
@ -1130,7 +1122,6 @@ impl<T> Linker<T> {
/// Attempts to instantiate the `module` provided. This is the same as
/// [`Linker::instantiate`], except for async `Store`s.
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub async fn instantiate_async(
&self,
mut store: impl AsContextMut<Data = T>,

3
crates/wasmtime/src/runtime/memory.rs

@ -237,7 +237,6 @@ impl Memory {
Self::_new(store.as_context_mut().0, ty)
}
#[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`).
@ -519,7 +518,6 @@ impl Memory {
}
}
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
/// Async variant of [`Memory::grow`]. Required when using a
/// [`ResourceLimiterAsync`](`crate::ResourceLimiterAsync`).
///
@ -726,7 +724,6 @@ impl SharedMemory {
/// `maximum` number of 64K-sized pages. This call allocates the necessary
/// pages on the system.
#[cfg(feature = "threads")]
#[cfg_attr(docsrs, doc(cfg(feature = "threads")))]
pub fn new(engine: &Engine, ty: MemoryType) -> Result<Self> {
if !ty.is_shared() {
bail!("shared memory must have the `shared` flag enabled on its memory type")

5
crates/wasmtime/src/runtime/module.rs

@ -235,7 +235,6 @@ impl Module {
/// # }
/// ```
#[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<Module> {
crate::CodeBuilder::new(engine)
.wasm(bytes.as_ref(), None)?
@ -271,7 +270,6 @@ impl Module {
/// # }
/// ```
#[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<Path>) -> Result<Module> {
crate::CodeBuilder::new(engine)
.wasm_file(file.as_ref())?
@ -310,7 +308,6 @@ impl Module {
/// # }
/// ```
#[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<Module> {
crate::CodeBuilder::new(engine)
.wasm(binary, None)?
@ -340,7 +337,6 @@ 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(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))]
pub unsafe fn from_trusted_file(engine: &Engine, file: impl AsRef<Path>) -> Result<Module> {
let mmap = MmapVec::from_file(file.as_ref())?;
if &mmap[0..4] == b"\x7fELF" {
@ -550,7 +546,6 @@ impl Module {
/// this method can be useful to get the serialized version without
/// compiling twice.
#[cfg(any(feature = "cranelift", feature = "winch"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "cranelift", feature = "winch"))))]
pub fn serialize(&self) -> Result<Vec<u8>> {
// The current representation of compiled modules within a compiled
// component means that it cannot be serialized. The mmap returned here

4
crates/wasmtime/src/runtime/store.rs

@ -710,7 +710,6 @@ impl<T> Store<T> {
/// [`Store`] configured via
/// [`Config::async_support`](crate::Config::async_support).
#[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)
@ -734,7 +733,6 @@ impl<T> Store<T> {
inner.limiter = Some(ResourceLimiterInner::Async(Box::new(limiter)));
}
#[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`].
@ -968,7 +966,6 @@ impl<T> Store<T> {
self.inner.epoch_deadline_callback(Box::new(callback));
}
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
/// Configures epoch-deadline expiration to yield to the async
/// caller and the update the deadline.
///
@ -1101,7 +1098,6 @@ impl<'a, T> StoreContextMut<'a, T> {
self.0.epoch_deadline_trap();
}
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
/// Configures epoch-deadline expiration to yield to the async
/// caller and the update the deadline.
///

Loading…
Cancel
Save