Skip to content

Commit dd3de92

Browse files
authored
Minor comment formatting cleanups. (#561)
Use shorter docs.rs URLs in comments, update to upstream Rust files that include more comments, and other miscellaenous comment formatting fixes.
1 parent bc63c50 commit dd3de92

21 files changed

+73
-56
lines changed

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,20 @@ by default. The rest of the API is conditional with cargo feature flags:
7070
| |
7171
| `use-libc` | Enable the libc backend.
7272

73-
[`rustix::fs`]: https://docs.rs/rustix/latest/rustix/fs/index.html
74-
[`rustix::io_uring`]: https://docs.rs/rustix/latest/rustix/io_uring/index.html
75-
[`rustix::mm`]: https://docs.rs/rustix/latest/rustix/mm/index.html
76-
[`rustix::net`]: https://docs.rs/rustix/latest/rustix/net/index.html
77-
[`rustix::param`]: https://docs.rs/rustix/latest/rustix/param/index.html
78-
[`rustix::process`]: https://docs.rs/rustix/latest/rustix/process/index.html
79-
[`rustix::rand`]: https://docs.rs/rustix/latest/rustix/rand/index.html
80-
[`rustix::termios`]: https://docs.rs/rustix/latest/rustix/termios/index.html
81-
[`rustix::thread`]: https://docs.rs/rustix/latest/rustix/thread/index.html
82-
[`rustix::time`]: https://docs.rs/rustix/latest/rustix/time/index.html
83-
[`rustix::io`]: https://docs.rs/rustix/latest/rustix/io/index.html
84-
[`rustix::fd`]: https://docs.rs/rustix/latest/rustix/fd/index.html
85-
[`rustix::ffi`]: https://docs.rs/rustix/latest/rustix/ffi/index.html
86-
[`rustix::path`]: https://docs.rs/rustix/latest/rustix/path/index.html
73+
[`rustix::fs`]: https://docs.rs/rustix/*/rustix/fs/index.html
74+
[`rustix::io_uring`]: https://docs.rs/rustix/*/rustix/io_uring/index.html
75+
[`rustix::mm`]: https://docs.rs/rustix/*/rustix/mm/index.html
76+
[`rustix::net`]: https://docs.rs/rustix/*/rustix/net/index.html
77+
[`rustix::param`]: https://docs.rs/rustix/*/rustix/param/index.html
78+
[`rustix::process`]: https://docs.rs/rustix/*/rustix/process/index.html
79+
[`rustix::rand`]: https://docs.rs/rustix/*/rustix/rand/index.html
80+
[`rustix::termios`]: https://docs.rs/rustix/*/rustix/termios/index.html
81+
[`rustix::thread`]: https://docs.rs/rustix/*/rustix/thread/index.html
82+
[`rustix::time`]: https://docs.rs/rustix/*/rustix/time/index.html
83+
[`rustix::io`]: https://docs.rs/rustix/*/rustix/io/index.html
84+
[`rustix::fd`]: https://docs.rs/rustix/*/rustix/fd/index.html
85+
[`rustix::ffi`]: https://docs.rs/rustix/*/rustix/ffi/index.html
86+
[`rustix::path`]: https://docs.rs/rustix/*/rustix/path/index.html
8787

8888
## Similar crates
8989

@@ -152,10 +152,10 @@ version of this crate.
152152
[`timerfd`]: https://crates.io/crates/timerfd
153153
[`io-streams`]: https://crates.io/crates/io-streams
154154
[`bitflags`]: https://crates.io/crates/bitflags
155-
[`Arg`]: https://docs.rs/rustix/latest/rustix/path/trait.Arg.html
155+
[`Arg`]: https://docs.rs/rustix/*/rustix/path/trait.Arg.html
156156
[I/O-safe]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md
157157
[I/O safety]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md
158158
[provenance]: https://github.com/rust-lang/rust/issues/95228
159-
[`OwnedFd`]: https://docs.rs/io-lifetimes/latest/io_lifetimes/struct.OwnedFd.html
160-
[`AsFd`]: https://docs.rs/io-lifetimes/latest/io_lifetimes/trait.AsFd.html
161-
[`NOSYS`]: https://docs.rs/rustix/latest/rustix/io/struct.Errno.html#associatedconstant.NOSYS
159+
[`OwnedFd`]: https://docs.rs/io-lifetimes/*/io_lifetimes/struct.OwnedFd.html
160+
[`AsFd`]: https://docs.rs/io-lifetimes/*/io_lifetimes/trait.AsFd.html
161+
[`NOSYS`]: https://docs.rs/rustix/*/rustix/io/struct.Errno.html#associatedconstant.NOSYS

examples/dup2_to_replace_stdio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn main() {
3838
drop(reader);
3939
drop(writer);
4040

41-
// Now we can print to "stdout" in the usual way, and it'll go to our pipe.
41+
// Now we can print to stdout in the usual way, and it'll go to our pipe.
4242
println!("hello, world!");
4343

4444
// And we can read from stdin, and it'll read from our pipe. It's a little

src/backend/libc/fs/dir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
237237
pub d_pino: i64,
238238
pub d_reclen: ::c_ushort,
239239
pub d_name: [::c_char; 1024], // Max length is _POSIX_PATH_MAX
240-
// */
240+
*/
241241

242242
// On dragonfly and FreeBSD 12, `dirent` has some non-public padding fields
243243
// so we can't directly initialize it.

src/backend/libc/fs/inotify.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub fn inotify_init(flags: CreateFlags) -> io::Result<OwnedFd> {
8181
unsafe { ret_owned_fd(c::inotify_init1(flags.bits())) }
8282
}
8383

84-
/// `inotify_add_watch(self, path, flags)`-Adds a watch to inotify
84+
/// `inotify_add_watch(self, path, flags)`Adds a watch to inotify
8585
///
8686
/// This registers or updates a watch for the filesystem path `path`
8787
/// and returns a watch descriptor corresponding to this watch.
@@ -96,7 +96,7 @@ pub fn inotify_add_watch<P: crate::path::Arg>(
9696
flags: WatchFlags,
9797
) -> io::Result<i32> {
9898
let path = path.as_cow_c_str().unwrap();
99-
// SAFETY: The fd and path we are passing is guranteed valid by the type
99+
// SAFETY: The fd and path we are passing is guaranteed valid by the type
100100
// system.
101101
unsafe {
102102
ret_c_int(c::inotify_add_watch(
@@ -107,7 +107,7 @@ pub fn inotify_add_watch<P: crate::path::Arg>(
107107
}
108108
}
109109

110-
/// `inotify_rm_watch(self, wd)`-Removes a watch from this inotify
110+
/// `inotify_rm_watch(self, wd)`Removes a watch from this inotify
111111
///
112112
/// The watch descriptor provided should have previously been returned
113113
/// by [`inotify_add_watch`] and not previously have been removed.

src/backend/libc/fs/syscalls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pub(crate) fn openat(
162162
mode: Mode,
163163
) -> io::Result<OwnedFd> {
164164
// Work around <https://sourceware.org/bugzilla/show_bug.cgi?id=17523>.
165-
// Basically old glibc versions don't handle O_TMPFILE correctly.
165+
// GLIBC versions before 2.25 don't handle `O_TMPFILE` correctly.
166166
#[cfg(all(unix, target_env = "gnu"))]
167167
if oflags.contains(OFlags::TMPFILE) && crate::backend::if_glibc_is_less_than_2_25() {
168168
return openat_via_syscall(dirfd, path, oflags, mode);
@@ -1593,7 +1593,7 @@ pub(crate) unsafe fn copyfile_state_get(
15931593

15941594
#[cfg(apple)]
15951595
pub(crate) fn getpath(fd: BorrowedFd<'_>) -> io::Result<CString> {
1596-
// The use of PATH_MAX is generally not encouraged, but it
1596+
// The use of `PATH_MAX` is generally not encouraged, but it
15971597
// is inevitable in this case because macOS defines `fcntl` with
15981598
// `F_GETPATH` in terms of `MAXPATHLEN`, and there are no
15991599
// alternatives. If a better method is invented, it should be used

src/backend/libc/io/syscalls.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub(crate) fn pwritev2(
242242
}
243243

244244
// These functions are derived from Rust's library/std/src/sys/unix/fd.rs at
245-
// revision a77da2d454e6caa227a85b16410b95f93495e7e0.
245+
// revision 326ef470a8b379a180d6dc4bbef08990698a737a.
246246

247247
// The maximum read limit on most POSIX-like systems is `SSIZE_MAX`, with the
248248
// man page quoting that if the count of bytes to read is greater than
@@ -262,7 +262,12 @@ const fn max_iov() -> usize {
262262
c::IOV_MAX as usize
263263
}
264264

265-
#[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux"))]
265+
#[cfg(any(
266+
target_os = "android",
267+
target_os = "emscripten",
268+
target_os = "linux",
269+
target_os = "nto"
270+
))]
266271
const fn max_iov() -> usize {
267272
c::UIO_MAXIOV as usize
268273
}
@@ -272,6 +277,8 @@ const fn max_iov() -> usize {
272277
target_os = "android",
273278
target_os = "emscripten",
274279
target_os = "linux",
280+
target_os = "nto",
281+
target_os = "horizon",
275282
)))]
276283
const fn max_iov() -> usize {
277284
16 // The minimum value required by POSIX.

src/backend/linux_raw/fs/inotify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub fn inotify_init(flags: CreateFlags) -> io::Result<OwnedFd> {
8080
syscalls::inotify_init1(flags)
8181
}
8282

83-
/// `inotify_add_watch(self, path, flags)`-Adds a watch to inotify
83+
/// `inotify_add_watch(self, path, flags)`Adds a watch to inotify
8484
///
8585
/// This registers or updates a watch for the filesystem path `path`
8686
/// and returns a watch descriptor corresponding to this watch.
@@ -98,7 +98,7 @@ pub fn inotify_add_watch<P: crate::path::Arg>(
9898
syscalls::inotify_add_watch(inot, &path, flags)
9999
}
100100

101-
/// `inotify_rm_watch(self, wd)`-Removes a watch from this inotify
101+
/// `inotify_rm_watch(self, wd)`Removes a watch from this inotify
102102
///
103103
/// The watch descriptor provided should have previously been returned
104104
/// by [`inotify_add_watch`] and not previously have been removed.

src/io/kqueue.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ impl UserDefinedFlags {
310310
}
311311
}
312312

313-
/// `kqueue()`- Create a new `kqueue` file descriptor.
313+
/// `kqueue()`Create a new `kqueue` file descriptor.
314314
///
315315
/// # References
316316
///
@@ -329,7 +329,8 @@ pub fn kqueue() -> io::Result<OwnedFd> {
329329
syscalls::kqueue()
330330
}
331331

332-
/// `kevent()`- Wait for events on a `kqueue`.
332+
/// `kevent(kqueue, changelist, eventlist, timeout)`—Wait for events on a
333+
/// `kqueue`.
333334
///
334335
/// # Safety
335336
///

src/io/port.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Solaris/Illumos event ports.
1+
//! Solaris/illumos event ports.
22
33
use crate::backend::c;
44
use crate::backend::io::syscalls;
@@ -31,7 +31,7 @@ impl Event {
3131
}
3232
}
3333

34-
/// `port_create()`- Creates a new port.
34+
/// `port_create()`Creates a new port.
3535
///
3636
/// # References
3737
///
@@ -44,7 +44,7 @@ pub fn port_create() -> io::Result<OwnedFd> {
4444
syscalls::port_create()
4545
}
4646

47-
/// `port_associate(_, PORT_SOURCE_FD, _, _, _)`- Associates a file descriptor
47+
/// `port_associate(_, PORT_SOURCE_FD, _, _, _)`Associates a file descriptor
4848
/// with a port.
4949
///
5050
/// # Safety
@@ -75,7 +75,7 @@ pub unsafe fn port_associate_fd(
7575
)
7676
}
7777

78-
/// `port_dissociate(_, PORT_SOURCE_FD, _)`- Dissociates a file descriptor from
78+
/// `port_dissociate(_, PORT_SOURCE_FD, _)`Dissociates a file descriptor from
7979
/// a port.
8080
///
8181
/// # Safety
@@ -94,7 +94,7 @@ pub unsafe fn port_dissociate_fd(port: impl AsFd, object: impl AsRawFd) -> io::R
9494
syscalls::port_dissociate(port.as_fd(), c::PORT_SOURCE_FD, object.as_raw_fd() as _)
9595
}
9696

