Skip to main content

Session

Struct Session 

Source
pub struct Session {
    pub opts: Options,
    pub target: TargetInfo,
    pub interner: Interner,
    pub sources: SourceMap,
    /* private fields */
}
Expand description

One compilation.

Holds the options, the string interner and the diagnostics raised so far. Passing a &mut Session is how a stage reports a problem, and the return value of a stage says what it produced, never whether it succeeded: that question is answered by Session::has_errors.

Fields§

§opts: Options

What this compilation was asked to do.

§target: TargetInfo

Everything known about the target.

§interner: Interner

The one interner for the compilation.

§sources: SourceMap

Every file read during the compilation, and the flat coordinate space their spans live in.

This is on the session rather than passed around separately because a span is only meaningful against the map that issued it, and one map per compilation is the rule that makes that true by construction.

Implementations§

Source§

impl Session

Source

pub fn new(opts: Options) -> Self

A session for opts.

Source

pub fn emit(&mut self, diag: Diagnostic)

Records a diagnostic.

Under -Werror a warning is promoted here, once, rather than at every site that raises one.

Source

pub fn diagnostics(&self) -> &[Diagnostic]

Everything raised so far, in the order it was raised.

Source

pub fn has_errors(&self) -> bool

Whether anything fatal has been raised.

Source

pub fn error_count(&self) -> u32

How many errors have been raised.

Source

pub fn warning_count(&self) -> u32

How many warnings have been raised.

Source

pub fn error_limit_reached(&self) -> bool

Whether the error limit has been reached and the caller should stop.

Trait Implementations§

Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.