From: Utkarsh Bahuguna <[email protected]>

Updating core-1.49.expected meant running the rig and copying its
output over by hand. This script compiles core with the same flags and
cleanup as core-diagnostics.exp and writes the file directly, and the
rig's log now points at it when the output changes.

Assisted-by: Claude Opus (Anthropic)

gcc/testsuite/ChangeLog:

        * rust/core/regen-core-expected.sh: New script.
        * rust/core/core-diagnostics.exp: Mention it when the output
        differs.

Signed-off-by: Utkarsh Bahuguna <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: 
https://github.com/Rust-GCC/gccrs/commit/930cd96bb36ece6749ecac82aafb1eb3f054b908

The commit has NOT been mentioned in any issue.

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/5076

 gcc/testsuite/rust/core/core-diagnostics.exp  |  2 +
 .../rust/core/regen-core-expected.sh          | 44 +++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100755 gcc/testsuite/rust/core/regen-core-expected.sh

diff --git a/gcc/testsuite/rust/core/core-diagnostics.exp 
b/gcc/testsuite/rust/core/core-diagnostics.exp
index 5e9deee5a..eebac9761 100644
--- a/gcc/testsuite/rust/core/core-diagnostics.exp
+++ b/gcc/testsuite/rust/core/core-diagnostics.exp
@@ -57,6 +57,8 @@ proc core-diagnostics { } {
     catch { exec diff -u $expected $actual } diff
     regsub {\nchild process exited abnormally$} $diff "" diff
     send_log "diff -u core-1.49.expected core-diagnostics.out:\n$diff\n"
+    send_log "if the change is expected, update the file with\n"
+    send_log "  $srcdir/$subdir/regen-core-expected.sh <build dir>\n"
     fail "$name: diagnostics differ from core-1.49.expected, see rust.log"
 }
 
diff --git a/gcc/testsuite/rust/core/regen-core-expected.sh 
b/gcc/testsuite/rust/core/regen-core-expected.sh
new file mode 100755
index 000000000..355536d1b
--- /dev/null
+++ b/gcc/testsuite/rust/core/regen-core-expected.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Copyright (C) 2026 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Regenerate the expected output for compiling core 1.49
+#
+# usage: regen-core-expected.sh BUILD_DIR
+#
+# BUILD_DIR is your build directory, the one with gcc/gccrs in it.  Uses
+# the same flags and cleanup as core-diagnostics.exp.
+
+if [ $# -ne 1 ] || [ ! -x "$1/gcc/gccrs" ]; then
+  printf 'usage: %s BUILD_DIR\n' "$0" >&2
+  printf 'BUILD_DIR should point to your GCC build directory\n' >&2
+  exit 1
+fi
+
+bindir=$(cd "$1/gcc" && pwd)
+here=$(cd "$(dirname "$0")" && pwd)
+libdir=$(cd "$here/../../../../libgrust/rustc-lib" && pwd)
+
+flags="-frust-incomplete-and-experimental-compiler-do-not-use
+  -fdiagnostics-plain-output -fno-rust-debug -frust-edition=2018
+  -frust-crate=core -w"
+
+# the testsuite runs in the C locale, so quotes come out as plain '
+set -x
+LC_ALL=C "$bindir/gccrs" -B "$bindir" $flags -S "$libdir/core/src/lib.rs" \
+  -o /dev/null 2>&1 \
+  | sed -e "s|$libdir/||g" -e '/internal compiler error: /q' \
+  > "$here/core-1.49.expected"
-- 
2.56.1

Reply via email to