97-
/// `port_get(port, timeout)`- Gets an event from a port.
97+
/// `port_get(port, timeout)`Gets an event from a port.
9898
///
9999
/// # References
100100
///
@@ -112,7 +112,7 @@ pub fn port_get(port: impl AsFd, timeout: Option<Duration>) -> io::Result<Event>
112112
syscalls::port_get(port.as_fd(), timeout.as_mut())
113113
}
114114

115-
/// `port_getn(port, events, min_events, timeout)`- Gets multiple events from a
115+
/// `port_getn(port, events, min_events, timeout)`Gets multiple events from a
116116
/// port.
117117
///
118118
/// # References
@@ -143,7 +143,7 @@ pub fn port_getn(
143143
)
144144
}
145145

146-
/// `port_send(port, events, userdata)`- Sends an event to a port.
146+
/// `port_send(port, events, userdata)`Sends an event to a port.
147147
///
148148
/// # References
149149
///

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
//! [`OwnedFd`]: https://doc.rust-lang.org/stable/std/os/fd/struct.OwnedFd.html
9191
//! [I/O-safe]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md
9292
//! [`Result`]: https://doc.rust-lang.org/stable/std/result/enum.Result.html
93-
//! [`Arg`]: https://docs.rs/rustix/latest/rustix/path/trait.Arg.html
93+
//! [`Arg`]: https://docs.rs/rustix/*/rustix/path/trait.Arg.html
9494
9595
#![deny(missing_docs)]
9696
#![allow(stable_features)]

