Repository: bytecodealliance/wasmtime
Pull request #8258 (2024-03-28 15:53:30)

Fix rustdoc warnings on Nightly
I noticed during a failed doc build of another PR we've got a number of warnings being emitted, so resolve all those here.

<!--
Please make sure you include the following information:

- If this work has been discussed elsewhere, please include a link to that
  conversation. If it was discussed in an issue, just mention "issue #...".

- Explain why this change is needed. If the details are in an issue already,
  this can be brief.

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->


github-actions[bot]: #### Subscribe to Label Action

cc @peterhuene

<details>
This issue or pull request has been labeled: "cranelift", "cranelift:area:machinst", "wasmtime:api"

Thus the following users have been cc'd because of the following labels:

* peterhuene: wasmtime:api

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

[Learn more.](https://github.com/bytecodealliance/subscribe-to-label-action)
</details>

Patch:
diff --git a/cranelift/codegen/src/binemit/mod.rs b/cranelift/codegen/src/binemit/mod.rs
index 14509736e..498459026 100644
--- a/cranelift/codegen/src/binemit/mod.rs
+++ b/cranelift/codegen/src/binemit/mod.rs
@@ -97,25 +97,25 @@ pub enum Reloc {
     /// The non-PLT version of this relocation has been deprecated.
     ///
     /// This is the `R_RISCV_CALL_PLT` relocation from the RISC-V ELF psABI document.
-    /// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#procedure-calls
+    /// <https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#procedure-calls>
     RiscvCallPlt,
 
     /// RISC-V TLS GD: High 20 bits of 32-bit PC-relative TLS GD GOT reference,
     ///
     /// This is the `R_RISCV_TLS_GD_HI20` relocation from the RISC-V ELF psABI document.
-    /// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#global-dynamic
+    /// <https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#global-dynamic>
     RiscvTlsGdHi20,
 
     /// Low 12 bits of a 32-bit PC-relative relocation (I-Type instruction)
     ///
     /// This is the `R_RISCV_PCREL_LO12_I` relocation from the RISC-V ELF psABI document.
-    /// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#pc-relative-symbol-addresses
+    /// <https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#pc-relative-symbol-addresses>
     RiscvPCRelLo12I,
 
     /// High 20 bits of a 32-bit PC-relative GOT offset relocation
     ///
     /// This is the `R_RISCV_GOT_HI20` relocation from the RISC-V ELF psABI document.
-    /// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#pc-relative-symbol-addresses
+    /// <https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#pc-relative-symbol-addresses>
     RiscvGotHi20,
 
     /// s390x TLS GD64 - 64-bit offset of tls_index for GD symbol in GOT
diff --git a/cranelift/codegen/src/ir/constant.rs b/cranelift/codegen/src/ir/constant.rs
index aa266a1f9..5c50afd78 100644
--- a/cranelift/codegen/src/ir/constant.rs
+++ b/cranelift/codegen/src/ir/constant.rs
@@ -165,8 +165,8 @@ impl FromStr for ConstantData {
     }
 }
 
-/// Maintains the mapping between a constant handle (i.e.  [`Constant`](crate::ir::Constant)) and
-/// its constant data (i.e.  [`ConstantData`](crate::ir::ConstantData)).
+/// Maintains the mapping between a constant handle (i.e.  [`Constant`]) and
+/// its constant data (i.e.  [`ConstantData`]).
 #[derive(Clone, PartialEq, Hash)]
 #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
 pub struct ConstantPool {
diff --git a/cranelift/codegen/src/ir/entities.rs b/cranelift/codegen/src/ir/entities.rs
index 428468252..e8f5212fa 100644
--- a/cranelift/codegen/src/ir/entities.rs
+++ b/cranelift/codegen/src/ir/entities.rs
@@ -174,7 +174,7 @@ impl DynamicType {
 
 /// An opaque reference to a global value.
 ///
-/// A `GlobalValue` is a [`Value`](Value) that will be live across the entire
+/// A `GlobalValue` is a [`Value`] that will be live across the entire
 /// function lifetime. It can be preloaded from other global values.
 ///
 /// You can create a `GlobalValue` in the following ways:
diff --git a/cranelift/codegen/src/isa/riscv64/inst/encode.rs b/cranelift/codegen/src/isa/riscv64/inst/encode.rs
index ebf26ca52..4ad7d46e3 100644
--- a/cranelift/codegen/src/isa/riscv64/inst/encode.rs
+++ b/cranelift/codegen/src/isa/riscv64/inst/encode.rs
@@ -1,7 +1,7 @@
 //! Contains the RISC-V instruction encoding logic.
 //!
 //! These formats are specified in the RISC-V specification in section 2.2.
-//! See: https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf
+//! See: <https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf>
 //!
 //! Some instructions especially in extensions have slight variations from
 //! the base RISC-V specification.
diff --git a/cranelift/codegen/src/machinst/vcode.rs b/cranelift/codegen/src/machinst/vcode.rs
index f9b4c6fe3..d246a31dd 100644
--- a/cranelift/codegen/src/machinst/vcode.rs
+++ b/cranelift/codegen/src/machinst/vcode.rs
@@ -1652,7 +1652,7 @@ impl<I: VCodeInst> VRegAllocator<I> {
 /// [MachBuffer].
 ///
 /// First, during the lowering phase, constants are inserted using
-/// [VCodeConstants.insert]; an intermediate handle, [VCodeConstant], tracks what constants are
+/// [VCodeConstants.insert]; an intermediate handle, `VCodeConstant`, tracks what constants are
 /// used in this phase. Some deduplication is performed, when possible, as constant
 /// values are inserted.
 ///
@@ -1718,12 +1718,12 @@ impl VCodeConstants {
         self.constants.len()
     }
 
-    /// Iterate over the [VCodeConstant] keys inserted in this structure.
+    /// Iterate over the `VCodeConstant` keys inserted in this structure.
     pub fn keys(&self) -> Keys<VCodeConstant> {
         self.constants.keys()
     }
 
-    /// Iterate over the [VCodeConstant] keys and the data (as a byte slice) inserted in this
+    /// Iterate over the `VCodeConstant` keys and the data (as a byte slice) inserted in this
     /// structure.
     pub fn iter(&self) -> impl Iterator<Item = (VCodeConstant, &VCodeConstantData)> {
         self.constants.iter()
diff --git a/cranelift/interpreter/src/environment.rs b/cranelift/interpreter/src/environment.rs
index ab10dc9db..63cd61d8e 100644
--- a/cranelift/interpreter/src/environment.rs
+++ b/cranelift/interpreter/src/environment.rs
@@ -10,7 +10,7 @@ pub struct FunctionStore<'a> {
     function_names: HashMap<String, FuncIndex>,
 }
 
-/// An opaque reference to a [`Function`](Function) stored in the [FunctionStore].
+/// An opaque reference to a [`Function`] stored in the [FunctionStore].
 #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
 pub struct FuncIndex(u32);
 entity_impl!(FuncIndex, "fn");
diff --git a/cranelift/interpreter/src/state.rs b/cranelift/interpreter/src/state.rs
index 9f3bfdddd..5ec7f9fc3 100644
--- a/cranelift/interpreter/src/state.rs
+++ b/cranelift/interpreter/src/state.rs
@@ -25,7 +25,7 @@ pub trait State<'a> {
     fn get_function(&self, func_ref: FuncRef) -> Option<&'a Function>;
     /// Retrieve a reference to the currently executing [Function].
     fn get_current_function(&self) -> &'a Function;
-    /// Retrieve the handler callback for a [LibCall](cranelift_codegen::ir::LibCall)
+    /// Retrieve the handler callback for a [LibCall]
     fn get_libcall_handler(&self) -> LibCallHandler;
 
     /// Record that an interpreter has called into a new [Function].
diff --git a/crates/cranelift/src/compiled_function.rs b/crates/cranelift/src/compiled_function.rs
index f96c91038..24732f003 100644
--- a/crates/cranelift/src/compiled_function.rs
+++ b/crates/cranelift/src/compiled_function.rs
@@ -66,7 +66,7 @@ pub struct CompiledFunction {
 }
 
 impl CompiledFunction {
-    /// Creates a [CompiledFunction] from a [cranelift_codegen::MachBufferFinalized<Final>]
+    /// Creates a [CompiledFunction] from a [`cranelift_codegen::MachBufferFinalized<Final>`]
     /// This function uses the information in the machine buffer to derive the traps and relocations
     /// fields. The compiled function metadata is loaded with the default values.
     pub fn new(
diff --git a/crates/wasi-common/src/ctx.rs b/crates/wasi-common/src/ctx.rs
index 0d8d495dc..7048aead7 100644
--- a/crates/wasi-common/src/ctx.rs
+++ b/crates/wasi-common/src/ctx.rs
@@ -14,7 +14,7 @@ use std::sync::{Arc, Mutex};
 /// the file descriptor table. This wrapper is only necessary due to the
 /// signature of `fd_fdstat_set_flags`; if that changes, there are a variety of
 /// improvements that can be made (TODO:
-/// https://github.com/bytecodealliance/wasmtime/issues/5643).
+/// <https://github.com/bytecodealliance/wasmtime/issues/5643)>.
 #[derive(Clone)]
 pub struct WasiCtx(Arc<WasiCtxInner>);
 
diff --git a/crates/wasmtime/src/compile/code_builder.rs b/crates/wasmtime/src/compile/code_builder.rs
index 35d3990ab..00b456d53 100644
--- a/crates/wasmtime/src/compile/code_builder.rs
+++ b/crates/wasmtime/src/compile/code_builder.rs
@@ -3,7 +3,7 @@ use anyhow::{anyhow, bail, Context, Result};
 use std::borrow::Cow;
 use std::path::Path;
 
-/// Builder-style structure used to create a [`Module`](crate::Module) or
+/// Builder-style structure used to create a [`Module`](crate::module::Module) or
 /// pre-compile a module to a serialized list of bytes.
 ///
 /// This structure can be used for more advanced configuration when compiling a
diff --git a/crates/wasmtime/src/runtime/component/mod.rs b/crates/wasmtime/src/runtime/component/mod.rs
index e72710797..9418ede3b 100644
--- a/crates/wasmtime/src/runtime/component/mod.rs
+++ b/crates/wasmtime/src/runtime/component/mod.rs
@@ -98,6 +98,8 @@
 //! 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)]
 
 mod component;
 mod func;
diff --git a/crates/wiggle/src/guest_type.rs b/crates/wiggle/src/guest_type.rs
index 4464347cb..732f9e07c 100644
--- a/crates/wiggle/src/guest_type.rs
+++ b/crates/wiggle/src/guest_type.rs
@@ -9,7 +9,7 @@ use std::sync::atomic::{
 /// indicate whether the function was successful and subsequent results are valid,
 /// or whether an error occured. This trait allows wiggle to return the correct
 /// value when the interface function's idiomatic Rust method returns
-/// Ok(<rest of return values>).
+/// `Ok(<rest of return values>)`.
 pub trait GuestErrorType {
     fn success() -> Self;
 }
diff --git a/crates/wiggle/src/lib.rs b/crates/wiggle/src/lib.rs
index 14141c36d..66fc3b49a 100644
--- a/crates/wiggle/src/lib.rs
+++ b/crates/wiggle/src/lib.rs
@@ -902,7 +902,7 @@ impl<'a, T> std::ops::Deref for GuestCow<'a, T> {
 ///   only by manually performing borrow-checking of the underlying regions that
 ///   are accessed; this kind of borrowing is wrapped up in the [`GuestSlice`]
 ///   and [`GuestSliceMut`] smart pointers (see
-///   [`UnsafeGuestSlice::shared_borrow`], [`UnsafeGuestSlice::mut_borrow`]).
+///   `UnsafeGuestSlice::shared_borrow`, `UnsafeGuestSlice::mut_borrow`).
 pub struct UnsafeGuestSlice<'a, T> {
     /// A raw pointer to the bytes in memory.
     ptr: &'a [UnsafeCell<T>],
diff --git a/winch/codegen/src/codegen/env.rs b/winch/codegen/src/codegen/env.rs
index 374b54958..63f1d31a2 100644
--- a/winch/codegen/src/codegen/env.rs
+++ b/winch/codegen/src/codegen/env.rs
@@ -202,7 +202,7 @@ impl<'a, 'translation, 'data, P: PtrSize> FuncEnv<'a, 'translation, 'data, P> {
         }
     }
 
-    /// Resolves [GlobalData] of a global at the given index.
+    /// Resolves `GlobalData` of a global at the given index.
     pub fn resolve_global(&mut self, index: GlobalIndex) -> GlobalData {
         let ty = self.translation.module.globals[index].wasm_ty;
         let val = || match self.translation.module.defined_global_index(index) {
@@ -254,7 +254,7 @@ impl<'a, 'translation, 'data, P: PtrSize> FuncEnv<'a, 'translation, 'data, P> {
         }
     }
 
-    /// Resolve a [HeapData] from a [MemoryIndex].
+    /// Resolve a `HeapData` from a [MemoryIndex].
     // TODO: (@saulecabrera)
     // Handle shared memories when implementing support for Wasm Threads.
     pub fn resolve_heap(&mut self, index: MemoryIndex) -> HeapData {
diff --git a/winch/codegen/src/isa/mod.rs b/winch/codegen/src/isa/mod.rs
index d6c3c627c..e34dd5e2b 100644
--- a/winch/codegen/src/isa/mod.rs
+++ b/winch/codegen/src/isa/mod.rs
@@ -96,7 +96,7 @@ pub enum CallingConvention {
     AppleAarch64,
     /// The default calling convention for Winch. It largely follows SystemV
     /// for parameter and result handling. This calling convention is part of
-    /// Winch's default ABI [crate::abi::ABI].
+    /// Winch's default ABI `crate::abi::ABI`.
     Default,
 }
 


Test patch:
diff --git a/cranelift/reader/src/testcommand.rs b/cranelift/reader/src/testcommand.rs
index 17896a070..adfd064ce 100644
--- a/cranelift/reader/src/testcommand.rs
+++ b/cranelift/reader/src/testcommand.rs
@@ -4,7 +4,7 @@
 //! The general syntax is:
 //!
 //! <pre>
-//! test <i>&lt;command&gt;</i> </i>[options]</i>...
+//! test <i>&lt;command&gt;</i> <i>[options]</i>...
 //! </pre>
 //!
 //! The options are either a single identifier flag, or setting values like `identifier=value`.