Skip to content

Commit 982fce1

Browse files
authored
Fix rustdoc warnings and test cargo doc in CI (#4711)
## Problem `cargo +nightly doc` is giving a lot of warnings: broken links, naked URLs, etc. ## Summary of changes * update the `proc-macro2` dependency so that it can compile on latest Rust nightly, see dtolnay/proc-macro2#391 and dtolnay/proc-macro2#398 * allow the `private_intra_doc_links` lint, as linking to something that's private is always more useful than just mentioning it without a link: if the link breaks in the future, at least there is a warning due to that. Also, one might enable [`--document-private-items`](https://doc.rust-lang.org/cargo/commands/cargo-doc.html#documentation-options) in the future and make these links work in general. * fix all the remaining warnings given by `cargo +nightly doc` * make it possible to run `cargo doc` on stable Rust by updating `opentelemetry` and associated crates to version 0.19, pulling in a fix that previously broke `cargo doc` on stable: open-telemetry/opentelemetry-rust#904 * Add `cargo doc` to CI to ensure that it won't get broken in the future. Fixes #2557 ## Future work * Potentially, it might make sense, for development purposes, to publish the generated rustdocs somewhere, like for example [how the rust compiler does it](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/index.html). I will file an issue for discussion.
1 parent e767ced commit 982fce1

Some content is hidden

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

55 files changed

+200
-138
lines changed

.cargo/config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ opt-level = 3
1212
# Turn on a small amount of optimization in Development mode.
1313
opt-level = 1
1414

15+
[build]
16+
# This is only present for local builds, as it will be overridden
17+
# by the RUSTDOCFLAGS env var in CI.
18+
rustdocflags = ["-Arustdoc::private_intra_doc_links"]
19+
1520
[alias]
1621
build_testing = ["build", "--features", "testing"]
1722
neon = ["run", "--bin", "neon_local"]

.github/workflows/build_and_test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ jobs:
127127
- name: Run cargo clippy (release)
128128
run: cargo hack --feature-powerset clippy --release $CLIPPY_COMMON_ARGS
129129

130+
- name: Check documentation generation
131+
run: cargo doc --workspace --no-deps --document-private-items
132+
env:
133+
RUSTDOCFLAGS: "-Dwarnings -Arustdoc::private_intra_doc_links"
134+
130135
# Use `${{ !cancelled() }}` to run quck tests after the longer clippy run
131136
- name: Check formatting
132137
if: ${{ !cancelled() }}

Cargo.lock

Lines changed: 22 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ notify = "5.0.0"
8484
num_cpus = "1.15"
8585
num-traits = "0.2.15"
8686
once_cell = "1.13"
87-
opentelemetry = "0.18.0"
88-
opentelemetry-otlp = { version = "0.11.0", default_features=false, features = ["http-proto", "trace", "http", "reqwest-client"] }
89-
opentelemetry-semantic-conventions = "0.10.0"
87+
opentelemetry = "0.19.0"
88+
opentelemetry-otlp = { version = "0.12.0", default_features=false, features = ["http-proto", "trace", "http", "reqwest-client"] }
89+
opentelemetry-semantic-conventions = "0.11.0"
9090
parking_lot = "0.12"
9191
pbkdf2 = "0.12.1"
9292
pin-project-lite = "0.2"
@@ -95,7 +95,7 @@ prost = "0.11"
9595
rand = "0.8"
9696
regex = "1.4"
9797
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls"] }
98-
reqwest-tracing = { version = "0.4.0", features = ["opentelemetry_0_18"] }
98+
reqwest-tracing = { version = "0.4.0", features = ["opentelemetry_0_19"] }
9999
reqwest-middleware = "0.2.0"
100100
reqwest-retry = "0.2.2"
101101
routerify = "3"
@@ -130,7 +130,7 @@ toml_edit = "0.19"
130130
tonic = {version = "0.9", features = ["tls", "tls-roots"]}
131131
tracing = "0.1"
132132
tracing-error = "0.2.0"
133-
tracing-opentelemetry = "0.18.0"
133+
tracing-opentelemetry = "0.19.0"
134134
tracing-subscriber = { version = "0.3", default_features = false, features = ["smallvec", "fmt", "tracing-log", "std", "env-filter"] }
135135
url = "2.2"
136136
uuid = { version = "1.2", features = ["v4", "serde"] }

compute_tools/src/pg_helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const POSTGRES_WAIT_TIMEOUT: Duration = Duration::from_millis(60 * 1000); // mil
1919
/// Escape a string for including it in a SQL literal. Wrapping the result
2020
/// with `E'{}'` or `'{}'` is not required, as it returns a ready-to-use
2121
/// SQL string literal, e.g. `'db'''` or `E'db\\'`.
22-
/// See https://github.com/postgres/postgres/blob/da98d005cdbcd45af563d0c4ac86d0e9772cd15f/src/backend/utils/adt/quote.c#L47
22+
/// See <https://github.com/postgres/postgres/blob/da98d005cdbcd45af563d0c4ac86d0e9772cd15f/src/backend/utils/adt/quote.c#L47>
2323
/// for the original implementation.
2424
pub fn escape_literal(s: &str) -> String {
2525
let res = s.replace('\'', "''").replace('\\', "\\\\");

control_plane/src/background_process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! (non-Neon binaries don't necessarily follow our pidfile conventions).
1111
//! The pid stored in the file is later used to stop the service.
1212
//!
13-
//! See [`lock_file`] module for more info.
13+
//! See the [`lock_file`](utils::lock_file) module for more info.
1414
1515
use std::ffi::OsStr;
1616
use std::io::Write;

control_plane/src/broker.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
//!
33
//! In the local test environment, the data for each safekeeper is stored in
44
//!
5+
//! ```text
56
//! .neon/safekeepers/<safekeeper id>
6-
//!
7+
//! ```
78
use anyhow::Context;
89

910
use std::path::PathBuf;

control_plane/src/endpoint.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
//!
33
//! In the local test environment, the data for each endpoint is stored in
44
//!
5+
//! ```text
56
//! .neon/endpoints/<endpoint id>
7+
//! ```
68
//!
79
//! Some basic information about the endpoint, like the tenant and timeline IDs,
810
//! are stored in the `endpoint.json` file. The `endpoint.json` file is created
@@ -22,7 +24,7 @@
2224
//!
2325
//! Directory contents:
2426
//!
25-
//! ```ignore
27+
//! ```text
2628
//! .neon/endpoints/main/
2729
//! compute.log - log output of `compute_ctl` and `postgres`
2830
//! endpoint.json - serialized `EndpointConf` struct

control_plane/src/safekeeper.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
//!
33
//! In the local test environment, the data for each safekeeper is stored in
44
//!
5+
//! ```text
56
//! .neon/safekeepers/<safekeeper id>
6-
//!
7+
//! ```
78
use std::io::Write;
89
use std::path::PathBuf;
910
use std::process::Child;

libs/metrics/src/metric_vec_duration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Helpers for observing duration on HistogramVec / CounterVec / GaugeVec / MetricVec<T>.
1+
//! Helpers for observing duration on `HistogramVec` / `CounterVec` / `GaugeVec` / `MetricVec<T>`.
22
33
use std::{future::Future, time::Instant};
44

libs/pageserver_api/src/models.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,16 @@ pub struct LayerResidenceEvent {
411411
pub reason: LayerResidenceEventReason,
412412
}
413413

414-
/// The reason for recording a given [`ResidenceEvent`].
414+
/// The reason for recording a given [`LayerResidenceEvent`].
415415
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
416416
pub enum LayerResidenceEventReason {
417417
/// The layer map is being populated, e.g. during timeline load or attach.
418418
/// This includes [`RemoteLayer`] objects created in [`reconcile_with_remote`].
419419
/// We need to record such events because there is no persistent storage for the events.
420+
///
421+
// https://github.com/rust-lang/rust/issues/74481
422+
/// [`RemoteLayer`]: ../../tenant/storage_layer/struct.RemoteLayer.html
423+
/// [`reconcile_with_remote`]: ../../tenant/struct.Timeline.html#method.reconcile_with_remote
420424
LayerLoad,
421425
/// We just created the layer (e.g., freeze_and_flush or compaction).
422426
/// Such layers are always [`LayerResidenceStatus::Resident`].

libs/pageserver_api/src/reltag.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ impl Ord for RelTag {
6060

6161
/// Display RelTag in the same format that's used in most PostgreSQL debug messages:
6262
///
63+
/// ```text
6364
/// <spcnode>/<dbnode>/<relnode>[_fsm|_vm|_init]
64-
///
65+
/// ```
6566
impl fmt::Display for RelTag {
6667
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
6768
if let Some(forkname) = forknumber_to_name(self.forknum) {

libs/postgres_ffi/src/relfile_utils.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ pub fn forknumber_to_name(forknum: u8) -> Option<&'static str> {
4949
}
5050
}
5151

52-
///
5352
/// Parse a filename of a relation file. Returns (relfilenode, forknum, segno) tuple.
5453
///
5554
/// Formats:
55+
///
56+
/// ```text
5657
/// <oid>
5758
/// <oid>_<fork name>
5859
/// <oid>.<segment number>
5960
/// <oid>_<fork name>.<segment number>
61+
/// ```
6062
///
6163
/// See functions relpath() and _mdfd_segpath() in PostgreSQL sources.
6264
///

libs/pq_proto/src/framed.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
//! It is similar to what tokio_util::codec::Framed with appropriate codec
66
//! provides, but `FramedReader` and `FramedWriter` read/write parts can be used
77
//! separately without using split from futures::stream::StreamExt (which
8-
//! allocates box[1] in polling internally). tokio::io::split is used for splitting
8+
//! allocates a [Box] in polling internally). tokio::io::split is used for splitting
99
//! instead. Plus we customize error messages more than a single type for all io
1010
//! calls.
1111
//!
12-
//! [1] https://docs.rs/futures-util/0.3.26/src/futures_util/lock/bilock.rs.html#107
12+
//! [Box]: https://docs.rs/futures-util/0.3.26/src/futures_util/lock/bilock.rs.html#107
1313
use bytes::{Buf, BytesMut};
1414
use std::{
1515
future::Future,
@@ -117,7 +117,7 @@ impl<S: AsyncWrite + Unpin> Framed<S> {
117117
impl<S: AsyncRead + AsyncWrite + Unpin> Framed<S> {
118118
/// Split into owned read and write parts. Beware of potential issues with
119119
/// using halves in different tasks on TLS stream:
120-
/// https://github.com/tokio-rs/tls/issues/40
120+
/// <https://github.com/tokio-rs/tls/issues/40>
121121
pub fn split(self) -> (FramedReader<S>, FramedWriter<S>) {
122122
let (read_half, write_half) = tokio::io::split(self.stream);
123123
let reader = FramedReader {

libs/remote_storage/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ pub const DEFAULT_REMOTE_STORAGE_MAX_CONCURRENT_SYNCS: usize = 50;
3434
pub const DEFAULT_REMOTE_STORAGE_MAX_SYNC_ERRORS: u32 = 10;
3535
/// Currently, sync happens with AWS S3, that has two limits on requests per second:
3636
/// ~200 RPS for IAM services
37-
/// https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/UsingWithRDS.IAMDBAuth.html
37+
/// <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/UsingWithRDS.IAMDBAuth.html>
3838
/// ~3500 PUT/COPY/POST/DELETE or 5500 GET/HEAD S3 requests
39-
/// https://aws.amazon.com/premiumsupport/knowledge-center/s3-request-limit-avoid-throttling/
39+
/// <https://aws.amazon.com/premiumsupport/knowledge-center/s3-request-limit-avoid-throttling/>
4040
pub const DEFAULT_REMOTE_STORAGE_S3_CONCURRENCY_LIMIT: usize = 100;
4141
/// No limits on the client side, which currenltly means 1000 for AWS S3.
42-
/// https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html#API_ListObjectsV2_RequestSyntax
42+
/// <https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html#API_ListObjectsV2_RequestSyntax>
4343
pub const DEFAULT_MAX_KEYS_PER_LIST_RESPONSE: Option<i32> = None;
4444

4545
const REMOTE_STORAGE_PREFIX_SEPARATOR: char = '/';

libs/tenant_size_model/src/calculation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::{SegmentMethod, SegmentSizeResult, SizeResult, StorageModel};
2121
// 2. D+C+a+b
2222
// 3. D+A+B
2323

24-
/// [`Segment`] which has had it's size calculated.
24+
/// `Segment` which has had its size calculated.
2525
#[derive(Clone, Debug)]
2626
struct SegmentSize {
2727
method: SegmentMethod,

libs/tracing-utils/src/http.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub enum OtelName<'a> {
3333
/// directly into HTTP servers. However, I couldn't find one for Hyper,
3434
/// so I had to write our own. OpenTelemetry website has a registry of
3535
/// instrumentation libraries at:
36-
/// https://opentelemetry.io/registry/?language=rust&component=instrumentation
36+
/// <https://opentelemetry.io/registry/?language=rust&component=instrumentation>
3737
/// If a Hyper crate appears, consider switching to that.
3838
pub async fn tracing_handler<F, R>(
3939
req: Request<Body>,

libs/utils/src/http/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub async fn json_request<T: for<'de> Deserialize<'de>>(
1414
.map_err(ApiError::BadRequest)
1515
}
1616

17-
/// Will be removed as part of https://github.com/neondatabase/neon/issues/4282
17+
/// Will be removed as part of <https://github.com/neondatabase/neon/issues/4282>
1818
pub async fn json_request_or_empty_body<T: for<'de> Deserialize<'de>>(
1919
request: &mut Request<Body>,
2020
) -> Result<Option<T>, ApiError> {

0 commit comments

Comments
 (0)