Skip to content

Commit 4df81fc

Browse files
committed
ci(rustc_codegen_tuffy): stabilize crate tests against syn nightly drift
Pin the syn crate-test checkout to a known revision and apply a local compatibility patch for nightly-2026-03-28. This keeps the crate-test runner aligned with the backend toolchain instead of depending on whatever syn master happens to expose in its rustc_ast-facing test helpers. Also route the crate-test script through a shared toolchain variable so the backend build, bitflags, syn, and hashbrown sections all use the same nightly.
1 parent 8928558 commit 4df81fc

2 files changed

Lines changed: 32 additions & 7 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/tests/common/eq.rs b/tests/common/eq.rs
2+
index afdba57..4b2d15b 100644
3+
--- a/tests/common/eq.rs
4+
+++ b/tests/common/eq.rs
5+
@@ -346,8 +346,8 @@ macro_rules! spanless_eq_struct {
6+
} => {
7+
impl $(<$param: SpanlessEq>)* SpanlessEq for $($name)::+ $(<$param>)* {
8+
fn eq(&self, other: &Self) -> bool {
9+
- let $($name)::+ { $($field: $this,)* $($ignore: _,)* } = self;
10+
- let $($name)::+ { $($field: $other,)* $($ignore: _,)* } = other;
11+
+ let $($name)::+ { $($field: $this,)* $($ignore: _,)* .. } = self;
12+
+ let $($name)::+ { $($field: $other,)* $($ignore: _,)* .. } = other;
13+
true $(&& SpanlessEq::eq($this, $other))*
14+
}
15+
}

rustc_codegen_tuffy/tests/run-crate-tests.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ mkdir -p "$TEMP_DIR"
1818

1919
overall_pass=0
2020
overall_fail=0
21+
RUST_NIGHTLY="${TUFFY_CRATE_TEST_TOOLCHAIN:-nightly-2026-03-28}"
2122

2223
# ── Build ─────────────────────────────────────────────────────────────────────
2324

2425
if [ -n "${BACKEND:-}" ]; then
2526
echo "=== Using pre-built backend ==="
2627
else
2728
echo "=== Build ==="
28-
cargo build --manifest-path "$CRATE_ROOT/Cargo.toml" --release
29+
cargo +"$RUST_NIGHTLY" build --manifest-path "$CRATE_ROOT/Cargo.toml" --release
2930
BACKEND="$CRATE_ROOT/target/release/librustc_codegen_tuffy.so"
3031
fi
3132

@@ -62,7 +63,7 @@ cat > "$BITFLAGS_DIR/.cargo/config.toml" <<CFGEOF
6263
rustflags = ["-Z", "codegen-backend=$BACKEND"]
6364
CFGEOF
6465

65-
if cargo +nightly-2026-03-28 test --manifest-path "$BITFLAGS_DIR/Cargo.toml"; then
66+
if cargo +"$RUST_NIGHTLY" test --manifest-path "$BITFLAGS_DIR/Cargo.toml"; then
6667
overall_pass=$((overall_pass + 1))
6768
else
6869
overall_fail=$((overall_fail + 1))
@@ -73,12 +74,21 @@ echo ""
7374
# syn is a widely-used parser crate. Because many proc-macros depend on syn
7475
# from crates.io, TUFFY_SRC_DIR restricts the tuffy backend to the workspace
7576
# copy of syn (prevents applying tuffy to the registry copy used by proc-macros).
77+
# The checkout is pinned and patched because nightly-2026-03-28 changed
78+
# rustc_ast::UseTree in a way that breaks syn's floating test-suite snapshots.
7679

7780
SYN_DIR="$REPO_ROOT/scratch/syn"
81+
SYN_REV="ae257c4e05a338f73655aa1fa3d144e047daccf1"
82+
SYN_PATCH="$SCRIPT_DIR/patches/syn-nightly-2026-03-28.patch"
7883
if [ ! -d "$SYN_DIR" ]; then
7984
echo "=== Cloning syn ==="
8085
git clone --filter=blob:none https://github.com/dtolnay/syn.git "$SYN_DIR"
8186
fi
87+
if ! git -C "$SYN_DIR" cat-file -e "$SYN_REV^{commit}" 2>/dev/null; then
88+
git -C "$SYN_DIR" fetch --filter=blob:none origin "$SYN_REV"
89+
fi
90+
git -C "$SYN_DIR" checkout --force "$SYN_REV"
91+
git -C "$SYN_DIR" apply "$SYN_PATCH"
8292
echo "=== Syn cargo test ==="
8393

8494
WRAPPER_EXEC="$TEMP_DIR/rustc-wrapper-tuffy"
@@ -91,7 +101,7 @@ if RUSTC_WRAPPER="$WRAPPER_EXEC" \
91101
TUFFY_BACKEND="$BACKEND" \
92102
TUFFY_CRATE="syn" \
93103
TUFFY_SRC_DIR="$SYN_DIR" \
94-
cargo test --manifest-path "$SYN_DIR/Cargo.toml" --all-features; then
104+
cargo +"$RUST_NIGHTLY" test --manifest-path "$SYN_DIR/Cargo.toml" --all-features; then
95105
overall_pass=$((overall_pass + 1))
96106
else
97107
overall_fail=$((overall_fail + 1))
@@ -121,19 +131,19 @@ echo "=== Hashbrown release-focused tests ==="
121131
if CARGO_TARGET_DIR="$HASHBROWN_TARGET_DIR" \
122132
RUSTFLAGS="-Zcodegen-backend=$BACKEND" \
123133
RUSTDOCFLAGS="-Zcodegen-backend=$BACKEND" \
124-
cargo +nightly-2026-03-28 build --manifest-path "$HASHBROWN_DIR/Cargo.toml" --target x86_64-unknown-linux-gnu --no-default-features \
134+
cargo +"$RUST_NIGHTLY" build --manifest-path "$HASHBROWN_DIR/Cargo.toml" --target x86_64-unknown-linux-gnu --no-default-features \
125135
&& CARGO_TARGET_DIR="$HASHBROWN_TARGET_DIR" \
126136
RUSTFLAGS="-Zcodegen-backend=$BACKEND" \
127137
RUSTDOCFLAGS="-Zcodegen-backend=$BACKEND" \
128-
cargo +nightly-2026-03-28 build --manifest-path "$HASHBROWN_DIR/Cargo.toml" --target x86_64-unknown-linux-gnu --release --no-default-features \
138+
cargo +"$RUST_NIGHTLY" build --manifest-path "$HASHBROWN_DIR/Cargo.toml" --target x86_64-unknown-linux-gnu --release --no-default-features \
129139
&& CARGO_TARGET_DIR="$HASHBROWN_TARGET_DIR" \
130140
RUSTFLAGS="-Zcodegen-backend=$BACKEND" \
131141
RUSTDOCFLAGS="-Zcodegen-backend=$BACKEND" \
132-
cargo +nightly-2026-03-28 test --manifest-path "$HASHBROWN_DIR/Cargo.toml" --target x86_64-unknown-linux-gnu --release --no-fail-fast \
142+
cargo +"$RUST_NIGHTLY" test --manifest-path "$HASHBROWN_DIR/Cargo.toml" --target x86_64-unknown-linux-gnu --release --no-fail-fast \
133143
&& CARGO_TARGET_DIR="$HASHBROWN_TARGET_DIR" \
134144
RUSTFLAGS="-Zcodegen-backend=$BACKEND" \
135145
RUSTDOCFLAGS="-Zcodegen-backend=$BACKEND" \
136-
cargo +nightly-2026-03-28 test --manifest-path "$HASHBROWN_DIR/Cargo.toml" --target x86_64-unknown-linux-gnu --release --features rustc-internal-api,serde,rayon,nightly --no-fail-fast; then
146+
cargo +"$RUST_NIGHTLY" test --manifest-path "$HASHBROWN_DIR/Cargo.toml" --target x86_64-unknown-linux-gnu --release --features rustc-internal-api,serde,rayon,nightly --no-fail-fast; then
137147
overall_pass=$((overall_pass + 1))
138148
else
139149
overall_fail=$((overall_fail + 1))

0 commit comments

Comments
 (0)