Skip to content

Commit 06e75b0

Browse files
committed
docs(allocator): enable lint warnings on missing docs, and add missing doc comments (#6613)
Part of oxc-project/backlog#130
1 parent de22b81 commit 06e75b0

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

crates/oxc_allocator/src/boxed.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ impl<'alloc, T: Hash> Hash for Box<'alloc, T> {
167167
pub struct Address(usize);
168168

169169
impl<'a, T> Box<'a, T> {
170+
/// Get the memory address of a value allocated in the arena.
170171
#[inline]
171172
pub fn address(&self) -> Address {
172173
Address(ptr::addr_of!(**self) as usize)

crates/oxc_allocator/src/clone_in.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ use crate::{Allocator, Box, Vec};
2020
/// However, it **isn't** guaranteed.
2121
///
2222
pub trait CloneIn<'new_alloc>: Sized {
23+
/// The type of the cloned object.
24+
///
25+
/// This should always be `Self` with a different lifetime.
2326
type Cloned;
2427

28+
/// Clone `self` into the given `allocator`. `allocator` may be the same one
29+
/// that `self` is already in.
2530
fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned;
2631
}
2732

crates/oxc_allocator/src/convert.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
use crate::{Allocator, Box};
44

5-
/// This trait works similarly to the standard library `From` trait, It comes with a similar
6-
/// implementation containing blanket implementation for `IntoIn`, reflective implementation and a
5+
/// This trait works similarly to the standard library [`From`] trait, It comes with a similar
6+
/// implementation containing blanket implementation for [`IntoIn`], reflective implementation and a
77
/// bunch of primitive conversions from Rust types to their arena equivalent.
88
pub trait FromIn<'a, T>: Sized {
9+
/// Converts to this type from the input type within the given `allocator`.
910
fn from_in(value: T, allocator: &'a Allocator) -> Self;
1011
}
1112

12-
/// This trait works similarly to the standard library `Into` trait.
13-
/// It is similar to `FromIn` is reflective, A `FromIn` implementation also implicitly implements
14-
/// `IntoIn` for the opposite type.
13+
/// This trait works similarly to the standard library [`Into`] trait.
14+
/// It is similar to [`FromIn`] is reflective, A [`FromIn`] implementation also implicitly implements
15+
/// [`IntoIn`] for the opposite type.
1516
pub trait IntoIn<'a, T>: Sized {
17+
/// Converts this type into the (usually inferred) input type within the given `allocator`.
1618
fn into_in(self, allocator: &'a Allocator) -> T;
1719
}
1820

crates/oxc_allocator/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
//! let parsed = Parser::new(&allocator, "let x = 1;", SourceType::default());
3939
//! assert!(parsed.errors.is_empty());
4040
//! ```
41-
41+
#![warn(missing_docs)]
4242
use std::{
4343
convert::From,
4444
ops::{Deref, DerefMut},

crates/oxc_allocator/src/vec.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ impl<'alloc, T> Vec<'alloc, T> {
9393
Self(vec::Vec::with_capacity_in(capacity, allocator))
9494
}
9595

96+
/// Create a new [`Vec`] whose elements are taken from an iterator and
97+
/// allocated in the given `allocator`.
98+
///
99+
/// This is behaviorially identical to [`FromIterator::from_iter`].
96100
#[inline]
97101
pub fn from_iter_in<I: IntoIterator<Item = T>>(iter: I, allocator: &'alloc Allocator) -> Self {
98102
let iter = iter.into_iter();

0 commit comments

Comments
 (0)