Skip to content

Commit 3ab490b

Browse files
committed
Disable autodiff bootstrapping
1 parent c47f0e3 commit 3ab490b

File tree

5 files changed

+48
-28
lines changed

5 files changed

+48
-28
lines changed

compiler/rustc_builtin_macros/src/errors.rs

-8
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,6 @@ mod autodiff {
187187
pub(crate) act: String,
188188
}
189189

190-
#[derive(Diagnostic)]
191-
#[diag(builtin_macros_autodiff_mode)]
192-
pub(crate) struct AutoDiffInvalidMode {
193-
#[primary_span]
194-
pub(crate) span: Span,
195-
pub(crate) mode: String,
196-
}
197-
198190
#[derive(Diagnostic)]
199191
#[diag(builtin_macros_autodiff_width)]
200192
pub(crate) struct AutoDiffInvalidWidth {

compiler/rustc_builtin_macros/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1010
#![doc(rust_logo)]
1111
#![feature(assert_matches)]
12-
#![feature(autodiff)]
12+
#![cfg_attr(not(bootstrap), feature(autodiff))]
1313
#![feature(box_patterns)]
1414
#![feature(decl_macro)]
1515
#![feature(if_let_guard)]

library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ pub mod assert_matches {
226226

227227
// We don't export this through #[macro_export] for now, to avoid breakage.
228228
#[unstable(feature = "autodiff", issue = "124509")]
229+
#[cfg(not(bootstrap))]
229230
/// Unstable module containing the unstable `autodiff` macro.
230231
pub mod autodiff {
231232
#[unstable(feature = "autodiff", issue = "124509")]

library/core/src/macros/mod.rs

+41-17
Original file line numberDiff line numberDiff line change
@@ -1519,33 +1519,57 @@ pub(crate) mod builtin {
15191519
($file:expr $(,)?) => {{ /* compiler built-in */ }};
15201520
}
15211521

1522-
/// Automatic Differentiation macro which allows generating a new function to compute
1523-
/// the derivative of a given function. It may only be applied to a function.
1524-
/// The expected usage syntax is
1525-
/// `#[autodiff(NAME, MODE, INPUT_ACTIVITIES, OUTPUT_ACTIVITY)]`
1526-
/// where:
1527-
/// NAME is a string that represents a valid function name.
1528-
/// MODE is any of Forward, Reverse, ForwardFirst, ReverseFirst.
1529-
/// INPUT_ACTIVITIES consists of one valid activity for each input parameter.
1530-
/// OUTPUT_ACTIVITY must not be set if we implicitly return nothing (or explicitly return
1531-
/// `-> ()`). Otherwise it must be set to one of the allowed activities.
1532-
#[unstable(feature = "autodiff", issue = "124509")]
1533-
#[allow_internal_unstable(rustc_attrs)]
1534-
#[rustc_builtin_macro]
1535-
pub macro autodiff($item:item) {
1536-
/* compiler built-in */
1537-
}
1538-
1522+
/// the derivative of a given function in the forward mode of differentiation.
1523+
/// It may only be applied to a function.
1524+
///
1525+
/// The expected usage syntax is:
1526+
/// `#[autodiff_forward(NAME, INPUT_ACTIVITIES, OUTPUT_ACTIVITY)]`
1527+
///
1528+
/// - `NAME`: A string that represents a valid function name.
1529+
/// - `INPUT_ACTIVITIES`: Specifies one valid activity for each input parameter.
1530+
/// - `OUTPUT_ACTIVITY`: Must not be set if the function implicitly returns nothing
1531+
/// (or explicitly returns `-> ()`). Otherwise, it must be set to one of the allowed activities.
1532+
///
1533+
/// # Example
1534+
///
1535+
/// ```rust
1536+
/// #[autodiff_forward(df, Dual, Dual, Dual)]
1537+
/// fn f(x: f64, y: f64) -> f64 {
1538+
/// x * y
1539+
/// }
1540+
/// ```
15391541
#[unstable(feature = "autodiff", issue = "124509")]
15401542
#[allow_internal_unstable(rustc_attrs)]
15411543
#[rustc_builtin_macro]
1544+
#[cfg(not(bootstrap))]
15421545
pub macro autodiff_forward($item:item) {
15431546
/* compiler built-in */
15441547
}
15451548

1549+
/// Automatic Differentiation macro which allows generating a new function to compute
1550+
/// the derivative of a given function in the reverse mode of differentiation.
1551+
/// It may only be applied to a function.
1552+
///
1553+
/// The expected usage syntax is:
1554+
/// `#[autodiff_reverse(NAME, INPUT_ACTIVITIES, OUTPUT_ACTIVITY)]`
1555+
///
1556+
/// - `NAME`: A string that represents a valid function name.
1557+
/// - `INPUT_ACTIVITIES`: Specifies one valid activity for each input parameter.
1558+
/// - `OUTPUT_ACTIVITY`: Must not be set if the function implicitly returns nothing
1559+
/// (or explicitly returns `-> ()`). Otherwise, it must be set to one of the allowed activities.
1560+
///
1561+
/// # Example
1562+
///
1563+
/// ```rust
1564+
/// #[autodiff_reverse(df, Active, Active, Active)]
1565+
/// fn f(x: f64, y: f64) -> f64 {
1566+
/// x * y
1567+
/// }
1568+
/// ```
15461569
#[unstable(feature = "autodiff", issue = "124509")]
15471570
#[allow_internal_unstable(rustc_attrs)]
15481571
#[rustc_builtin_macro]
1572+
#[cfg(not(bootstrap))]
15491573
pub macro autodiff_reverse($item:item) {
15501574
/* compiler built-in */
15511575
}

library/std/src/lib.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@
281281
#![feature(allow_internal_unsafe)]
282282
#![feature(allow_internal_unstable)]
283283
#![feature(asm_experimental_arch)]
284-
#![feature(autodiff)]
284+
#![cfg_attr(not(bootstrap), feature(autodiff))]
285285
#![feature(cfg_sanitizer_cfi)]
286286
#![feature(cfg_target_thread_local)]
287287
#![feature(cfi_encoding)]
@@ -632,12 +632,15 @@ pub mod simd {
632632
#[doc(inline)]
633633
pub use crate::std_float::StdFloat;
634634
}
635+
635636
#[unstable(feature = "autodiff", issue = "124509")]
637+
#[cfg(not(bootstrap))]
636638
/// This module provides support for automatic differentiation.
637639
pub mod autodiff {
638640
/// This macro handles automatic differentiation.
639-
pub use core::autodiff::autodiff;
641+
pub use core::autodiff::{autodiff_forward, autodiff_reverse};
640642
}
643+
641644
#[stable(feature = "futures_api", since = "1.36.0")]
642645
pub mod task {
643646
//! Types and Traits for working with asynchronous tasks.

0 commit comments

Comments
 (0)