How Rust transforms into Machine Code.

This page summarizes the projects mentioned and recommended in the original post on /r/rust

CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • rust

    Empowering everyone to build reliable and efficient software.

    MIR goes through many different transformations from the time it's built to what gets lowered to LLVM IR. It's also worth noting that borrow checking works on MIR. Some of the most important MIR transformations are drop elaboration and generator lowering.

  • CodeRabbit

    CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.

    CodeRabbit logo
  • astexplorer

    A web tool to explore the ASTs generated by various parsers.

    This is probably the most obvious step of how rustc transforms source code. The first step in this is lexing - it converts your rust code into a stream of tokens. The stream is similar to that of TokenStream in procedural macros, but the API is different - proc_macro requires stability, while rustc is very unstable. For example: rs fn main () {} transforms into Ident, Ident, OpenParen, CloseParen, OpenBrace, CloseBrace, At this point, it's important to note that identifiers are just represented as Ident. This is also represented through an enum internally via rustc_lexer. Then, the second stage, parsing. This transforms the tokens into a more useful form, the abstract syntax tree, Using the AST Explorer, putting in our code and selecting Rust language, we can see that the code above transforms into an AST. I won't paste the AST here due to sheerly how long it is, but I invite you to check it out yourself.

  • rustc-dev-guide

    A guide to how rustc works and how to contribute to it.

    It's possible - you could open an issue on the rustc-dev-guide repo if you'd like. https://github.com/rust-lang/rustc-dev-guide/

  • inkwell

    It's a New Kind of Wrapper for Exposing LLVM (Safely)

    inkwell is a great llvm binding for rust and it has an implementation of kaleidoscope

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • The rust project has a burnout problem

    3 projects | news.ycombinator.com | 17 Jan 2024
  • A language like C, but with a borrow-checker

    1 project | news.ycombinator.com | 18 Nov 2023
  • Ask HN: Which language will you try for this year's Advent of Code and why?

    1 project | news.ycombinator.com | 15 Nov 2023
  • Does modern implementation use tagged pointers/values?

    1 project | /r/ProgrammingLanguages | 27 May 2023
  • Brainfk-rs: A brainfuck to WebAssembly compiler written in Rust

    1 project | /r/Compilers | 30 Apr 2023

Did you konow that Rust is
the 5th most popular programming language
based on number of metions?