src/net/addr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! The following is derived from Rust's
22
//! library/std/src/net/socket_addr.rs at revision
3-
//! f7e8ba28a4785e698a55fb95e4b3e803302de0ff.
3+
//! bd20fc1fd657b32f7aa1d70d8723f04c87f21606.
44
//!
55
//! All code in this file is licensed MIT or Apache 2.0 at your option.
66
//!

src/net/ip.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! The following is derived from Rust's
22
//! library/std/src/net/ip_addr.rs at revision
3-
//! 14230a7f8e117aa049d3ae661fa00ded7edefc68.
3+
//! bd20fc1fd657b32f7aa1d70d8723f04c87f21606.
44
//!
55
//! All code in this file is licensed MIT or Apache 2.0 at your option.
66
//!
@@ -1223,6 +1223,9 @@ impl Ipv6Addr {
12231223

12241224
/// An IPv6 address representing localhost: `::1`.
12251225
///
1226+
/// This corresponds to constant `IN6ADDR_LOOPBACK_INIT` or `in6addr_loopback` in other
1227+
/// languages.
1228+
///
12261229
/// # Examples
12271230
///
12281231
/// ```
@@ -1231,11 +1234,15 @@ impl Ipv6Addr {
12311234
/// let addr = Ipv6Addr::LOCALHOST;
12321235
/// assert_eq!(addr, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
12331236
/// ```
1237+
#[doc(alias = "IN6ADDR_LOOPBACK_INIT")]
1238+
#[doc(alias = "in6addr_loopback")]
12341239
#[cfg_attr(staged_api, stable(feature = "ip_constructors", since = "1.30.0"))]
12351240
pub const LOCALHOST: Self = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1);
12361241

12371242
/// An IPv6 address representing the unspecified address: `::`
12381243
///
1244+
/// This corresponds to constant `IN6ADDR_ANY_INIT` or `in6addr_any` in other languages.
1245+
///
12391246
/// # Examples
12401247
///
12411248
/// ```
@@ -1244,6 +1251,8 @@ impl Ipv6Addr {
12441251
/// let addr = Ipv6Addr::UNSPECIFIED;
12451252
/// assert_eq!(addr, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0));
12461253
/// ```
1254+
#[doc(alias = "IN6ADDR_ANY_INIT")]
1255+
#[doc(alias = "in6addr_any")]
12471256
#[cfg_attr(staged_api, stable(feature = "ip_constructors", since = "1.30.0"))]
12481257
pub const UNSPECIFIED: Self = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0);
12491258

src/net/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
//! of these APIs. [`wsa_cleanup`] may be used in the process if these APIs are
55
//! no longer needed.
66
//!
7-
//! [`wsa_startup`]: https://docs.rs/rustix/latest/x86_64-pc-windows-msvc/rustix/net/fn.wsa_startup.html
8-
//! [`wsa_cleanup`]: https://docs.rs/rustix/latest/x86_64-pc-windows-msvc/rustix/net/fn.wsa_cleanup.html
7+
//! [`wsa_startup`]: https://docs.rs/rustix/*/x86_64-pc-windows-msvc/rustix/net/fn.wsa_startup.html
8+
//! [`wsa_cleanup`]: https://docs.rs/rustix/*/x86_64-pc-windows-msvc/rustix/net/fn.wsa_cleanup.html
99
1010
#[cfg(not(feature = "std"))]
1111
mod addr;

src/path/arg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ where
950950
}
951951

