Skip to main content

solar_interface/
lib.rs

1#![doc = include_str!("../README.md")]
2#![doc(
3    html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/solar/main/assets/logo.png",
4    html_favicon_url = "https://raw.githubusercontent.com/paradigmxyz/solar/main/assets/favicon.ico"
5)]
6#![cfg_attr(docsrs, feature(doc_cfg))]
7#![cfg_attr(feature = "nightly", feature(panic_update_hook))]
8
9#[macro_use]
10extern crate tracing;
11
12pub mod diagnostics;
13use diagnostics::ErrorGuaranteed;
14
15mod globals;
16use globals::SessionGlobals;
17
18mod pos;
19pub use pos::{BytePos, CharPos, RelativeBytePos};
20
21mod session;
22pub use session::{Session, SessionBuilder};
23
24pub mod source_map;
25pub use source_map::SourceMap;
26
27mod span;
28pub use span::{Span, Spanned, SpannedOption};
29
30mod symbol;
31pub use symbol::{ByteSymbol, Ident, Symbol, kw, sym};
32
33pub mod panic_hook;
34
35pub use config::ColorChoice;
36pub use dunce::canonicalize;
37pub use solar_config as config;
38pub use solar_data_structures as data_structures;
39
40/// Compiler result type.
41pub type Result<T = (), E = ErrorGuaranteed> = std::result::Result<T, E>;
42
43/// The minimum supported Solidity version.
44///
45/// Solar aims to support Solidity 0.8.* and later versions.
46pub const MIN_SOLIDITY_VERSION: semver::Version = semver::Version::new(0, 8, 0);
47
48/// Creates new session globals on the current thread if they doesn't exist already and then
49/// executes the given closure.
50///
51/// Prefer [`Session::enter`] to this function if possible to also set the source map and thread
52/// pool.
53///
54/// Using this instead of [`Session::enter`] may cause unexpected panics.
55///
56/// See [`Session::enter`] for more details.
57#[inline]
58pub fn enter<R>(f: impl FnOnce() -> R) -> R {
59    SessionGlobals::with_or_default(|_| f())
60}