![]() Fix enzyme build errors After [this PR](https://github.com/rust-lang/rust/pull/136428) was merged, I switched to master and attempted building `./x.py build --stage 1 library` with the config mentioned in the enzyme rustbook but it resulted in some errors tho the config.example.toml build succeeded The errors were re: ### 1. Use of ref in match patterns The errors were related to match ergonomics in Rust 2024, where ref is no longer needed when matching on references. Examples: ``` error: binding modifiers may only be written when the default binding mode is `move` --> compiler/rustc_builtin_macros/src/autodiff.rs:136:31 | 136 | Annotatable::Item(ref iitem) => { | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode --> compiler/rustc_builtin_macros/src/autodiff.rs:136:13 | 136 | Annotatable::Item(ref iitem) => { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` help: remove the unnecessary binding modifier | 136 - Annotatable::Item(ref iitem) => { 136 + Annotatable::Item(iitem) => { | error: binding modifiers may only be written when the default binding mode is `move` --> compiler/rustc_builtin_macros/src/autodiff.rs:146:36 | 146 | Annotatable::AssocItem(ref assoc_item, _) => { | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode --> compiler/rustc_builtin_macros/src/autodiff.rs:146:13 | 146 | Annotatable::AssocItem(ref assoc_item, _) => { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` help: remove the unnecessary binding modifier | 146 - Annotatable::AssocItem(ref assoc_item, _) => { 146 + Annotatable::AssocItem(assoc_item, _) => { | error: binding modifiers may only be written when the default binding mode is `move` --> compiler/rustc_builtin_macros/src/autodiff.rs:174:31 | 174 | ... Annotatable::Item(ref iitem) => (iitem.vis.clone(), iitem.ide... | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode --> compiler/rustc_builtin_macros/src/autodiff.rs:174:13 | 174 | ... Annotatable::Item(ref iitem) => (iitem.vis.clone(), iitem.ident.c... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` help: remove the unnecessary binding modifier | 174 - Annotatable::Item(ref iitem) => (iitem.vis.clone(), iitem.ident.clone()), 174 + Annotatable::Item(iitem) => (iitem.vis.clone(), iitem.ident.clone()), | error: binding modifiers may only be written when the default binding mode is `move` --> compiler/rustc_builtin_macros/src/autodiff.rs:175:36 | 175 | Annotatable::AssocItem(ref assoc_item, _) => { | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode --> compiler/rustc_builtin_macros/src/autodiff.rs:175:13 | 175 | Annotatable::AssocItem(ref assoc_item, _) => { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` help: remove the unnecessary binding modifier | 175 - Annotatable::AssocItem(ref assoc_item, _) => { 175 + Annotatable::AssocItem(assoc_item, _) => { | error: could not compile `rustc_builtin_macros` (lib) due to 4 previous errors warning: build failed, waiting for other jobs to finish... Build completed unsuccessfully in 0:19:39 ``` ### 2. the use of external C blocks without unsafe in compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs (I don't have the error message handy) The first commit fixes the errors above --- ## Additional Improvement: `@ZuseZ4` suggested we consolidate the variants under `#[cfg(llvm_enzyme)]` and `#[cfg(not(llvm_enzyme))]` by conditionally checking for `cfg!(llvm_enzyme)` instead. This way, the autodiff code is compiled but not executed avoiding such regressions r? `@ZuseZ4` cc: `@oli-obk` |
||
---|---|---|
.github | ||
compiler | ||
library | ||
LICENSES | ||
src | ||
tests | ||
.clang-format | ||
.editorconfig | ||
.git-blame-ignore-revs | ||
.gitattributes | ||
.gitignore | ||
.gitmodules | ||
.ignore | ||
.mailmap | ||
Cargo.lock | ||
Cargo.toml | ||
CODE_OF_CONDUCT.md | ||
config.example.toml | ||
configure | ||
CONTRIBUTING.md | ||
COPYRIGHT | ||
INSTALL.md | ||
LICENSE-APACHE | ||
license-metadata.json | ||
LICENSE-MIT | ||
README.md | ||
RELEASES.md | ||
REUSE.toml | ||
rust-bors.toml | ||
rustfmt.toml | ||
triagebot.toml | ||
x | ||
x.ps1 | ||
x.py |
This is the main source code repository for Rust. It contains the compiler, standard library, and documentation.
Why Rust?
-
Performance: Fast and memory-efficient, suitable for critical services, embedded devices, and easily integrated with other languages.
-
Reliability: Our rich type system and ownership model ensure memory and thread safety, reducing bugs at compile-time.
-
Productivity: Comprehensive documentation, a compiler committed to providing great diagnostics, and advanced tooling including package manager and build tool (Cargo), auto-formatter (rustfmt), linter (Clippy) and editor support (rust-analyzer).
Quick Start
Read "Installation" from The Book.
Installing from Source
If you really want to install from source (though this is not recommended), see INSTALL.md.
Getting Help
See https://www.rust-lang.org/community for a list of chat platforms and forums.
Contributing
See CONTRIBUTING.md.
License
Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.
See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.
Trademark
The Rust Foundation owns and protects the Rust and Cargo trademarks and logos (the "Rust Trademarks").
If you want to use these names or brands, please read the media guide.
Third-party logos may be subject to third-party copyrights and trademarks. See Licenses for details.