952952
// Taken from
953-
// https://github.com/rust-lang/rust/blob/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/sys/common/small_c_string.rs
953+
// <https://github.com/rust-lang/rust/blob/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/sys/common/small_c_string.rs>
954954
let mut buf = MaybeUninit::<[u8; SMALL_PATH_BUFFER_SIZE]>::uninit();
955955
let buf_ptr = buf.as_mut_ptr() as *mut u8;
956956

src/process/rlimit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ pub use backend::process::types::Resource;
88
/// [`setrlimit`], and [`prlimit`].
99
#[derive(Debug, Clone, PartialEq, Eq)]
1010
pub struct Rlimit {
11-
/// Current effective, "soft", limit.
11+
/// Current effective, soft, limit.
1212
pub current: Option<u64>,
13-
/// Maximum, "hard", value that `current` may be dynamically increased to.
13+
/// Maximum, hard, value that `current` may be dynamically increased to.
1414
pub maximum: Option<u64>,
1515
}
1616

src/process/wait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub fn wait(waitopts: WaitOptions) -> io::Result<Option<(Pid, WaitStatus)>> {
175175
backend::process::syscalls::wait(waitopts)
176176
}
177177

178-
/// `waitid(_, _, _, opts)`-Wait for the specified child process to change
178+
/// `waitid(_, _, _, opts)`Wait for the specified child process to change
179179
/// state.
180180
#[cfg(not(any(target_os = "wasi", target_os = "redox", target_os = "openbsd")))]
181181
#[inline]

