Skip to main content

Crate rustygo

Crate rustygo 

Source
Expand description

Runtime for Go packages compiled to Rust by the rustygo compiler.

Generated code is safe Rust and calls into this crate for everything Go has and Rust does not. The unsafe in the project lives here, the same way Rust’s own std confines it.

This crate is at the M0 spike stage (see docs/ROADMAP.md). What exists:

  • value and place: Go values, addressable storage and pointers.
  • string: Go strings.
  • ops: Go integer semantics that differ from Rust’s (shifts, division) and bounds checks.
  • print: the builtin print / println.
  • panic: Go panics carried on Rust unwinding.
  • rt: the process entry point for a Go main (std only).
  • prelude: what generated code imports.
  • gc and heap: GC roots and the collector.
  • trace: how the collector walks a value’s references.

Still to come, by milestone: slices, maps, closures and interfaces (M1); goroutines, channels and timers (M2); the syscall layer and netpoller (M3).

§Features

  • std (default): hosted targets. Without it the crate is no_std + alloc.
  • gc-torture: debug collector that collects at every safe point.

Modules§

complex
Go’s complex64 and complex128.
defers
defer.
func
Go function values and closures.
gc
Garbage-collection roots: the shadow stack.
heap
The heap and its collector.
iface
Interface values.
intrinsics
Bodies for functions gc implements in assembly or inside its own runtime, which the emitter maps here by name (internal/emit/intrinsics.go).
map
Go maps.
ops
Go integer semantics that Rust spells differently.
panic
Go panics, carried on Rust unwinding.
place
Places: addressable Go storage, and pointers to it.
prelude
Everything generated code uses unqualified: use rustygo::prelude::*;.
print
The builtin print and println.
rt
Process entry point for a compiled Go main package.
slice
Go slices: a view of a run of places in a backing array.
string
Go strings: immutable byte sequences, not necessarily UTF-8.
trace
Tracing: how the collector walks a value’s references.
unsafe_ptr
Go’s unsafe.Pointer and the unsafe builtins.
value
Go values: every Go type maps to a Copy Rust type with a zero value.