rust-lang/unsafe-code-guidelines

Forum for discussion about what unsafe code can and can't do

750

stars

498

commits

May 5, 2026

updated

rust-lang.github.io/unsafe-code-guidelines

README

UCG - Rust's Unsafe Code Guidelines

The purpose of this repository is to collect and discuss all sorts of questions that come up when writing unsafe code. It is primarily used by the opsem team to track open questions around the operational semantics, but we also track some "non-opsem" questions that fall into T-lang or T-type's purview, if they are highly relevant to unsafe code authors.

The Unsafe Code Guidelines Reference "book" is a past effort to systematize a consensus on some of these questions. Most of it has been archived, but the glossary is still a useful resource.

Current consensus is documented in t-opsem FCPs and the Rust Language Reference.

See also

The Rustonomicon is a draft document discussing unsafe code. It is intended to be brought into agreement with the content here. It represents an organized effort to explain how to write Rust code, rather than a reference.

Code of Conduct and licensing

All interactions on this repository (whether on issues, PRs, or elsewhere) are governed by the Rust Code of Conduct.

Further, all content on this repository is subject to the standard Rust licensing.

Contributors

(top 30 of 33)

RalfJung

227 commits

gnzlbg

136 commits

nikomatsakis

66 commits

avadacatavra

16 commits

rust-lang/unsafe-code-guidelines

Forum for discussion about what unsafe code can and can't do

750

stars

498

commits

May 5, 2026

updated

rust-lang.github.io/unsafe-code-guidelines

README

UCG - Rust's Unsafe Code Guidelines

The purpose of this repository is to collect and discuss all sorts of questions that come up when writing unsafe code. It is primarily used by the opsem team to track open questions around the operational semantics, but we also track some "non-opsem" questions that fall into T-lang or T-type's purview, if they are highly relevant to unsafe code authors.

The Unsafe Code Guidelines Reference "book" is a past effort to systematize a consensus on some of these questions. Most of it has been archived, but the glossary is still a useful resource.

Current consensus is documented in t-opsem FCPs and the Rust Language Reference.

See also

The Rustonomicon is a draft document discussing unsafe code. It is intended to be brought into agreement with the content here. It represents an organized effort to explain how to write Rust code, rather than a reference.

Code of Conduct and licensing

All interactions on this repository (whether on issues, PRs, or elsewhere) are governed by the Rust Code of Conduct.

Further, all content on this repository is subject to the standard Rust licensing.

Contributors

(top 30 of 33)

RalfJung

227 commits

gnzlbg

136 commits

nikomatsakis

66 commits

avadacatavra

16 commits