tests/fs/invalid_offset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! Rust APIs tend to use `u64`. Test that extreme `u64` values in APIs that
55
//! take file offsets are properly diagnosed.
66
//!
7-
//! These tests are disabled on ios/macos since those platforms kill the
7+
//! These tests are disabled on iOS/macOS since those platforms kill the
88
//! process with `SIGXFSZ` instead of returning an error.
99
1010
#![cfg(not(any(target_os = "redox", target_os = "wasi")))]

tests/io/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mod poll;
2525
mod procfs;
2626
#[cfg(not(windows))]
2727
#[cfg(not(target_os = "redox"))] // redox doesn't have cwd/openat
28-
#[cfg(not(target_os = "wasi"))] // wasi support for S_IRUSR etc. submitted to libc in #2264
28+
#[cfg(not(target_os = "wasi"))] // wasi support for `S_IRUSR` etc. submitted to libc in #2264
2929
mod read_write;
3030
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "android"))]
3131
mod seals;

tests/process/prctl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ fn test_floating_point_emulation_control() {
115115
dbg!(floating_point_emulation_control().unwrap());
116116
}
117117

118-
/*
119-
* Helper functions.
120-
*/
118+
//
119+
// Helper functions.
120+
//
121121

122122
#[cfg(feature = "thread")]
123123
pub(crate) fn thread_has_capability(capability: Capability) -> io::Result<bool> {

tests/process/working_directory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn tmpdir() -> TempDir {
77
tempdir().expect("expected to be able to create a temporary directory")
88
}
99

10-
/// Disable this test on macos because GHA has a weird system folder structure
10+
/// Disable this test on macOS because GHA has a weird system folder structure
1111
/// that makes this test fail.
1212
#[cfg(not(target_os = "macos"))]
1313
#[test]

tests/thread/prctl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ fn test_core_scheduling_cookie() {
105105
}
106106
}
107107

108-
/*
109-
* Helper functions.
110-
*/
108+
//
109+
// Helper functions.
110+
//
111111

112112
fn load_linux_kernel_config() -> io::Result<Vec<u8>> {
113113
if let Ok(compressed_bytes) = fs::read("/proc/config.gz") {

0 commit comments

Comments
 (0)