For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
type_aliases
Defines some type aliases.
These are Mojo built-ins, so you don't need to import them.
comptime values
AnyOrigin
comptime AnyOrigin[*, mut: Bool] = SomeUnsafeAnyOrigin
An origin that might access any memory value.
Parameters
- mut (
Bool): Whether the origin is mutable.
EllipsisType
comptime EllipsisType = __mlir_type.`!lit.ellipsis`
The type of the ... literal.
ImmOrigin
comptime ImmOrigin = ImmOrigin
Immutable origin reference type.
ImmStaticOrigin
comptime ImmStaticOrigin = ImmStaticOrigin
An origin for strings and other always-immutable static constants.
ImmUnsafeAnyOrigin
comptime ImmUnsafeAnyOrigin = ImmUnsafeAnyOrigin
The immutable universal origin that might alias any memory value.
This is an unsafe escape hatch slated for removal. See UnsafeAnyOrigin.
ImmUntrackedOrigin
comptime ImmUntrackedOrigin = ImmUntrackedOrigin
An immutable origin the lifetime checker does not track.
ImmutAnyOrigin
comptime ImmutAnyOrigin = ImmUnsafeAnyOrigin
The immutable origin that might access any memory value.
MutAnyOrigin
comptime MutAnyOrigin = MutUnsafeAnyOrigin
The mutable origin that might access any memory value.
MutOrigin
comptime MutOrigin = MutOrigin
Mutable origin reference type.
MutUnsafeAnyOrigin
comptime MutUnsafeAnyOrigin = MutUnsafeAnyOrigin
The mutable universal origin that might alias any memory value.
This is an unsafe escape hatch slated for removal. See UnsafeAnyOrigin.
MutUntrackedOrigin
comptime MutUntrackedOrigin = MutUntrackedOrigin
A mutable origin the lifetime checker does not track.
Never
comptime Never = Never
A type that can never have an instance constructed, used as a function result by functions that never return.
OriginSet
comptime OriginSet = LITOriginSet
A set of origin parameters.
UnsafeAnyOrigin
comptime UnsafeAnyOrigin[*, mut: Bool] = SomeUnsafeAnyOrigin
The universal origin: an unsafe origin that might alias any memory value.
Because a reference with this origin might alias any live value, it forces the lifetime checker into its most conservative behavior, defeating the guarantees the origin system is meant to provide:
- It extends unrelated lifetimes. Every other value in scope is kept alive for as long as the reference is live, even values it never points to, effectively halting ASAP destruction.
- It hides unused-variable warnings, since the compiler treats every in-scope variable as potentially aliased.
- It disables mutable exclusivity checking, since the compiler cannot prove which value the reference aliases.
Safety: This is a temporary compiler escape hatch from Mojo's early days,
not a capability to reach for. It will never be stabilized and is slated for
deprecation and removal. The Unsafe prefix marks every use as a place to
migrate away from; prefer a concrete origin so the compiler can continue to
track lifetimes and exclusivity.
Parameters
- mut (
Bool): Whether the origin is mutable.
UntrackedOrigin
comptime UntrackedOrigin[*, mut: Bool] = UntrackedOrigin[mut]
An origin the lifetime checker does not track, because it aliases no existing value.
An untracked origin is the empty origin: it promises the reference aliases no
value the compiler is managing, so there is nothing for the lifetime checker to
track or extend. That is exactly the behavior you want when interfacing with
memory from outside the Mojo program. For example, the pointer returned by
alloc() carries an untracked origin, because the allocated block aliases no
Mojo-owned value.
Parameters
- mut (
Bool): Whether the origin is mutable.
Structs
-
Origin: This represents a origin reference for a memory value.