Skip to content

Commit 1181fe3

Browse files
committed
docs(turbopack): Fix all warnings in cargo doc --no-deps --workspace, and run rustdoc as part of our CI checks
1 parent 156307e commit 1181fe3

File tree

51 files changed

+349
-477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+349
-477
lines changed

crates/next-napi-bindings/src/next_api/utils.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ pub fn root_task_dispose(
9898
Ok(())
9999
}
100100

101+
/// [Peeks] at the [`Issue`] held by the given source and returns it as a [`PlainDiagnostic`].
102+
/// It does not [consume] any [`Issue`]s held by the source.
103+
///
104+
/// [Peeks]: turbo_tasks::CollectiblesSource::peek_collectibles
105+
/// [`Issue`]: turbopack_core::issue::Issue
106+
/// [consume]: turbo_tasks::CollectiblesSource::take_collectibles
101107
pub async fn get_issues<T: Send>(
102108
source: OperationVc<T>,
103109
filter: Vc<IssueFilter>,
@@ -107,10 +113,11 @@ pub async fn get_issues<T: Send>(
107113
))
108114
}
109115

110-
/// Reads the [turbopack_core::diagnostics::Diagnostic] held
111-
/// by the given source and returns it as a
112-
/// [turbopack_core::diagnostics::PlainDiagnostic]. It does
113-
/// not consume any Diagnostics held by the source.
116+
/// [Peeks] at the [`Diagnostic`]s held by the given source and returns it as a [`PlainDiagnostic`].
117+
/// It does not [consume] any [`Diagnostic`]s held by the source.
118+
///
119+
/// [Peeks]: turbo_tasks::CollectiblesSource::peek_collectibles
120+
/// [consume]: turbo_tasks::CollectiblesSource::take_collectibles
114121
pub async fn get_diagnostics<T: Send>(
115122
source: OperationVc<T>,
116123
) -> Result<Arc<Vec<ReadRef<PlainDiagnostic>>>> {

crates/next-taskless/src/constants.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,13 @@ pub const NODE_EXTERNALS: [&str; 68] = [
7070
"zlib",
7171
];
7272

73-
/// List of node.js internals that are supported by edge runtime.
74-
/// If anything Node.js builtin module apart from these these imports are
75-
/// used and user does not provide alias for the polyfill, a runtime error will be thrown.
76-
/// See https://vercel.com/docs/functions/runtimes/edge-runtime#compatible-node.js-modules
73+
/// The Node.js built-in modules that are supported by edge runtime.
74+
///
75+
/// If any Node.js builtin module apart from these these imports are used and the user does not
76+
/// provide an alias for it (i.e. a polyfill), a runtime error will be thrown.
77+
///
78+
/// See <https://vercel.com/docs/functions/runtimes/edge-runtime#compatible-node.js-modules>
79+
//
7780
// SAFETY: This has to be sorted alphabetically since we are doing binary search on it
7881
pub const EDGE_NODE_EXTERNALS: [&str; 7] = [
7982
"assert",

packages/next-swc/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
"build-native-wasi": "npx --package=@napi-rs/cli@3.0.0-alpha.45 napi build --platform --target wasm32-wasip1-threads -p next-napi-bindings --cwd ../../ --output-dir packages/next-swc/native --no-default-features",
1717
"build-wasm": "wasm-pack build ../../crates/wasm --scope=next",
1818
"cache-build-native": "[ -d native ] && echo $(ls native)",
19-
"rust-check-fmt": "cd ../..; cargo fmt -- --check",
2019
"rust-check-clippy": "cargo clippy --workspace --all-targets -- -D warnings -A deprecated",
20+
"rust-check-doc": "RUSTDOCFLAGS='-Zunstable-options --output-format=json' cargo doc --no-deps --workspace",
21+
"rust-check-fmt": "cd ../..; cargo fmt -- --check",
2122
"rust-check-napi": "cargo check -p next-napi-bindings",
2223
"test-cargo-unit": "cargo nextest run --workspace --exclude next-napi-bindings --exclude turbo-tasks-macros --cargo-profile release-with-assertions --no-fail-fast"
2324
},

packages/next-swc/turbo.jsonc

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,14 @@
136136
"outputs": ["native/*.node", "native/index.d.ts"],
137137
},
138138
"rust-check": {
139-
"dependsOn": ["rust-check-fmt", "rust-check-clippy", "rust-check-napi"],
139+
"dependsOn": [
140+
"rust-check-clippy",
141+
"rust-check-doc",
142+
"rust-check-fmt",
143+
"rust-check-napi",
144+
],
140145
},
141-
"rust-check-fmt": {
146+
"rust-check-clippy": {
142147
"inputs": [
143148
"../../.cargo/**",
144149
"../../crates/**",
@@ -148,9 +153,8 @@
148153
"../../.github/workflows/build_and_deploy.yml",
149154
"../../rust-toolchain.toml",
150155
],
151-
"cache": false,
152156
},
153-
"rust-check-clippy": {
157+
"rust-check-doc": {
154158
"inputs": [
155159
"../../.cargo/**",
156160
"../../crates/**",
@@ -161,6 +165,18 @@
161165
"../../rust-toolchain.toml",
162166
],
163167
},
168+
"rust-check-fmt": {
169+
"inputs": [
170+
"../../.cargo/**",
171+
"../../crates/**",
172+
"../../turbopack/crates/**",
173+
"../../**/Cargo.toml",
174+
"../../**/Cargo.lock",
175+
"../../.github/workflows/build_and_deploy.yml",
176+
"../../rust-toolchain.toml",
177+
],
178+
"cache": false,
179+
},
164180
"rust-check-napi": {
165181
"inputs": [
166182
"../../.cargo/**",

turbopack/crates/turbo-tasks-backend/src/backing_storage.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ pub trait BackingStorage: BackingStorageSealed {
3737
///
3838
/// This typically means that we'll restart the process or `turbo-tasks` soon with a fresh
3939
/// database. If this happens, there's no point in writing anything else to disk, or flushing
40-
/// during [`KeyValueDatabase::shutdown`].
40+
/// during [`TurboTasksBackend::stop`].
4141
///
42-
/// This can be implemented by calling [`invalidate_db`] with
43-
/// the database's non-versioned base path.
44-
///
45-
/// [`KeyValueDatabase::shutdown`]: crate::database::key_value_database::KeyValueDatabase::shutdown
46-
/// [`invalidate_db`]: crate::database::db_invalidation::invalidate_db
42+
/// [`TurboTasksBackend::stop`]: turbo_tasks::backend::Backend::stop
43+
//
44+
// This can be implemented by calling `database::db_invalidation::invalidate_db` with the
45+
// database's non-versioned base path.
4746
fn invalidate(&self, reason_code: &str) -> Result<()>;
4847
}
4948

turbopack/crates/turbo-tasks-bytes/src/bytes.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ impl Deref for Bytes {
4848
}
4949
}
5050

51-
/// Types that implement From<X> for Bytes {}
52-
/// Unfortunately, we cannot just use the more generic `Into<Bytes>` without
53-
/// running afoul of the `From<X> for X` base case, causing conflicting impls.
51+
/// Types that `impl From<CustomType> for Bytes {}`
52+
///
53+
/// Unfortunately, we cannot just use the more generic `Into<Bytes>` without running afoul of the
54+
/// `From<X> for X` base case, causing conflicting impls.
5455
pub trait IntoBytes: Into<CBytes> {}
5556
impl IntoBytes for &'static [u8] {}
5657
impl IntoBytes for &'static str {}

turbopack/crates/turbo-tasks-fs/src/embed/dir.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ pub fn directory_from_include_dir(
2525
Vc::upcast(EmbeddedFileSystem::new(name, dir))
2626
}
2727

28-
/// Returns an embedded [Vc<Box<dyn FileSystem>>] for the given path.
28+
/// Returns an embedded [`Vc<Box<dyn FileSystem>>`][FileSystem] for the given path.
2929
///
30-
/// This will embed a directory's content into the binary and
31-
/// create an [Vc<EmbeddedFileSystem>].
30+
/// This will embed a directory's content into the binary and create an
31+
/// [`Vc<EmbeddedFileSystem>`][EmbeddedFileSystem].
3232
///
33-
/// If you enable the `dynamic_embed_contents` feature, calling
34-
/// the macro will return a [Vc<DiskFileSystem>].
33+
/// If you enable the `dynamic_embed_contents` feature, calling the macro will return a
34+
/// [`Vc<DiskFileSystem>`][DiskFileSystem].
3535
///
36-
/// This enables dynamic linking (and hot reloading) of embedded files/dirs.
37-
/// A binary built with `dynamic_embed_contents` enabled is **is not portable**,
38-
/// only the directory path will be embedded into the binary.
36+
/// This enables dynamic linking (and hot reloading) of embedded files/dirs. A binary built with
37+
/// `dynamic_embed_contents` enabled is **is not portable**, only the directory path will be
38+
/// embedded into the binary.
3939
#[macro_export]
4040
macro_rules! embed_directory {
4141
($name:tt, $path:tt) => {{ // make sure the path contains `$CARGO_MANIFEST_DIR`

turbopack/crates/turbo-tasks-fs/src/lib.rs

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,6 @@ use crate::{
9191
};
9292
pub use crate::{read_glob::ReadGlobResult, virtual_fs::VirtualFileSystem};
9393

94-
/// A (somewhat arbitrary) filename limit that we should try to keep output file names below.
95-
///
96-
/// For the sake of consistency, this is a fixed constant that is likely to be safe across all
97-
/// platforms.
98-
///
99-
/// Different operating systems have different limits on file name and file path. See
100-
/// [`validate_path_length`] for details. Because this only accounts for a single path segment, and
101-
/// not the total path length, this cannot not guarantee a full file path is safe.
102-
///
103-
/// To ensure file names are kept within this limit, call
104-
/// [`FileSystemPath::truncate_file_name_with_hash`].
105-
pub const MAX_SAFE_FILE_NAME_LENGTH: usize = 200;
106-
10794
/// Validate the path, returning the valid path, a modified-but-now-valid path, or bailing with an
10895
/// error.
10996
///
@@ -1553,9 +1540,8 @@ impl FileSystemPath {
15531540
FileSystemPath { fs, path }
15541541
}
15551542

1556-
/// Adds a subpath to the current path. The /-separate path argument might
1557-
/// contain ".." or "." segments, but it must not leave the root of the
1558-
/// filesystem.
1543+
/// Adds a subpath to the current path. The /-separated `path` argument might contain ".." or
1544+
/// "." segments, but it must not leave the root of the filesystem.
15591545
pub fn join(&self, path: &str) -> Result<Self> {
15601546
if let Some(path) = join_path(&self.path, path) {
15611547
Ok(Self::new_normalized(self.fs, path.into()))
@@ -1568,7 +1554,7 @@ impl FileSystemPath {
15681554
}
15691555
}
15701556

1571-
/// Adds a suffix to the filename. [path] must not contain `/`.
1557+
/// Adds a suffix to the filename. `path` must not contain `/`.
15721558
pub fn append(&self, path: &str) -> Result<Self> {
15731559
if path.contains('/') {
15741560
bail!(
@@ -1583,12 +1569,12 @@ impl FileSystemPath {
15831569
))
15841570
}
15851571

1586-
/// Adds a suffix to the basename of the filename. [appending] must not
1587-
/// contain `/`. Extension will stay intact.
1572+
/// Adds a suffix to the basename of the file path. `appending` must not contain `/`. The [file
1573+
/// extension][FileSystemPath::extension] will stay intact.
15881574
pub fn append_to_stem(&self, appending: &str) -> Result<Self> {
15891575
if appending.contains('/') {
15901576
bail!(
1591-
"FileSystemPath(\"{}\").append_to_stem(\"{}\") must not append '/'",
1577+
"FileSystemPath({:?}).append_to_stem({:?}) must not append '/'",
15921578
self.path,
15931579
appending,
15941580
)
@@ -1628,14 +1614,15 @@ impl FileSystemPath {
16281614
None
16291615
}
16301616

1631-
/// DETERMINISM: Result is in random order. Either sort result or do not depend
1632-
/// on the order.
1617+
/// DETERMINISM: Result is in random order. Either sort the result or do not depend on the
1618+
/// order.
16331619
pub fn read_glob(&self, glob: Vc<Glob>) -> Vc<ReadGlobResult> {
16341620
read_glob(self.clone(), glob)
16351621
}
16361622

1637-
// Tracks all files and directories matching the glob
1638-
// Follows symlinks as though they were part of the original hierarchy.
1623+
// Tracks all files and directories matching the glob using the filesystem watcher. Follows
1624+
// symlinks as though they were part of the original hierarchy. The returned [`Vc`] will be
1625+
// invalidated if a file or directory changes.
16391626
pub fn track_glob(&self, glob: Vc<Glob>, include_dot_files: bool) -> Vc<Completion> {
16401627
track_glob(self.clone(), glob, include_dot_files)
16411628
}
@@ -2046,7 +2033,7 @@ pub enum LinkContent {
20462033
///
20472034
/// We don't use the [`FileSystemPath`] to store the target, because the [`FileSystemPath`] is
20482035
/// always normalized. In [`FileSystemPath::write_symbolic_link_dir`] we need to compare
2049-
/// `target` with the value returned by [`sys::fs::read_link`].
2036+
/// `target` with the value returned by [`std::fs::read_link`].
20502037
Link {
20512038
target: RcStr,
20522039
link_type: LinkType,

turbopack/crates/turbo-tasks-fs/src/rope.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ impl<T: Into<Bytes>> From<T> for Rope {
159159
impl RopeBuilder {
160160
/// Push owned bytes into the Rope.
161161
///
162-
/// If possible use [push_static_bytes] or `+=` operation instead, as they
163-
/// will create a reference to shared memory instead of cloning the bytes.
162+
/// If possible, use [`RopeBuilder::push_static_bytes`] or `+=` operation instead. That will
163+
/// create a reference to shared memory instead of cloning the bytes.
164164
pub fn push_bytes(&mut self, bytes: &[u8]) {
165165
if bytes.is_empty() {
166166
return;
@@ -414,7 +414,7 @@ impl DeterministicHash for RopeBytesOnlyHash<'_> {
414414
/// [`Rope::to_bytes`] instead would be easier, but would require copying to an intermediate buffer.
415415
///
416416
/// This len + bytes format is similar to how bincode would normally encode a `&[u8]`:
417-
/// https://docs.rs/bincode/latest/bincode/spec/index.html#collections
417+
/// <https://docs.rs/bincode/latest/bincode/spec/index.html#collections>
418418
impl Encode for Rope {
419419
fn encode<E: Encoder>(&self, encoder: &mut E) -> Result<(), EncodeError> {
420420
self.length.encode(encoder)?;
@@ -882,7 +882,7 @@ impl BufRead for RopeReader<'_> {
882882
}
883883

884884
impl<'a> Stream for RopeReader<'a> {
885-
/// This is efficiently streamable into a [`Hyper::Body`] if each item is cloned into an owned
885+
/// This is efficiently streamable into a `Hyper::Body` if each item is cloned into an owned
886886
/// `Bytes` instance.
887887
type Item = Result<&'a Bytes>;
888888

turbopack/crates/turbo-tasks-fs/src/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use turbo_tasks::ResolvedVc;
88

99
use crate::{DiskFileSystem, FileSystemPath};
1010

11-
/// Converts a disk access Result<T> into a Result<Some<T>>, where a NotFound
12-
/// error results in a None value. This is purely to reduce boilerplate code
13-
/// comparing NotFound errors against all other errors.
11+
/// Converts a disk access `Result<T>` into a `Result<Some<T>>`, where a [`ErrorKind::NotFound`] (or
12+
/// [`ErrorKind::InvalidFilename`]) error results in a [`None`] value. This is purely to reduce
13+
/// boilerplate code comparing [`ErrorKind::NotFound`] errors against all other errors.
1414
pub fn extract_disk_access<T>(value: io::Result<T>, path: &Path) -> Result<Option<T>> {
1515
match value {
1616
Ok(v) => Ok(Some(v)),

0 commit comments

Comments
 (0)