Skip to content

Commit 27ec35d

Browse files
authored
Rollup merge of rust-lang#131470 - EnzymeAD:enzyme-testinfra2, r=jieyouxu
add test infra to explicitely test rustc with autodiff/enzyme disabled I assume this is not what you want for now, but I'll update the PR once I understand how the ignore- directives work. To summarize the situation, we want a feature gate test where we don't enable the autodiff feature using `#![feature(autodiff)]`. There are two situations. 1) We have a rustc which was build without autodiff support (current default): It gives one error about the feature being needed and one error about this rustc version being build without autodiff support. 2) We have a rustc which was build with autodiff support (i.e. for now a custom build): It gives one error about the feature being needed. We have a `//```@needs-enzyme```` directive which we can use in revisions for the second case. However, we have no way to specify that needs-enzyme implies that the second error should not be seen. This ads a way of passing the following test: ``` //@ revisions: has_support no_support //```@[has_support]``` needs-enzyme //```@[no_support]``` needs-enzyme-disabled #![crate_type = "lib"] #[autodiff(dfoo, Reverse)] //[has_support]~^ ERROR use of unstable library feature 'autodiff' [E0658] //[no_support]~^^ ERROR use of unstable library feature 'autodiff' [E0658] //[no_support]~| ERROR this rustc version does not support autodiff fn foo() {} ``` Cherry picking this PR to my frontend pr makes the test above pass in both configurations (enzyme=true/false in config.toml). I'm open to other changes that make this testcase pass. r? ```@jieyouxu``` Tracking: - rust-lang#124509
2 parents af7bb0f + b12dc20 commit 27ec35d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/tools/compiletest/src/command-list.rs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
4949
"ignore-eabi",
5050
"ignore-emscripten",
5151
"ignore-endian-big",
52+
"ignore-enzyme",
5253
"ignore-freebsd",
5354
"ignore-fuchsia",
5455
"ignore-gdb",

src/tools/compiletest/src/header/cfg.rs

+6
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ pub(super) fn parse_cfg_name_directive<'a>(
166166
message: "when the target vendor is Apple"
167167
}
168168

169+
condition! {
170+
name: "enzyme",
171+
condition: config.has_enzyme,
172+
message: "when rustc is built with LLVM Enzyme"
173+
}
174+
169175
// Technically the locally built compiler uses the "dev" channel rather than the "nightly"
170176
// channel, even though most people don't know or won't care about it. To avoid confusion, we
171177
// treat the "dev" channel as the "nightly" channel when processing the directive.

0 commit comments

Comments
 (0)