solar-interface 0.2.0

Source positions, diagnostics, and related helper functions
Documentation
#![doc = include_str!("../README.md")]
#![doc(
    html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/solar/main/assets/logo.png",
    html_favicon_url = "https://raw.githubusercontent.com/paradigmxyz/solar/main/assets/favicon.ico"
)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(feature = "nightly", feature(panic_update_hook))]

#[macro_use]
extern crate tracing;

pub mod diagnostics;
use diagnostics::ErrorGuaranteed;

mod globals;
use globals::SessionGlobals;

mod pos;
pub use pos::{BytePos, CharPos, RelativeBytePos};

mod session;
pub use session::{Session, SessionBuilder};

pub mod source_map;
pub use source_map::SourceMap;

mod span;
pub use span::{Span, Spanned, SpannedOption};

mod symbol;
pub use symbol::{ByteSymbol, Ident, Symbol, kw, sym};

pub mod panic_hook;

pub use config::ColorChoice;
pub use dunce::canonicalize;
pub use solar_config as config;
pub use solar_data_structures as data_structures;

/// Compiler result type.
pub type Result<T = (), E = ErrorGuaranteed> = std::result::Result<T, E>;

/// The minimum supported Solidity version.
///
/// Solar aims to support Solidity 0.8.* and later versions.
pub const MIN_SOLIDITY_VERSION: semver::Version = semver::Version::new(0, 8, 0);

/// Creates new session globals on the current thread if they doesn't exist already and then
/// executes the given closure.
///
/// Prefer [`Session::enter`] to this function if possible to also set the source map and thread
/// pool.
///
/// Using this instead of [`Session::enter`] may cause unexpected panics.
///
/// See [`Session::enter`] for more details.
#[inline]
pub fn enter<R>(f: impl FnOnce() -> R) -> R {
    SessionGlobals::with_or_default(|_| f())
}