Rust 2015 Rust 2015 has a theme of "stability". It commenced with the release of 1.0, and is the "default edition". The edition system was conceived in late 2017, but Rust 1.0 was released in May of 2015. As such, 2015 is the edition that y...
Advanced migration strategies How migrations work cargo fix --edition works by running the equivalent of cargo check on your project with special lints enabled which will detect code that may not compile in the next edition. These lints inc...
Transitioning an existing project to a new edition Rust includes tooling to automatically transition a project from one edition to the next. It will update your source code so that it is compatible with the next edition. Briefly, the steps...
Creating a new project A new project created with Cargo is configured to use the latest edition by default: $ cargo new foo Creating binary (application) `foo` package note: see more `Cargo.toml` keys and their definitions at https://doc.ru...
What are Editions? In May 2015, the release of Rust 1.0 established "stability without stagnation" as a core Rust axiom. Since then, Rust has committed to a pivotal rule: once a feature is released through stable, contributors will continue...
Introduction Welcome to The Rust Edition Guide! "Editions" are Rust's way of introducing changes into the language that would not otherwise be backwards compatible. In this guide, we'll discuss: • What editions are • Which changes are conta...
Glossary Abstract syntax tree An ‘abstract syntax tree’, or ‘AST’, is an intermediate representation of the structure of the program when the compiler is compiling it. Alignment The alignment of a value specifies what addresses values are p...
Test summary The following is a summary of the total tests that are linked to individual rule identifiers within the reference. {{summary-table}}
Influences Rust is not a particularly original language, with design elements coming from a wide range of sources. Some of these are listed below (including elements that have since been removed): • SML, OCaml: algebraic data types, pattern...
Appendix: Macro follow-set ambiguity formal specification This page documents the formal specification of the follow rules for Macros By Example. They were originally specified in RFC 550, from which the bulk of this text is copied, and exp...
Syntax index This appendix provides an index of tokens and common forms with links to where those elements are defined. Keywords | Keyword | Use | |---------------|-----| | _ | wildcard pattern, inferred const, inferred type, placeholder li...
Grammar summary The following is a summary of the grammar production rules. For details on the syntax of this grammar, see [notation.grammar.syntax]. {{ grammar-summary }}
The Rust runtime This section documents features that define some aspects of the Rust runtime. The global_allocator attribute The global_allocator [attribute][attributes] selects a [memory allocator][std::alloc]. [!EXAMPLE] use core::alloc:...
Application binary interface (ABI) This section documents features that affect the ABI of the compiled output of a crate. See extern functions for information on specifying the ABI for exporting functions. See external blocks for informatio...
Constant evaluation Constant evaluation is the process of computing the result of expressions during compilation. Only a subset of all expressions can be evaluated at compile-time. Constant expressions Certain forms of expressions, called c...
Behavior not considered unsafe The Rust compiler does not consider the following behaviors unsafe, though a programmer may (should) find them undesirable, unexpected, or erroneous. • Deadlocks • Leaks of memory and other resources • Exiting...
Behavior considered undefined Rust code is incorrect if it exhibits any of the behaviors in the following list. This includes code within unsafe blocks and unsafe functions. unsafe only means that avoiding undefined behavior is on the progr...
The unsafe keyword The unsafe keyword is used to create or discharge the obligation to prove something safe. Specifically: • It is used to mark code that defines extra safety conditions that must be upheld elsewhere. • This includes unsafe...
Unsafety Unsafe operations are those that can potentially violate the memory-safety guarantees of Rust's static semantics. The following language level features cannot be used in the safe subset of Rust: • Dereferencing a raw pointer. • Rea...