Skip to content

Commit

Permalink
docs: add some more docs to Session (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Dec 5, 2024
1 parent bfe2320 commit f853d03
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions crates/interface/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ use std::{collections::BTreeSet, num::NonZeroUsize, path::PathBuf, sync::Arc};

/// Information about the current compiler session.
#[derive(derive_builder::Builder)]
#[builder(
pattern = "owned",
build_fn(name = "try_build", private, error = "SessionBuilderError"),
setter(strip_option)
)]
#[builder(pattern = "owned", build_fn(name = "try_build", private), setter(strip_option))]
pub struct Session {
/// The diagnostics context.
pub dcx: DiagCtxt,
Expand Down Expand Up @@ -41,21 +37,16 @@ pub struct Session {
#[builder(default)]
pub pretty_json: bool,
/// Number of threads to use. Already resolved to a non-zero value.
///
/// Note that this defaults to 1. If you wish to use parallelism, you must manually set this to
/// a value greater than 1.
#[builder(default = "NonZeroUsize::MIN")]
pub jobs: NonZeroUsize,
/// Whether to emit AST stats.
#[builder(default)]
pub ast_stats: bool,
}

#[derive(Debug)]
struct SessionBuilderError;
impl From<derive_builder::UninitializedFieldError> for SessionBuilderError {
fn from(_value: derive_builder::UninitializedFieldError) -> Self {
Self
}
}

impl SessionBuilder {
/// Sets the diagnostic context to a test emitter.
#[inline]
Expand Down Expand Up @@ -97,6 +88,10 @@ impl SessionBuilder {

/// Consumes the builder to create a new session.
///
/// The diagnostics context must be set before calling this method, either by calling
/// [`dcx`](Self::dcx) or by using one of the provided helper methods, like
/// [`with_stderr_emitter`](Self::with_stderr_emitter).
///
/// # Panics
///
/// Panics if:
Expand Down

0 comments on commit f853d03

Please sign in to comment.