Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add some more docs to Session #155

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading