Expand description
Core types for the Mosaic typesetting engine.
Implements the document model (manifest §5) and diagnostics surface (manifest §31). Every other crate depends on this one; nothing here depends on parsing, layout, or backends.
The implementation is split into focused modules and re-exported flat at
the crate root: consumers use mos_core::Diagnostic,
mos_core::SourceSpan, etc., never the module paths. Internally:
document; the lowered semantic node graph (Document,Node,NodeSpec)span: source byte-ranges (SourceSpan) andlinecoldiagnostics:Diagnostic,DiagnosticAnnotation,Severity,Suggestioncodes; theMOS####diagnostic-code registrysink: diagnostic emission plumbing (DiagnosticSink)error; the crate-levelCoreErrorandResultaliashash: deterministic content hashing (ContentHash,ContentHasher)path: portable path helpers (display_path,resolve_relative)
Re-exports§
pub use codes::DiagnosticCategory;pub use codes::DiagnosticCode;pub use codes::DiagnosticDef;
Modules§
- codes
- Diagnostic code registry; the single source of truth for every diagnostic the compiler can emit.
- diagnostics 🔒
- User-facing diagnostics: severities, sub-message annotations, and machine-actionable fix-it suggestions.
- document 🔒
- The lowered semantic document graph (manifest §5, §6 stage 2).
- error 🔒
- The crate-level error type and
Resultalias. - hash 🔒
- Deterministic content hashing for cache boundaries (design note
docs/incremental-dependencies.md§4, §5). - path 🔒
- Portable path resolution and display helpers.
- sink 🔒
- Diagnostic emission plumbing.
- span 🔒
- Source locations.
Structs§
- Collecting
Sink - Collects every diagnostic and remembers whether any was an error.
- Content
Hash - Opaque content / dependency hash.
- Content
Hasher - An incremental builder for a deterministic
ContentHashover a sequence of typed fields (design note §4). - Diagnostic
- A user-facing diagnostic (manifest §16, §31).
- Diagnostic
Abort - A phase aborted for structural reasons (see the module docs). Carries no payload: the diagnostics explaining why have already been emitted to the sink.
- Document
- The lowered semantic document graph (manifest §5, §6 stage 2).
- Node
- A semantic document node (manifest §5.1).
- NodeId
- Stable identifier for a document node.
- Node
Spec - The blueprint for a node handed to
Document::alloc/Document::alloc_child. Carries only the fields a caller legitimately chooses:kind,span, andattributes. The arena supplies theid, the emptychildrenlist, and thecontent_hash/style_idplaceholders, so an invalid node is unrepresentable at the call site. - Source
Span - A byte-range location in a source file (manifest §6 stage 1).
- StyleId
- Identifier for a resolved style bundle.
- Suggestion
- A machine-actionable fix for a
Diagnostic.
Enums§
- Attr
Value - Attribute value carried on a semantic
Node. - Core
Error - Convenience top-level error type for crates that want a single
Resultalias without inventing their own. - Diagnostic
Annotation - A sub-message attached to a
Diagnostic. - Node
Kind - The kinds of nodes Mosaic recognises (manifest §5.1).
- Path
Error - Why a portable,
/-separated path could not be resolved. - Severity
- Diagnostic severity (manifest §31).
Traits§
- Diagnostic
Sink - Receiver for diagnostics emitted during a compiler phase.
Functions§
- display_
path - Render a filesystem path for user-facing output with forward slashes on every platform.
- linecol
- Convert a byte offset into a 1-based
(line, column)pair. - resolve_
relative - Join a portable,
/-separatedrelativepath ontobase, using the platform path separator throughout. - resolve_
source_ path - Resolve a portable,
/-separatedsrc_path(as written in a source file) relative to the directory containingsource_file.
Type Aliases§
- AttrMap
- Attribute map carried on each node. Keys are interned strings in a
later iteration; for now plain
Stringkeys are fine for the stub. - Diagnostic
Result - Result of a compiler phase.
Ok(T)on (possibly diagnostic-bearing) completion;Err(DiagnosticAbort)only on a structural abort. - Result