IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
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] = AnyOrigin[mut=mut]

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.

ImmutAnyOrigin

comptime ImmutAnyOrigin = ImmutAnyOrigin

The immutable origin that might access any memory value.

ImmutOrigin

comptime ImmutOrigin = ImmutOrigin

Immutable origin reference type.

ImmutUnsafeAnyOrigin

comptime ImmutUnsafeAnyOrigin = ImmutAnyOrigin

The immutable universal origin that might alias any memory value.

This is an unsafe escape hatch slated for removal. See UnsafeAnyOrigin.

ImmutUntrackedOrigin

comptime ImmutUntrackedOrigin = ImmutUntrackedOrigin

An immutable origin the lifetime checker does not track.

MutAnyOrigin

comptime MutAnyOrigin = MutAnyOrigin

The mutable origin that might access any memory value.

MutOrigin

comptime MutOrigin = MutOrigin

Mutable origin reference type.

MutUnsafeAnyOrigin

comptime MutUnsafeAnyOrigin = MutAnyOrigin

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.

StaticConstantOrigin

comptime StaticConstantOrigin = StaticConstantOrigin

An origin for strings and other always-immutable static constants.

UnsafeAnyOrigin

comptime UnsafeAnyOrigin[*, mut: Bool] = AnyOrigin[mut=mut]

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.