impl 和 traits 如何在较低级别上工作?
How does impl and traits work on a lower level?
有一天我对在 Rust 编译器上工作很感兴趣,但我想深入了解 Rust 中的一切是如何实现的。我理解 Rust 中的大部分概念,或者它们是如何实现的。但是,我不太确定 impl 或 traits 是在较低级别实现的吗?比如他们会生成什么样的代码等等...
谢谢
这个问题很不明确(详尽的答案读起来会很痛苦),所以我只向您介绍两件事:
Rust playground 可以显示生成的 LLVM IR 和程序集。
librustc 的 Rust source code is publicly available. The code you seek lives in librustc (which takes the AST from libsyntax, typechecked by librustc_typeck
and borrow-checked by librustc_borrowck
and drives LLVM byte code creation). The README.md 为您提供了很多信息。
有一天我对在 Rust 编译器上工作很感兴趣,但我想深入了解 Rust 中的一切是如何实现的。我理解 Rust 中的大部分概念,或者它们是如何实现的。但是,我不太确定 impl 或 traits 是在较低级别实现的吗?比如他们会生成什么样的代码等等...
谢谢
这个问题很不明确(详尽的答案读起来会很痛苦),所以我只向您介绍两件事:
Rust playground 可以显示生成的 LLVM IR 和程序集。
librustc 的 Rust source code is publicly available. The code you seek lives in librustc (which takes the AST from libsyntax, typechecked by librustc_typeck
and borrow-checked by librustc_borrowck
and drives LLVM byte code creation). The README.md 为您提供了很多信息。